问题
My question: How do I obtain the training error in the svm module (SVC class)?
I am trying to do a plot of error of the train set and test set against the number of training data used ( or other features such as C / gamma ). However, according to the SVM documentation , there is no such exposed attribute or method to return such data. I did find that RandomForestClassifier does expose a oob_score_ though.
回答1:
Just compute the score on the training data:
>>> model.fit(X_train, y_train).score(X_train, y_train)
You can also use any other performance metrics from the sklearn.metrics
module. The doc is here:
http://scikit-learn.org/stable/modules/model_evaluation.html
Also: oob_score_
is an estimate of the test / validation score, not the training score.
来源:https://stackoverflow.com/questions/17953539/how-to-obtain-the-training-error-in-svm-of-scikit-learn