I trained a Setfit model with the default logistic regression head with an unbalanced dataset of 5000 on a binary classification task. Because of the unbalanced dataset, I was hoping to do a study of the area-under-curve of the precision-recall plot which would require class confidence scores rather than “argmax’d” class labels. However when I used model.predict_proba(ds["text"])
, the results weirdly only ever came in one of two class confidence pairs- either 0.9989 & 0.0011 or 0.023045 & 0.97695.
(The actual confidence scores are slightly around this, e.g. 0.9988959589582787 or 0.9988959627978705 but I’m assuming that’s noise).
I am doing the evaluation in a different script after downloading the trained model:
model = SetFitModel.from_pretrained("model_outputs/test_extra_setfit_save")
with open("model_outputs/test_extra_setfit_save/model_head.pkl", 'rb') as mhf:
model.model_head = pickle.load(mhf)
ds = Dataset.load_from_disk("eval_dataset")
ds = ds.rename_columns({
"is_hate": "label"
})
results = model.predict_proba(ds["text"])
I’m loading the model head manually because of this bug, by default it was giving a “logistic regression not yet fitted” error.