![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1449412/image.jpeg)
How to extract data from nnstart fitting algorithm
6 次查看(过去 30 天)
显示 更早的评论
i am very new to this nnstart. i used this levenberg-marquardt algorithm uisng X (3*2,00,000) and Y (2*2,00,000). finally its shows some plots. but i want to extract the Y data for both test and validated datas and for new set of X values. How to do that...Thankz in advance
clear all
close all
clc
Data =csvread('pfm_data1.csv');
X= Data(:,1:3);
X=X';
Y= Data(:,4:5);
Y=Y';
nnstart;
0 个评论
回答(1 个)
S0852306
2023-8-3
编辑:S0852306
2023-8-3
" but i want to extract the Y data for both test and validated datas and for new set of X values."
I'm not entirely sure about the meaning of this sentence, but I assume you want to validate the reliability of the network with new data. If that's the case, you just need to export the trained model to validate it with new data.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1449412/image.jpeg)
just click export model, and use the following command to predict.
("results" is the name of trained model, customizable)
results.Network([X(:,1)]) % predict, replace new X here.
pred=results.Network(X);
MSE=mean((pred-Y).^2,'all');
However, nnstart only allows the use of a 2-layer network, and the performance of the fitting is not very satisfactory.
(The MSE obtained from using nnstart is approximately in the range of 3e-3 to 1e-3)
If you want better performance, you may need to use fitnet (Mathworks)
or use this pack, which is specifically designed for regression and surface fitting with neural networks.
The results I got is much better (MSE=7.4736e-06) compare to simple "nnstart"
clear; clc; close all;
% to run this code, download this pack
% at file exchange: https://tinyurl.com/wre9r5uk
Data =csvread('pfm_data1.csv');
X= Data(:,1:3);
X=X';
Y= Data(:,4:5);
Y=Y';
%%
NN.InputAutoScaling='on';
NN.LabelAutoScaling='on';
InSize=3; OutSize=2;
LayerStruct=[InSize,10,10,10,OutSize];
NN=Initialization(LayerStruct,NN);
%%
option.Solver='ADAM';
option.BatchSize=1e+4;
option.MaxIteration=100;
NN=OptimizationSolver(X,Y,NN,option);
%%
option.MaxIteration=200;
option.Solver='BFGS';
NN=OptimizationSolver(X,Y,NN,option);
R=FittingReport(X,Y,NN);
% Using NN.Evaluate([1;2;3]) to evaluate trained model
NN.Evaluate(X(:,1))
MSE=mean(R.ErrorVector.^2,'all');
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Descriptive Statistics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!