Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding AUC score for SVM model

I understand that Support Vector Machine algorithm does not compute probabilities, which is needed to find the AUC value, is there any other way to just find the AUC score?

from sklearn.svm import SVC
model_ksvm = SVC(kernel = 'rbf', random_state = 0)
model_ksvm.fit(X_train, y_train)

model_ksvm.predict_proba(X_test)

I can't get the the probability output from the SVM algorithm, without the probability output I can't get the AUC score, which I can get with other algorithm.

like image 663
Lekster Avatar asked Nov 01 '25 18:11

Lekster


1 Answers

You don't really need probabilities for the ROC, just any sort of confidence score. You need to rank-order the samples according to how likely they are to be in the positive class. Support Vector Machines can use the (signed) distance from the separating plane for that purpose, and indeed sklearn does that automatically under the hood when scoring with AUC: it uses the decision_function method, which is the signed distance.

You can also set the probability option in the SVC (docs), which fits a Platt calibration model on top of the SVM to produce probability outputs:

model_ksvm = SVC(kernel='rbf', probability=True, random_state=0)

But this will lead to the same AUC, because the Platt calibration just maps the signed distances to probabilities monotonically.

like image 159
Ben Reiniger Avatar answered Nov 04 '25 09:11

Ben Reiniger