https://github.com/hayatiyrtgl/flm_reviews_analysis
Sentiment analysis using ML classifiers for text data.
https://github.com/hayatiyrtgl/flm_reviews_analysis
countvectorizer machine-learning natural-language-processing natural-language-understanding nltk python python3 random-forest random-forest-classifier scikitlearn-machine-learning sentiment-analysis sentiment-classification sklearn sklearn-classify
Last synced: 4 months ago
JSON representation
Sentiment analysis using ML classifiers for text data.
- Host: GitHub
- URL: https://github.com/hayatiyrtgl/flm_reviews_analysis
- Owner: HayatiYrtgl
- License: mit
- Created: 2024-04-24T19:21:09.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-24T19:22:07.000Z (over 2 years ago)
- Last Synced: 2025-04-08T18:39:24.734Z (over 1 year ago)
- Topics: countvectorizer, machine-learning, natural-language-processing, natural-language-understanding, nltk, python, python3, random-forest, random-forest-classifier, scikitlearn-machine-learning, sentiment-analysis, sentiment-classification, sklearn, sklearn-classify
- Language: Jupyter Notebook
- Homepage:
- Size: 520 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This script is a sentiment analysis project using machine learning classifiers such as Random Forests, Logistic Regression, Naive Bayes, K-Nearest Neighbors (KNN), and Support Vector Machines (SVM). Let's break down the key parts of the code:
1. **Data Loading and Preprocessing**:
- The script loads training and test data from CSV files.
- It checks for missing values in both datasets and converts text to lowercase.
- Regular expressions are used to remove non-alphabetic characters from the text.
- Text is split into words and stemmed using the Porter stemming algorithm.
- Stop words are removed from the text.
2. **Feature Extraction**:
- CountVectorizer is used to convert text data into numerical features.
3. **Model Training**:
- Random Forests, Logistic Regression, Naive Bayes, KNN, and SVM classifiers are trained on the training data.
4. **Model Evaluation**:
- Accuracy and F1 score are computed for each classifier using the test data.
5. **Prediction**:
- There's a function `preprocess` defined to preprocess custom input.
- Custom input is preprocessed and transformed using the trained CountVectorizer.
- Predictions are made using each classifier for the custom input.
6. **Output**:
- For the custom input, the script outputs the predicted probabilities (for Logistic Regression) and the predicted classes for each classifier.
Overall, this script provides a comprehensive sentiment analysis pipeline, from data preprocessing to model evaluation and prediction. It demonstrates the use of various machine learning classifiers for sentiment analysis tasks.