Instructions to use itslucasmiranda/ml-review-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use itslucasmiranda/ml-review-classifier with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("itslucasmiranda/ml-review-classifier", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
ML Review Classifier
Version: v0.1.0-baseline
Status: Experimental baseline, not production-ready.
A reproducible sentiment classification model developed with Python, scikit-learn, TF-IDF and Logistic Regression.
Model Description
This model classifies English-language reviews into two categories:
0: Negative1: Positive
It uses a scikit-learn pipeline combining TfidfVectorizer and LogisticRegression.
Dataset
Source: UCI Sentiment Labelled Sentences
The original dataset contains 3,000 reviews from Amazon, IMDb and Yelp.
Following preprocessing and duplicate removal, 2,979 examples remained.
| Split | Samples |
|---|---|
| Training | 1,784 |
| Validation | 593 |
| Test | 602 |
Dataset source: https://archive.ics.uci.edu/dataset/331/sentiment+labelled+sentences
Dataset citation: Kotzias, D. (2015). Sentiment Labelled Sentences. UCI Machine Learning Repository. DOI: 10.24432/C57604.
The dataset is distributed under CC BY 4.0.
Model Architecture
- Feature extraction: TF-IDF
- N-grams: 1โ2
- Minimum document frequency: 2
- Classifier: Logistic Regression
- Maximum iterations: 1,000
- Random state: 42
Evaluation Results
Validation
| Metric | Result |
|---|---|
| Accuracy | 79.76% |
| Macro F1 | 79.76% |
Final Test
| Metric | Result |
|---|---|
| Accuracy | 81.56% |
| Macro Precision | 81.56% |
| Macro Recall | 81.56% |
| Macro F1 | 81.56% |
The final test was performed on 602 held-out reviews.
Confusion Matrix
| Actual / Predicted | Negative | Positive |
|---|---|---|
| Negative | 247 | 54 |
| Positive | 57 | 244 |
Total correct predictions: 491 / 602.
Usage
Install the dependencies listed in the environment section.
Download tfidf_logistic_regression.joblib from this repository.
import joblib
model = joblib.load("tfidf_logistic_regression.joblib")
reviews = [
"The food was amazing!",
"The service was terrible."
]
predictions = model.predict(reviews)
print(predictions)
Security: Joblib files use pickle-based serialization and can execute arbitrary code when loaded. Only load this artifact from a trusted source after verifying its integrity.
Reproducibility
Environment used:
- Python 3.14.7
- scikit-learn 1.9.1
- NumPy 2.5.5
- SciPy 1.18.1
- Joblib 1.6.0
Model artifact SHA-256:
8395cce17d942589785e2afaec14d1fa267244ea5b9a248f13b2619ad8047d5
Reproducing the training experiment requires the source code and dataset preparation procedure in the GitHub repository.
Limitations
- Supports English-language reviews only.
- Binary classification; no neutral sentiment class.
- Trained on a small, relatively old dataset.
- Performance on real-world Brazilian customer reviews has not been established.
- Predictions may be incorrect on sarcasm, ambiguous statements or unfamiliar vocabulary.
- Evaluation results do not demonstrate production readiness.
Source Code
GitHub โ ml-review-classifier
Author
Lucas Miranda
Software Engineering | Machine Learning | Generative AI
- Downloads last month
- -