This project is a Sentiment Analysis Tool that classifies text into positive or negative sentiment using machine learning. It provides a RESTful API built with Flask and uses scikit-learn for model training.
Sentiment analysis, also known as opinion mining, is a natural language processing (NLP) technique used to determine whether data is positive, negative, or neutral. This tool leverages machine learning to analyze the sentiment of text data.
- Python 3.10
- Virtual Environment (venv)
- Kaggle account with API credentials
-
Clone the repository:
git clone https://github.com/eatwhatyoukill/sentiment-analysis.git
-
Create and activate a virtual environment:
python -m venv venv venv\Scripts\activate # For Windows source venv/bin/activate # For Linux/Mac
-
Install the required Python packages using pip:
pip install -r requirements.txt
-
Set up Kaggle API credentials:
- Ensure you have your Kaggle API key saved in a
kaggle.json
file in the.kaggle
directory within your home directory.
- Ensure you have your Kaggle API key saved in a
To run the application, use the following command:
python app.py
You can send a POST request to the /predict
endpoint with the text you want to analyze. For example, using curl:
curl -X POST -H "Content-Type: application/json" -d "{\"text\": \"I love this product!\"}" http://127.0.0.1:5000/predict
This will return a JSON response indicating whether the sentiment is positive or negative.
- Text Classification: Classifies text into positive or negative sentiment.
- RESTful API: Provides a RESTful API using Flask.
- Model Training: Trains a machine learning model using scikit-learn.
- Python: The primary programming language used for development.
- Flask: A lightweight WSGI web application framework used to create the API.
- scikit-learn: A machine learning library used to build and train the sentiment analysis model.
- joblib: Used for model serialization and deserialization.
- Kaggle API: Used to download the dataset from Kaggle.
This project is configured to be deployed on Azure App Service using GitHub Actions.
The GitHub Actions workflow file is located at .github/workflows/main_sentimentAnalysis30081996.yml
. It defines the steps to build and deploy the application to Azure.
Ensure the following secrets are added to your GitHub repository:
AZUREAPPSERVICE_CLIENTID
AZUREAPPSERVICE_TENANTID
AZUREAPPSERVICE_SUBSCRIPTIONID
- Commit and push your changes to the
main
branch. - The GitHub Actions workflow will automatically trigger and deploy the application to Azure.
Report an Issue or Request a Feature
Contributions are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes and commit them (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- The dataset used in this project is sourced from Kaggle.
- Special thanks to the contributors of the libraries and tools used in this project.
If you have any questions or suggestions, feel free to reach out.