Search code examples
tensorflowkeraspython-3.6metrics

how to use y_true/y_test and y_pred?


in this line I used y_true and y_pred:

model.compile(optimizer="rmsprop", loss="categorical_crossentropy", metrics=[precision(y_true,y_pred),recall(y_true,y_pred),fmeasure(y_true,y_pred)])

but a this error happened:

NameError: name 'y_true' is not defined

and I imported metrics

from keras import metrics

Solution

  • When specifying metrics, you pass function objects to the metrics parameter, not function calls. There is no need at all to mention y_true and y_pred:

    model.compile(optimizer="rmsprop", loss="categorical_crossentropy", metrics=[precision, recall, fmeasure])