How to calculate precision and recall in Keras

后端 未结 5 607
别跟我提以往
别跟我提以往 2020-12-13 03:47

I am building a multi-class classifier with Keras 2.02 (with Tensorflow backend),and I do not know how to calculate precision and recall in Keras. Please help me.

5条回答
  •  天命终不由人
    2020-12-13 04:14

    Use Scikit Learn framework for this.

    from sklearn.metrics import classification_report
    
    history = model.fit(x_train, y_train, batch_size=32, epochs=10, verbose=1, validation_data=(x_test, y_test), shuffle=True)
    pred = model.predict(x_test, batch_size=32, verbose=1)
    predicted = np.argmax(pred, axis=1)
    report = classification_report(np.argmax(y_test, axis=1), predicted)
    print(report)
    

    This blog is very useful.

提交回复
热议问题