-1

I am using 10-fold cross-validation and evaluating the model on the basis of accuracy and precision.

The confusion matrix is generated 10 times for each model. How can I aggregate the confusion matrix and calculate the accuracy?

desertnaut
  • 57,590
  • 26
  • 140
  • 166

1 Answers1

0

You can use cross_val_predict function as follows and use it result as confusion_matrix() argument.

from sklearn.metrics import confusion_matrix
from sklearn.model_selection import cross_val_predict

y_pred = cross_val_predict(clf, x, y, cv=5)
cm = confusion_matrix(y, y_pred)