title: Accuracy, precision, and recall for multi-class model
body: <p>How do I calculate <em>accuracy</em>, <em>precision</em> and <em>recall</em> for each class from a confusion matrix?
  I am using the embedded dataset iris; the confusion matrix is as below:</p>
  <pre><code>prediction   setosa versicolor virginica
  setosa         29          0         0
  versicolor      0         20         2
  virginica       0          3        21
  </code></pre>
  <p>I am using 75 entries as the training set and other for testing:</p>
  <pre><code>iris.train &lt;- c(sample(1:150, 75)) # have selected 75 randomly
  </code></pre>