title: How can I implement a custom metrics "Negative Predictive Value" in python Keras?
body: <p>I have a code for calculating the Negative Predictive Value for the comparison of two arrays (y_pred and y_actual):</p>
  
  <pre><code>def npv(y_pred, y_actual):
      tn = 0
      fn = 0
      negative_value = 1
  
      for i in range(0,len(y_actual)):
          if(y_pred[i] == negative_value):
              if(y_pred[i] == y_actual[i]):
                  tn += 1
              else:
                  fn += 1
  
      result = tn / (tn + fn)
      return result
  </code></pre>
  
  <p>But I would like to implement it with tensors to use it as a custom metric in a deep learning recurrent neural network with Keras in python.</p>
  
  <p>How can I do it?</p>