Views
No views yet
| Metric | Score |
|---|---|
| Accuracy | 91.2% |
| F1 | 0.913 |
| Brier | 0.079 |
1from setfit import SetFitModel
2import pickle, numpy as np
3
4model = SetFitModel.from_pretrained("faysal725/product-review-sentiment-classifier")
5
6# For calibrated confidence, download platt_calibrator.pkl from this repo
7with open("platt_calibrator.pkl", "rb") as f:
8 platt = pickle.load(f)
9
10text = "This product is amazing, best purchase ever!"
11raw_probs = np.array(model.predict_proba([text]))
12calibrated = platt.predict_proba(raw_probs[:, 1].reshape(-1, 1))[0]
13label = "positive" if calibrated[1] >= 0.5 else "negative"
14confidence = max(calibrated)
15
16print(f"{label} ({confidence:.1%})")