trainlm predict value & switch
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
output of trained network is y from
load data
Tb = readtable('train1.csv','PreserveVariableNames',true)
x = Tb(:,(1:562))%data.simplefitInputs';
t = Tb(:,(563:563));%data.simplefitTargets';
[net,tr] = train(net,x,t);
y = net(x);
as target were classes 1,2,3,4,5,6
why output is 1.123 , 4.454, 5.6575 etc not same classes as input?
and how to convert output y to predicted value ?
YPredicted = classify(net.myNet,y)
returns error:
SWITCH expression must be a scalar or a character vector.
Error in network/subsref (line 173)
switch (subs)
my final output would be confusionmatrix
plotconfusion(YTest,YPredicted)
0 commentaires
Réponses (1)
Mahesh Taparia
le 18 Mar 2020
Modifié(e) : Mahesh Taparia
le 18 Mar 2020
Hi
In my understanding, you want classification output and you are getting regression output. Convert the variable 't' into a categorical array before training the model and check if it is working or not, i.e
t = categorical(Tb(:,(563:563)));
3 commentaires
Mahesh Taparia
le 19 Mar 2020
Hi
The below is the working code for classification of your application. Hope it will helps.
Train= load('TrainSetArray.mat')
Target = load('TargetSetArray.mat')
% avaliable under
%https://drive.google.com/open?id=1CzfnIY5DZqcu8Vt-zxM3I6sVLnzLhwK5
x = Train.TrainSetArray;
t = Target.TargetSet;
t1=ind2vec(t');
trainFcn = 'trainlm'; % Levenberg-Marquardt backpropagation.
% Create a Fitting Network
hiddenLayerSize = 1;
net = patternnet(hiddenLayerSize,trainFcn);
% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% Train the Network
[net,tr] = train(net,x',t1);
y = net(x');%%%%% include the test vectors here
perf = perform(net,t,y);
classes = vec2ind(y);
Voir également
Catégories
En savoir plus sur Define Shallow Neural Network Architectures dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!