title: Confusion Matrix for Leave-One-Out Cross Validation in sklearn
body: <p><a href="https://stackoverflow.com/a/53235657/2414957">I know how to draw confusion matrix when I use the train and test split using sklearn</a> but I do not know how to create the confusion matrix when I am using the leave-one-out cross validation <a href="https://machinelearningmastery.com/evaluate-performance-machine-learning-algorithms-python-using-resampling/" rel="nofollow noreferrer">as shown in this example</a>:</p>
  
  <pre><code># Evaluate using Leave One Out Cross Validation
  import pandas
  from sklearn import model_selection
  from sklearn.linear_model import LogisticRegression
  url = "https://raw.githubusercontent.com/jbrownlee/Datasets/master/pima-indians-diabetes.data.csv"
  names = ['preg', 'plas', 'pres', 'skin', 'test', 'mass', 'pedi', 'age', 'class']
  dataframe = pandas.read_csv(url, names=names)
  array = dataframe.values
  X = array[:,0:8]
  Y = array[:,8]
  num_folds = 10
  num_instances = len(X)
  loocv = model_selection.LeaveOneOut()
  model = LogisticRegression()
  results = model_selection.cross_val_score(model, X, Y, cv=loocv)
  print("Accuracy: %.3f%% (%.3f%%)" % (results.mean()*100.0, results.std()*100.0))
  </code></pre>
  
  <p>How should I create the confusion matrix for LOOCV in order to visualize the per-class accuracy?</p>