title: Scikit-learn: How to obtain True Positive, True Negative, False Positive and False Negative
body: <p><strong>My problem:</strong></p>
  
  <p>I have a dataset which is a large JSON file. I read it and store it in the <code>trainList</code> variable.</p>
  
  <p>Next, I pre-process it - in order to be able to work with it.</p>
  
  <p>Once I have done that I start the classification:</p>
  
  <ol>
  <li>I use the <code>kfold</code> cross validation method in order to obtain the mean
  accuracy and train a classifier.</li>
  <li>I make the predictions and obtain the accuracy &amp; confusion matrix of that fold.</li>
  <li>After this, I would like to obtain the <code>True Positive(TP)</code>, <code>True Negative(TN)</code>, <code>False Positive(FP)</code> and <code>False Negative(FN)</code> values. I'll  use these parameters to obtain the <strong>Sensitivity</strong> and <strong>Specificity</strong>. </li>
  </ol>
  
  <p>Finally, I would use this to put in HTML in order to show a chart with the TPs of each label.</p>
  
  <p><strong>Code:</strong></p>
  
  <p>The variables I have for the moment:</p>
  
  <pre><code>trainList #It is a list with all the data of my dataset in JSON form
  labelList #It is a list with all the labels of my data 
  </code></pre>
  
  <p>Most part of the method:</p>
  
  <pre><code>#I transform the data from JSON form to a numerical one
  X=vec.fit_transform(trainList)
  
  #I scale the matrix (don't know why but without it, it makes an error)
  X=preprocessing.scale(X.toarray())
  
  #I generate a KFold in order to make cross validation
  kf = KFold(len(X), n_folds=10, indices=True, shuffle=True, random_state=1)
  
  #I start the cross validation
  for train_indices, test_indices in kf:
      X_train=[X[ii] for ii in train_indices]
      X_test=[X[ii] for ii in test_indices]
      y_train=[listaLabels[ii] for ii in train_indices]
      y_test=[listaLabels[ii] for ii in test_indices]
  
      #I train the classifier
      trained=qda.fit(X_train,y_train)
  
      #I make the predictions
      predicted=qda.predict(X_test)
  
      #I obtain the accuracy of this fold
      ac=accuracy_score(predicted,y_test)
  
      #I obtain the confusion matrix
      cm=confusion_matrix(y_test, predicted)
  
      #I should calculate the TP,TN, FP and FN 
      #I don't know how to continue
  </code></pre>