Tensorflow Precision / Recall / F1 score and Confusion matrix

前端 未结 5 2056
别跟我提以往
别跟我提以往 2020-12-02 06:37

I would like to know if there is a way to implement the different score function from the scikit learn package like this one :

from sklearn.metrics import co         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 07:09

    Use the metrics APIs provided in tf.contrib.metrics, for example:

    labels = ...
    predictions = ...
    
    accuracy, update_op_acc = tf.contrib.metrics.streaming_accuracy(labels, predictions)
    error, update_op_error = tf.contrib.metrics.streaming_mean_absolute_error(labels, predictions)
    
    sess.run(tf.local_variables_initializer())
    for batch in range(num_batches):
      sess.run([update_op_acc, update_op_error])
    accuracy, mean_absolute_error = sess.run([accuracy, mean_absolute_error])
    

提交回复
热议问题