Issue
I have created a support vector model which makes a prediction via model.predict()
. Is there a way to see the probability or confidence of this prediction?
def svc_training(X, y):
# Create a support vector classifier
clf = SVC(C=1)
# Fit the classifier using the training data
clf.fit(X, y)
return clf
Solution
You need to enable probability parameter:
probability: boolean, optional (default=False) :
Whether to enable probability estimates. This must be enabled prior to calling fit, and will slow down that method.
So, clf = SVC(C=1, probability=True)
and you can reach confidence scores with
predictions = model.predict(predict_df)
clf.predict_proba(predict_df)
where predict_df
is simply the dataframe you want to predict.
Answered By - Nuri Taş
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.