2
$\begingroup$

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

$\endgroup$
2
$\begingroup$

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)
$\endgroup$
  • $\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 Sep 21 '18 at 22:50
  • $\begingroup$ You can use the scoring parameter in GridSearchCV $\endgroup$ – Fred Sep 22 '18 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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