neural network: probability of prediction

Illustration
yun_hun_32 - 2021-07-20T10:30:36+00:00
Question: neural network: probability of prediction

I have been using the neural network toolbox to predict the next value in a time series. This works, however I would like to know what is the probability of Matlab's neural network prediction.   E.g.: let's say we have time series [1 2 3 4 5]. The neural network would maybe predict the next value in the chain will be 5.9 (as an example).   Is there any (easy) way to derive the probability of this prediction? I would like to be able to tell something like this: it is predicted that the expected value of the next step will be 5.9 with a probability of 78%. It would be even better if I could get the entire probability distribution of the next value, or at least also the standard deviation. I hope anyone can help.   My point is that having a prediction without a probability does not help a lot, there might be a lot of uncertainty about this prediction. If one would forecast it is going to rain tomorrow this would give little information. If one would say it is going to rain with 95% probability than I know how to handle.

Expert Answer

Profile picture of Neeta Dsouza Neeta Dsouza answered . 2025-11-20

To determine the probability of a prediction made by MATLAB's neural network, you can use the `predict` function with the `ReturnCategorical` option set to `true`. This will return both the predicted class labels and the classification scores, which indicate the likelihood of each class.

Here’s an example:


% Assuming 'trainedModel' is your trained neural network
% 'X' is your input data
[YPred, YProb] = trainedModel.predictFcn(X);  % YProb contains the probabilities

In this example, `YPred` contains the predicted values, and `YProb` contains the probabilities associated with each prediction.

\


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!