Clear Filters
Clear Filters

How to extract data from nnstart fitting algorithm

7 views (last 30 days)
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;

Answers (1)

S0852306
S0852306 on 3 Aug 2023
Edited: S0852306 on 3 Aug 2023
" 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.
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');

Categories

Find more on Descriptive Statistics in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!