Visualize Decision Surfaces on K Nearest Neighbor Classification | Machine Learning | MATLAB
gscatter Documentation:
https://www.mathworks.com/help/stats/...
%Code:
%Code:
clc
close all
modelformed=fitcknn(data,'Class~PL+PW');
modelformed.NumNeighbors=10;
e=min(data.PL):0.01:max(data.PL);
f=min(data.PW):0.01:max(data.PW);
[x1 x2]=meshgrid(e,f);
x=[x1(:) x2(:)];
ms=predict(modelformed,x);
gscatter(x1(:),x2(:),ms,'cym');
hold on;
gscatter(data.PL,data.PW,data.Class,'rgb','.',30);
title('knn
Classification Visualization');
Dataset:
https://media.geeksforgeeks.org/wp-co...
Prerequisite:
k-nearest neighbor classifier in MATLAB in lesser than 2 minutes | MATLAB
https://www.youtube.com/watch?v=9m8hy...
Free program: https://www.matlabcoding.com
Free Support: castorclasses2014@gmail.com
Live Support: t.me/matlabirawen
Like us: https://www.facebook.com/matlabirawen/
Join us: https://www.facebook.com/groups/MATLA...
MATLAB Book for the beginner: https://amzn.to/3fTfmTa
No comments