title: How to compute log loss in machine learning
body: <p>The following code are used to produce the probability output of binary classification with Random Forest.</p>
  
  <pre><code>library(randomForest) 
  
  rf &lt;- randomForest(train, train_label,importance=TRUE,proximity=TRUE)
  prediction&lt;-predict(rf, test, type="prob")
  </code></pre>
  
  <p>Then the result about prediction is as follows:</p>
  
  <p><a href="https://i.stack.imgur.com/cSq49.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cSq49.png" alt="enter image description here"></a></p>
  
  <p>The true label about test data are known (named test_label). Now I want to compute <a href="http://www.r-bloggers.com/making-sense-of-logarithmic-loss/" rel="nofollow noreferrer">logarithmic loss</a> for probability output of binary classification. The function about LogLoss is as follows.</p>
  
  <pre><code>LogLoss=function(actual, predicted)
  {
    result=-1/length(actual)*(sum((actual*log(predicted)+(1-actual)*log(1-predicted))))
    return(result)
  }
  </code></pre>
  
  <p>How to compute logarithmic loss with probability output of binary classification. Thank you.</p>