필터 지우기
필터 지우기

plot confusion for backpropagation output

조회 수: 1 (최근 30일)
Tomasz Kaczmarski
Tomasz Kaczmarski 2020년 3월 26일
댓글: Tomasz Kaczmarski 2020년 3월 30일
Hello im trying to plot confusion matrix for all where i can see accuracy of each class
as shown in
unfortunellty im getting constant error
SWITCH expression must be a scalar or a character vector.
code is below
%PREPROCESSING
%load data
Tb = readtable('train1.csv','PreserveVariableNames',true);
Tbv = readtable('test1.csv','PreserveVariableNames',true);
%merge both datasets they can be splitted to train target later via dynamic
%parameter
Tbt = union(Tb, Tbv)
%split into train target
TrainSet = Tbt(:,(1:562))%data.simplefitInputs';
TargetSet = Tbt(:,(563:563));%data.simplefitTargets';
TargetSet= table2array(TargetSet)
%make some noise
TrainSetArray = table2array(TrainSet)
noiseSignal = cos(5 * pi * 100 * TrainSetArray)+sqrt(5) * randn(size(TrainSetArray));
%TRAINING
x = TrainSetArray';
%x = noiseSignal';
t = TargetSet';
%t = categorical(Tb(:,(563:563)));FAILING DURING TRAINING
trainFcn = 'trainlm'; % Levenberg-Marquardt backpropagation.
% Create a Fitting Network
hiddenLayerSize = 10;
net = fitnet(hiddenLayerSize,trainFcn);
% Create a Fitting Network
hiddenLayerSize = 1;
net = fitnet(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,t);
%get output
y = net(x);
%get test set
testX = x(:,tr.testInd);
testT = t(:,tr.testInd);
testY = net(testX);
%PLOTTING CONFUSION MATRIXacorss classes as
% https://uk.mathworks.com/help/deeplearning/ref/plotconfusion.html
YPredicted = classify(net.myNet,testX)%Line Causing error SWITCH expression must be a scalar or a character vector.
plotconfusion(testy,YPredicted)

답변 (1개)

Srivardhan Gadila
Srivardhan Gadila 2020년 3월 28일
The error is caused due to the input argument "net.myNet" in the classify function above.
The following are the errors in the above code:
  1. There is no object property named "myNet" for the above shallow neural network net. For information on properties of neural networks, refer to Neural Network Object Properties & Neural Network Subobject Properties.
  2. The function classify cannot be used on the above net object since it is a Shallow neural network and not a SeriesNetwork object or a DAGNetwork object. Refer to classify.
  댓글 수: 4
Srivardhan Gadila
Srivardhan Gadila 2020년 3월 28일
The fitnet is used for regression. The confusion matrix is used for classification problems.
Refer to plotconfusion & confusionmat for more information
Tomasz Kaczmarski
Tomasz Kaczmarski 2020년 3월 30일
ok how to apply Levenberg-Marquardt backpropagation(trianlm) result to visualise problem as described above ?
you says its not possible ?
im not asking which alorithm to use but how to visualise output !!!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by