title: how does sklearn compute the Accuracy score step by step?
body: <p>I was reading about the metrics used in sklearn but I find pretty confused the following:</p>
  
  <p><a href="https://i.stack.imgur.com/JB7DX.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/JB7DX.gif" alt="enter image description here"></a></p>
  
  <p>In the documentation sklearn provides a example of its usage as follows:</p>
  
  <pre><code>import numpy as np
  from sklearn.metrics import accuracy_score
  y_pred = [0, 2, 1, 3]
  y_true = [0, 1, 2, 3]
  accuracy_score(y_true, y_pred)
  0.5
  </code></pre>
  
  <p>I understood that sklearns computes that metric as follows:</p>
  
  <p><a href="https://i.stack.imgur.com/12d6L.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/12d6L.gif" alt="enter image description here"></a></p>
  
  <p>I am not sure about the process, I would like to appreciate if some one could explain more this result step by step since I was studying it but I found hard to understand,  In order to understand more I tried the following case:</p>
  
  <pre><code>import numpy as np
  from sklearn.metrics import accuracy_score
  y_pred = [0, 2, 1, 3,0]
  y_true = [0, 1, 2, 3,0]
  print(accuracy_score(y_true, y_pred))
  0.6
  </code></pre>
  
  <p>And I supposed that the correct computation would be the following:</p>
  
  <p><a href="https://i.stack.imgur.com/BO3Iq.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/BO3Iq.gif" alt="enter image description here"></a></p>
  
  <p>but I am not sure about it, I would like to see if someone could support me with the computation rather than copy and paste the sklearn's documentation.</p>
  
  <p>I have the doubt if the <em>i</em> in the sumatory  is the same as the <em>i</em> in the formula inside the parenthesis, it is unclear to me, I don't know if the number of elements in the sumatory is related just to the number of elements in the sample of if it depends on also by the number of classes.</p>