title: Computing the log loss with Numpy of a 1d-array
body: <p>I have a CSV-file with my own estimated probabilities for the outcome of a soccer match. There are three possible outcomes: a win, a draw and a loss. In order to determine how accurate my estimates are, I want to see how they score on the log loss-scoring rule. In what follows I assume that: </p>
  
  <ul>
  <li>In each instance / football match) there are three possible outcomes (win/draw/loss)</li>
  <li>The model predictions for the outcomes are respective probabilities <em>P,1, P,2</em> and <em>P,3</em></li>
  <li>The respective actual observed outcomes are <em>E,1, E,2</em> and <em>E,3</em>. So for football matches the <em>E,i's</em> are either 1 or 0 and in such cases the index of the actual observed outcome will be denoted <em>w</em>, so <em>E,i</em> is 1 if <em>i</em> is <em>w</em> and 0 otherwise. </li>
  </ul>
  
  <p>My working script looks a follows </p>
  
  <pre><code>    import numpy as np
  
      def log_loss_score(predicted, actual, eps=1e-14):
  
          """
          :param predicted:   The predicted probabilities as floats between 0-1
          :param actual:      The binary labels. Either 0 or 1.
          :param eps:         Log(0) is equal to infinity, so we need to offset our predicted values slightly by eps from 0 or 1
          :return:            The logarithmic loss between between the predicted probability assigned to the possible outcomes for item i, and the actual outcome.
          """
  
          predicted = np.clip(predicted, eps, 1-eps)
          loss = -1 * np.mean(actual * np.log(predicted) + (1 - actual) * np.log(1-predicted))
  
          return loss
  
  
       predicted = [0.35, 0.3, 0.35]
       actual = [0, 1, 0] # the match ended in a draw
       for x in range(0, len(predicted)):
           log_loss = log_loss_score(predicted[x], actual[x])
           print(log_loss)
  </code></pre>
  
  <p>Running this script gives me the following output:</p>
  
  <p><em>0.4307829160924542
  1.2039728043259361
  0.4307829160924542</em></p>
  
  <p>I understand that is the log-loss of each match outcome prediction for a single match. But how can I transform this into a match-"broad" log-loss score?</p>
  
  <p><strong>Question</strong>: How can I calculate the log-loss score of the whole match if I have the log-loss score of each potential outcome?</p>