How to extract data from the "plotperform" function?
9 views (last 30 days)
Show older comments
MathWorks Support Team
on 7 Aug 2023
Edited: MathWorks Support Team
on 14 Feb 2025
I am using the "plotperform" function to see performance curves when training my neural network. How can I get the numeric values (i.e. the "x" and "y" coordinates that are plotted) of these curves as vectors (as opposed to just visuals)?
Accepted Answer
MathWorks Support Team
on 25 Jan 2025
Edited: MathWorks Support Team
on 14 Feb 2025
Here are two approaches to getting the "x" and "y" coordinates from the "plotperform" function:
1) Before calling "plotperform", you would typically call a function like "train" that returns a "struct" (known as the "training record"), which should contain the numeric values you are looking for, as these are used by "plotperform" for plotting. To understand the structure of the "training record," you can access the specific documentation by executing the following command in the MATLAB R2020a command window:
>> web(fullfile(docroot, 'deeplearning/ref/network.train.html'))
2) Alternatively, if you would like to access the data after running "plotperform", you could use the "XData" and "YData" attributes of the "line" object. You would first have to get handles to the "line" objects. The following code snippet is a small example of how to do this:
%initialize a network for which you can plot graphs
[x,t] = bodyfat_dataset; % Dataset shipped with MATLAB
net = feedforwardnet(10);
[net,tr] = train(net,x,t);
plotperform(tr)
% get numeric values
ax = gca; % gets handle to axes
h = findobj(ax,'Type','line'); % gets handles to all lines plotted in axes (with "plotperform" there would be 6)
x = h(6).XData; %6th line in "h" is the train curve
y = h(6).YData
Please follow the link below to search for the required information regarding the current release:
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!