How to plot confusion matrix for 2 classes (genuine or fraud)

3 次查看(过去 30 天)
clc
clear
trainingSetup = load("C:\Users\User\Desktop\Master Application\02 Dissertion\Signature\Kaggle\Real_A1\trainingSetup_2021_04_01__20_23_12.mat");
imdsTrain = imageDatastore("C:\Users\User\Desktop\Master Application\02 Dissertion\Signature\Testing","IncludeSubfolders",true,"LabelSource","foldernames");
[imdsTrain, imdsValidation] = splitEachLabel(imdsTrain,0.7,"randomized");
% Resize the images to match the network input layer.
augimdsTrain = augmentedImageDatastore([224 224 3],imdsTrain);
augimdsValidation = augmentedImageDatastore([224 224 3],imdsValidation);
opts = trainingOptions("rmsprop",...
"ExecutionEnvironment","auto",...
"InitialLearnRate",0.001,...
"Shuffle","every-epoch",...
"Plots","training-progress",...
"ValidationData",augimdsValidation);
layers = [
imageInputLayer([224 224 3],"Name","imageinput")
convolution2dLayer([3 3],32,"Name","conv","Padding","same")
reluLayer("Name","relu")
maxPooling2dLayer([5 5],"Name","maxpool","Padding","same")
fullyConnectedLayer(2,"Name","fc")
softmaxLayer("Name","softmax")
classificationLayer("Name","classoutput")];
[net, traininfo] = trainNetwork(augimdsTrain,layers,opts);

回答(1 个)

Athul Prakash
Athul Prakash 2021-4-6
Hi Tam,
First, you may set aside some of your data as test data.
With this test dataset, obtain Y_Actual as the labels and X as the values in the test data.
After that,
YPred = predict(net, X);
cmat = confusionmat(YActual, YPred);
1) Check out the doc on confusionmat and the examples found there.
2) You may also refer to confusionchart(), which creates a plot of the confusion matrix as well.
Hope it helps!

类别

Help CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by