College Menfess Tweet Emotion Project
This project is a Flask web application that predicts the emotions or sentiment of tweets sent to a college menfess account. The application uses machine learning models to analyze and classify the tweets.
Features
- Emotion Prediction: Predicts the emotion of a tweet using a custom prediction function.
- Support Vector Machine (SVM) Prediction: Provides an additional prediction using a Support Vector Machine (SVM) model.
Project Structure
.
├── main.py # The main Flask application script
├── script/
│ └── func.py # Contains the function `predictTweet` used for predicting the tweet emotion
├── kmeans.py # Contains the functions `predict_label` and `predict_label_svm` for SVM prediction
├── templates/
│ └── ... # Directory for HTML templates (if any)
└── README.md # Project documentation
Getting Started
Prerequisites
- Python 3.x
- Flask
- NumPy
- Pickle (for model loading)
Installation
-
Clone the repository:
git clone https://github.com/akhmadramadani/collegemenfess-emotion.git cd collegemenfess-emotion -
Install the required Python packages:
pip install -r requirements.txt
Usage
-
Run the Flask application:
python main.py -
The application will start on
http://127.0.0.1:5000/by default.
API Endpoints
-
GET /: Returns a simple greeting message. -
POST /predict: Predicts the emotion of the provided tweet. Requires the following form data:tweet: The tweet text to be analyzed.
Example request:
curl -X POST -F 'tweet=Your tweet text here' http://127.0.0.1:5000/predictExample response:
{ "prediction": "positive", "predict_using_svm": "neutral" } -
POST /predict_svm: Predicts the emotion using the SVM model only. Requires the following form data:tweet: The tweet text to be analyzed.
Example request:
curl -X POST -F 'tweet=Your tweet text here' http://127.0.0.1:5000/predict_svmExample response:
{ "prediction": "neutral" }
Environment Variables
PORT: Set the port for the Flask application. Default is5000.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please submit a pull request or open an issue for any feature requests or bug reports.
Authors
- Akhmad Ramadani - Github
This `README.md` file provides a clear overview of the project, instructions on how to set it up, and details about the API endpoints. Be sure to replace placeholders like `Your Name` and `Your GitHub` with the appropriate details for your project.