An open API service indexing awesome lists of open source software.

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.

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.