What is the difference between “predict” and “pred

2020-07-02 10:14发布

What is the difference between predict and predict_class functions in keras?

Why does Model object don't have predict_class function?

标签: keras
2条回答
再贱就再见
2楼-- · 2020-07-02 10:27

predict will return the scores of the regression and predict_class will return the class of your prediction. Although it seems similar there are some differences:

Imagine you are trying to predict if the picture is a dog or a cat (you have a classifier):

  • predict will return you: 0.6 cat and 0.2 dog (for example).
  • predict_class will return you cat

Now image you are trying to predict house prices (you have a regressor):

  • predict will return the predicted price
  • predict_class will not make sense here since you do not have a classifier

TL:DR: use predict_class for classifiers (outputs are labels) and use predict for regressions (outputs are non discrete)

Hope it helps!

查看更多
祖国的老花朵
3楼-- · 2020-07-02 10:38

predict_classes method is only available for the Sequential class but not for the Model class You can check this answer

查看更多
登录 后发表回答