Setting a threshold in classifier output in Python
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Breezy Bay
--
Chapters
00:00 Setting A Threshold In Classifier Output In Python
00:53 Accepted Answer Score 2
01:23 Thank you
--
Full question
https://stackoverflow.com/questions/2977...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #classification
#avk47
    Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Breezy Bay
--
Chapters
00:00 Setting A Threshold In Classifier Output In Python
00:53 Accepted Answer Score 2
01:23 Thank you
--
Full question
https://stackoverflow.com/questions/2977...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #classification
#avk47
ACCEPTED ANSWER
Score 2
As far as I know, SVC itself does not allow thresholding of probabilities in the manner you want. You can do a second pass of indexing and get the accepted labels after you build labels_predicted and probabilities.
thresh = 0.9
accepted_probabilities_idx = probabilities.max(axis=1) > thresh
accepted_labels_predicted = labels_predicted[accepted_probabilities_idx]
accepted_new_data = pandas.DataFrame(new_data, index=accepted_probabilities_idx)
I am not sure what you want to do with data where ML-probability with low. This solution discards it completely.