Solved – difference between accuracy_score() and cross_val_score()

accuracyclassificationmachine learningmulti-classscikit learn

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().

enter image description here

enter image description here

What could be the possible reason for mismatch?

Edit: Added Confusion Matrix and Classification report:
enter image description here

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 of sklearn.metrics library calculates the accuracy based on the inputs y_pred and y_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.