How do you compute accuracy in a regression model, after rounding predictions to classes, in keras?

后端 未结 2 780
再見小時候
再見小時候 2021-01-02 18:59

How would you create and display an accuracy metric in keras for a regression problem, for example after you round the predictions to the nearest integer class?

Whi

相关标签:
2条回答
  • 2021-01-02 19:15

    The answer by Thomas pretty much sums up the question. Just a minor addition as I was stuck in this one. Here "K" is

    import keras.backend as K
    
    def soft_acc(y_true, y_pred):
    return K.mean(K.equal(K.round(y_true), K.round(y_pred)))
    
    model.compile(..., metrics=[soft_acc])
    
    0 讨论(0)
  • 2021-01-02 19:33

    I use rounded accuracy like this:

    def soft_acc(y_true, y_pred):
        return K.mean(K.equal(K.round(y_true), K.round(y_pred)))
    
    model.compile(..., metrics=[soft_acc])
    
    0 讨论(0)
提交回复
热议问题