I found model.predict
and model.predict_proba
both give an identical 2D matrix representing probabilities at each categories for each row.
What is the difference of the two functions?
predict() returns the final output of the model, i.e. answer. While model. evaluate() returns the loss. The loss is used to train the model (via backpropagation) and it is not the answer.
Keras model predicts is the method of function provided in Keras that helps in the predictions of output depending on the specified samples of input to the model.
model. predict_proba() : For classification problems, some estimators also provide this method, which returns the probability that a new observation has each categorical label. In this case, the label with the highest probability is returned by model.
The Random Forest simply votes among the results. The predict_proba() returns the number of votes for each class, divided by the number of trees in the forest. Your precision is exactly 1/n_estimators.
predict
predict(self, x, batch_size=32, verbose=0)
Generates output predictions for the input samples, processing the samples in a batched way.
Arguments
x: the input data, as a Numpy array. batch_size: integer. verbose: verbosity mode, 0 or 1.
Returns
A Numpy array of predictions.
predict_proba
predict_proba(self, x, batch_size=32, verbose=1)
Generates class probability predictions for the input samples batch by batch.
Arguments
x: input data, as a Numpy array or list of Numpy arrays (if the model has multiple inputs). batch_size: integer. verbose: verbosity mode, 0 or 1.
Returns
A Numpy array of probability predictions.
Edit: In the recent version of keras, predict and predict_proba is same i.e. both give probabilities. To get the class labels use predict_classes. The documentation is not updated. (adapted from Avijit Dasgupta's comment)
As mentioned in previous comments (and here), there currently isn't any difference.
However one seems to exist only for backward compatibility (not sure which one, and I'd be interested to know).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With