Regression learner response plot?

So I am using the regression learner app, and it provides the plot that I want, however I would like to use that plot in the main matlab section, so I can change the titles, axis and colours of the graph.
I had a look for the data that it plots when exported, however could not find it.
Any advice?

7 comentarios

dpb
dpb el 7 de Ag. de 2018
As per usual, the App isn't finished, particularly on the export side--there appears no way (at least w/ R2016b here) to save the actual figure itself; bestest you can do is to export the model and recreate the figure from it and the starting data.
You may be just as well off to just use the model you found most satisfactory and revert to fitlm and specify that model and proceed from there.
Phil Whitfield
Phil Whitfield el 8 de Ag. de 2018
Do you know if it is possible to retrieve the data points themselves?
I managed to plot the same graph using the export model, then using that code to generate the same predictions, and plot them using
plot(trainedModel.LinearModel.Fitted)
Thanks for the help
dpb
dpb el 8 de Ag. de 2018
You must have had the data to have created the fit???
But, the Export option seems to have a couple of options, one of which appears to include the data...I've never actually used the App; wasn't even aware of its existence... :)
export-regression-model is all that I know...
yeah so I used the app to generate the fit using the data I had, then exported that model using the export function, then within the workspace of matlab I saved it as 'linearmodel1'. Then I used the code
linearmodel1(data)
to generate the same model within the workspace to allow for the plot function to work, which took me a while to find where the predictions had been stored.
It was simpler than I thought
Milly
Milly el 20 de Jun. de 2024
Any update on this yet? It has been 6 years!
I have been able to recreate the resonse plot with "True" and "Predicted" options by adding the following code to the default "Generate Function" code.
I am still searching for how to include the "Errors" option to the chart, any suggestions welcome.
figure
plot(responseData,"*");
hold on
plot(validationPredictions,"*");
% need something here to add the "Errors" option!
hold off
Milly
Milly el 20 de Jun. de 2024
To add the error bars use the following:
% calculate mid point between each pair
midpoint = (responseData + validationPredictions)/2;
% calculate the distance from the mid point to either result
errorBars = abs(responseData - validationPredictions)/2;
% use both in errorbar plot with the connecting lines and markers turned off
errorbar(midpoint,errorBars,"LineStyle","none", 'DisplayName',"Error")

Iniciar sesión para comentar.

Respuestas (1)

Milly
Milly el 20 de Jun. de 2024
Editada: Milly el 20 de Jun. de 2024
To manually replicate the Response Plot from the Regression Learner and plot when you run it, add the following code to the end of the function.
The variables [responseData, validationPredictions] are created as default in the "Generate Function" code.
You can then adjust titles, axis and colours of the graph as usual, within this code.
% Dummy data, variable names as in "Generate Function" code
responseData = randi([1,10],10,1); % True
validationPredictions = randi([1,10],10,1); % Predicted
% plot results
figure
hold on
plot(responseData,"*", "DisplayName","True"); % Plot "True"
plot(validationPredictions,"*", "DisplayName","Predicted"); % Plot "Predicted"
% add errors
midpoint = (responseData + validationPredictions)/2; % mid point between each pair
errorBars = abs(responseData - validationPredictions)/2; % distance from mid point
errorbar(midpoint,errorBars,"LineStyle","none", 'DisplayName',"Error") % Plot "Errors"
legend('Location','northeastoutside')
title("Response Plot")
xlabel("Record number"); ylabel("Response")
hold off

Productos

Versión

R2017b

Preguntada:

el 7 de Ag. de 2018

Editada:

el 20 de Jun. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by