How to plot train test error for classification models like Support Vector Classification(SVC). I am using SVC from sklearn module, not able to get train and test errors to plot


1 Answer 1


Well you haven't defined what "error" means, so I'll just assume that you want the log loss.

First, you need to create your SVC object telling it you'll want probability estimations:

model = sklearn.svm.SVC(probability=True)

Then you can compute the log loss given said estimation:

probs = model.predict_proba(x)
loss = sklearn.metrics.log_loss(y_true=y, y_pred=probs)
  • $\begingroup$ Thanks! BUt i want to plot mean_train_score and mean_test_score values in GridSearchCV for C and gamma values of SVM. How can i do that? $\endgroup$
    – Harika M
    Commented Sep 21, 2018 at 22:50
  • $\begingroup$ You can use the scoring parameter in GridSearchCV $\endgroup$
    – Fred
    Commented Sep 22, 2018 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.