pythonmachine-learningscikit-learnsvm

Support Vector Machine. Precision and/or accuracy?


I am trying to figure whether the code I use calculates precision or accuracy or both. Since I only have a little background in statistics (in another language) I don't really understand the Wikipedia article covering that topic.

Concretely I use following Python code:

from sklearn import svm, cross_validation
clf = svm.SVC(kernel=kernel, C=C)
scores = cross_validation.cross_val_score(clf, FeatureMatrix, np.squeeze(LabelMatrix), cv=d_inds)

Documentation for the scikit-learn functions can be found here:


Solution

  • By default, cross_val_score uses the score method of the classifier (for the SVC, this is accuracy). If you want to specify another metric, pass it in the scoring parameter, as is cross_val_score(clf, X, y, scoring = 'precision'). For a full list of scoring options, take a look at http://scikit-learn.org/stable/modules/model_evaluation.html