title: Why does binary accuracy give high accuracy while categorical accuracy give low accuracy, in a multi-class classification problem?
body: <p>I'm working on a multiclass classification problem using Keras and I'm using binary accuracy and categorical accuracy as metrics. When I evaluate my model I get a really high value for the binary accuracy and quite a low one in for the categorical accuracy. I tried to recreate the binary accuracy metric in my own code but I am not having much luck. My understanding is that this is the process I need to recreate:</p>
  
  <pre><code>def binary_accuracy(y_true, y_pred):
       return K.mean(K.equal(y_true, K.round(y_pred)), axis=-1)
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>from keras import backend as K
  preds = model.predict(X_test, batch_size = 128)
  
  print preds
  pos = 0.00
  neg = 0.00
  
  for i, val in enumerate(roundpreds):
  
      if val.tolist() == y_test[i]:
          pos += 1.0
  
      else: 
          neg += 1.0
  
  print pos/(pos + neg)
  </code></pre>
  
  <p>But this gives a much lower value than the one given by binary accuracy. Is binary accuracy even an appropriate metric to be using in a multi-class problem? If so does anyone know where I am going wrong?</p>