I am training a model for which I need to report class probabilities instead of a single classification. I have three classes and each training instance has either of the three classes assigned to it.
I am trying to use Keras to create an MLP. But I can't figure how to extract the final class probabilities for each class. I am using this as my base example: http://machinelearningmastery.com/regression-tutorial-keras-deep-learning-library-python/
Thanks !
predict_class will return the index of the class having maximum value. For example, if cat is 0.6 and dog is 0.4, it will return 0 if the class cat is at index 0)
In order to perform multi-class classification (nb_classes > 1) you have to prepare your model in a specific manner.
You could use the predict method of your trained model
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 (or list of Numpy arrays if the model has multiple outputs). batch_size: integer. verbose: verbosity mode, 0 or 1.
Returns a Numpy array of predictions.
model.predict(input_to_your_network)
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