MatrixVision

MatrixVision

Confusion Matrix

A confusion matrix is a performance measurement tool used in machine learning and statistics to evaluate the accuracy of a classification model. It is a table that allows visualization of the performance of an algorithm by comparing the predicted and actual classes of a dataset.

A confusion matrix typically has four cells, representing the following:

A confusion matrix provides insight into the performance of a classification model, including metrics such as accuracy, precision, recall, and F1-score. It is particularly useful for evaluating the performance of binary classification models but can be extended to multi-class classification problems as well.

Scatter Plot

Confusion Matrix

MATLAB

clc;
clear all;
close all;
warning off;
M = readtable('M.txt');
J = readtable('J.txt');
V = readtable('V.txt');
plot(M.Var2, M.Var3);
axis equal;
figure;
plot(J.Var2, J.Var3);
axis equal;
figure;
plot(V.Var2, V.Var3);
axis equal;
durM = M.Var1(end);
durJ = J.Var1(end);
durV = V.Var1(end);
aratioM = range(M.Var3) / range(M.Var2);
aratioJ = range(J.Var3) / range(J.Var2);
aratioV = range(V.Var3) / range(V.Var2);
figure;
features = readtable('Features.txt'); % Read features from file
gscatter(features.Var1, features.Var2, features.Var3);
knnmodel = fitcknn(features, 'Var3');
testdata = readtable('testdata.txt');
predictions = predict(knnmodel, testdata(:, 1:2));
Observation = [testdata(:, end) predictions];
knnmodel = fitcknn(features, 'Var3', 'NumNeighbors', 5);
predictions = predict(knnmodel, testdata(:, 1:2));
Observation = [testdata(:, end) predictions];
iscorrect = string(predictions) == string(testdata.Var3);
accuracy = sum(iscorrect) / numel(iscorrect);
misclassrate = sum(~iscorrect) / numel(iscorrect);
disp(['Accuracy: ', num2str(accuracy)]);
disp(['Misclassification Rate: ', num2str(misclassrate)]);
figure;
confusionchart(testdata.Var3, predictions);

TOOL

CONTRIBUTOR