yassiracharki/Amazon_Reviews_Binary_for_Sentiment_Analysis
Viewer • Updated • 4M • 103
How to use faysal725/product-review-sentiment-classifier with setfit:
from setfit import SetFitModel
model = SetFitModel.from_pretrained("faysal725/product-review-sentiment-classifier")Binary sentiment classifier for product reviews — positive or negative with calibrated confidence scores.
| Metric | Score |
|---|---|
| Accuracy | 91.2% |
| F1 | 0.913 |
| Brier | 0.079 |
from setfit import SetFitModel
import pickle, numpy as np
model = SetFitModel.from_pretrained("faysal725/product-review-sentiment-classifier")
# For calibrated confidence, download platt_calibrator.pkl from this repo
with open("platt_calibrator.pkl", "rb") as f:
platt = pickle.load(f)
text = "This product is amazing, best purchase ever!"
raw_probs = np.array(model.predict_proba([text]))
calibrated = platt.predict_proba(raw_probs[:, 1].reshape(-1, 1))[0]
label = "positive" if calibrated[1] >= 0.5 else "negative"
confidence = max(calibrated)
print(f"{label} ({confidence:.1%})")
For the complete package with FastAPI server, batch endpoint, Docker deployment, and full documentation, visit Gumroad.
MIT