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.
- 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.
.
├── 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
- Python 3.x
- Flask
- NumPy
- Pickle (for model loading)
-
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
-
Run the Flask application:
python main.py
-
The application will start on
http://127.0.0.1:5000/
by default.
-
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/predict
Example 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_svm
Example response:
{ "prediction": "neutral" }
PORT
: Set the port for the Flask application. Default is5000
.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please submit a pull request or open an issue for any feature requests or bug reports.
- 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.