When i run this proccessing with 10 fold cross-validation,prediction results is precisely opposite of label datas and i get zero accuracy.I can not solve why is that?
kfold = model_selection.KFold(n_splits=5,random_state=+7,shuffle=False)
predictions = model_selection.cross_val_predict(SVC(),features_list,labels_list,cv=kfold)
accuracy=metrics.accuracy_score(labels_list,predictions)
print(confusion_matrix(labels_list,predictions))
print(classification_report(labels_list,predictions))
print("Accuracy Score:",accuracy)
Do not use cross_val_predict
to evaluate a model in scikit-learn (warning section there: https://scikit-learn.org/stable/modules/cross_validation.html#obtaining-predictions-by-cross-validation)
Instead, use cross_val_score
which will return 10 accuracies for the 10 models tested on the 10 different datasets built from cross-validation. Look at the mean score and std. dev. for the evaluation.