The problem I'm working on is a multiclass-classification. Have been reading through lot of articles and documentation, but not able to figure out which of Accuracy_Score or Cross_Val_Score should be used to find the prediction accuracy of a model.
I tried using both but the scores are different. Cross_Val_Score()
gave me 71% right prediction, but 69.93% using Accuracy_Score()
.
What could be the possible reason for mismatch?
Best Answer
They're going to be different because in
cross_val_score
, you obtain an accuracy for each of your folds and average them. For each CV fold, your training and tests set are different; so, you obtain different accuracy values for each of them, and it enables you to calculate standard deviation of your accuracies, which is enclosed in parentheses in your image.accuracy_score
ofsklearn.metrics
library calculates the accuracy based on the inputsy_pred
andy_true
. For example, if you input your entire training set, you'll get accuracy of your entire training set, which is of course slightly different than your CV score.