|
Download README.md from felipermtrindade/FoodReviewAI-Sentiment: direct link, hf CLI and curl.
- Browser
- Download file 3.06 kB
-
https://huggingface.co/felipermtrindade/FoodReviewAI-Sentiment/resolve/main/README.md
- Command line
-
hf download hf://felipermtrindade/FoodReviewAI-Sentiment/README.md
-
curl -L -o README.md https://huggingface.co/felipermtrindade/FoodReviewAI-Sentiment/resolve/main/README.md
3.06 kB
| language: pt | |
| tags: | |
| - sentiment-analysis | |
| - text-classification | |
| - scikit-learn | |
| - tf-idf | |
| - logistic-regression | |
| metrics: | |
| - accuracy | |
| - precision | |
| - recall | |
| - f1 | |
| # FoodReviewAI - Restaurant Review Sentiment Classifier | |
| ## Model Description | |
| FoodReviewAI is a machine learning model developed to classify restaurant reviews written in Portuguese as positive or negative. | |
| The project demonstrates a complete machine learning workflow, including data preprocessing, model training, evaluation, and API integration. | |
| ## Model Architecture | |
| - **Text representation:** TF-IDF (maximum 10,000 features, unigrams and bigrams) | |
| - **Classification algorithm:** Logistic Regression | |
| - **Class balancing:** `class_weight="balanced"` | |
| - **Framework:** scikit-learn | |
| ## Training Data | |
| The model was trained using the StarRest dataset, containing reviews of Brazilian restaurants. | |
| After preprocessing, 16,293 Portuguese reviews were selected: | |
| - 15,207 positive reviews | |
| - 1,086 negative reviews | |
| Only reviews from platforms 1, 2, and 3 were used. | |
| Reviews rated 1 or 2 were labeled negative, while reviews rated 4 or 5 were labeled positive. Reviews rated 3 were excluded. | |
| ## Evaluation Results | |
| The dataset was split into 80% training and 20% testing, using stratified sampling. | |
| | Metric | Result | | |
| |---|---| | |
| | Accuracy | 95.6% | | |
| | Negative precision | 0.61 | | |
| | Negative recall | 0.91 | | |
| | Negative F1-score | 0.73 | | |
| | Positive F1-score | 0.98 | | |
| ### Confusion Matrix | |
| | | Predicted Negative | Predicted Positive | | |
| |---|---|---| | |
| | Actual Negative | 198 | 19 | | |
| | Actual Positive | 125 | 2917 | | |
| ## Usage | |
| Install the required libraries: | |
| ```bash | |
| pip install scikit-learn joblib huggingface_hub | |
| ``` | |
| Download and load the trained model: | |
| ```python | |
| from huggingface_hub import hf_hub_download | |
| import joblib | |
| caminho = hf_hub_download( | |
| repo_id="felipermtrindade/FoodReviewAI-Sentiment", | |
| filename="foodreview_model.pkl" | |
| ) | |
| modelo = joblib.load(caminho) | |
| texto = ["A comida estava maravilhosa e o atendimento foi excelente!"] | |
| resultado = modelo.predict(texto) | |
| print("Positiva" if resultado[0] == 1 else "Negativa") | |
| ``` | |
| Only load this model file if you trust its publisher. Joblib files use Python serialization and can execute code when loaded. | |
| ## Limitations | |
| - The dataset is highly imbalanced, with approximately 93% positive reviews. | |
| - The model performs binary classification and may struggle with mixed or neutral sentiments. | |
| - Sentiment labels were derived from customer ratings, not manually annotated. | |
| - The model was trained using Portuguese restaurant reviews and may not generalize to other domains. | |
| - Predicted probabilities have not been independently calibrated. | |
| ## Source Code | |
| [FoodReviewAI on GitHub](https://github.com/felipemtrindade/FoodReviewAI) | |
| ## Dataset | |
| [StarRest - Mendeley Data](https://data.mendeley.com/datasets/r5th4s7vpv/2) | |
| ## Future Improvements | |
| - Compare performance against Portuguese BERT models. | |
| - Evaluate errors and ambiguous reviews. | |
| - Improve minority-class classification. | |
| - Add automated testing and model versioning. |