How to get error bar in target vs predicted plots of regression?

2 ビュー (過去 30 日間)
Onkar Khadke
Onkar Khadke 2021 年 5 月 22 日
回答済み: Sai Pavan 2024 年 4 月 12 日
How can we get error bar in target vs predicted plots of regression ? How to get the error bar using trainbr training algorithm

回答 (1 件)

Sai Pavan
Sai Pavan 2024 年 4 月 12 日
Hello Onkar,
I understand that you want to get the error bar in target vs predicted plots of regression trained using using trainbr training algorithm.
Although "trainbr" function does not directly provide error bars, we can estimate them by calculating the residuals between the predicted and actual values, then determining the standard error of these residuals. This standard error can serve as an approximation for the error bars in the plot.
Please refer to the below workflow to get the errorbar plot for the regression model:
  1. Train the network using the Bayesian Regularization backpropagation algorithm.
  2. Generate predictions on the validation or test dataset.
  3. Calculate residuals as the difference between actual and predicted values.
  4. Compute the standard error of the residuals.
  5. Plot the target vs. predicted values, incorporating the standard error as error bars using "errorbar" function.
Please refer to the below code snippet that illustrates the workflow mentioned above:
% Train the network
net = feedforwardnet(hiddenLayerSize, 'trainbr');
[net, tr] = train(net, X, T);
% Generate predictions
Y = net(Xval); % Xval: validation/test inputs
% Calculate residuals and standard error
residuals = Tval - Y; % Tval: actual target values for validation/test set
stderr = std(residuals) / sqrt(length(residuals));
% Plot with error bars
figure;
errorbar(Tval, Y, stderr, 'o');
xlabel('Actual Values');
ylabel('Predicted Values');
title('Target vs. Predicted with Error Bars');
Please refer to the below documentation to learn more about the "errorbar" function: https://www.mathworks.com/help/matlab/ref/errorbar.html
Hope it helps!

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by