title: Calculating accuracy for multi-class classification
body: <p>Consider a three class classification problem with the following confusion matrix.</p>
  
  <pre><code>cm_matrix = 
                  predict_class1    predict_class2    predict_class3
                   ______________    ______________    ______________
  
  Actual_class1         2000                 0                 0     
  Actual_class2           34              1966                 0     
  Actual_class3            0                 0              2000   
  
  
  
  Multi-Class Confusion Matrix Output
                       TruePositive    FalsePositive    FalseNegative    TrueNegative
                       ____________    _____________    _____________    ____________
  
      Actual_class1        2000             34                0              3966    
      Actual_class2        1966              0               34              4000    
      Actual_class3        2000              0                0              4000    
  </code></pre>
  
  <p>The formula that I have used are:</p>
  
  <pre><code>Accuracy Of Each class=(TP ./total instances of that class)
  </code></pre>
  
  <p>( formula based on an answer here: <a href="https://stackoverflow.com/questions/51255247/individual-class-accuracy-calculation-confusion">Individual class accuracy calculation confusion</a>)</p>
  
  <pre><code>Sensitivity=TP./TP+FN ;
  </code></pre>
  
  <p>The implementation of it in Matlab is:</p>
  
  <pre><code>acc_1  = 100*(cm_matrix(1,1))/sum(cm_matrix(1,:)) = 100*(2000)/(2000+0+0) = 100
  acc_2  = 100*(cm_matrix(2,2))/sum(cm_matrix(2,:)) =  100*(1966)/(34+1966+0) = 98.3
  acc_3  = 100*(cm_matrix(3,3))/sum(cm_matrix(3,:)) = 100*(2000)/(0+0+2000) = 100
  
  sensitivity_1 = 2000/(2000+0)=1 = acc_1
  sensitivity_2 =  1966/(1966+34) = 98.3 = acc_2
  sensitivity_3 = 2000/2000 = 1 = acc_3
  </code></pre>
  
  <p><strong>Question1)</strong> Is my formula for Accuracy of each class correct? For calculating accuracy of each individual class, say for positive class I should take the TP in the numerator. Similarly, for accuracy of only the negative class, I should consider TN in the numerator in the formula for accuracy. Is the same formula applicable to binary classification? Is my implementation of it correct?</p>
  
  <p><strong>Question2)</strong> Is my formula for sensitivity correct? Then how come I am getting same answer as individual class accuracies?</p>