Drawing a discrimination line

5 views (last 30 days)
Raviteja
Raviteja on 10 Feb 2012
Edited: Yiming on 8 Oct 2013
Hello,Please help me..
I want to understand how "classify" funtion works in matlab. So I have written a code below.
load fisheriris
% Taken only two classes...so I removed 'virginica' class
d=strcmp(species,'virginica');
i=find(d==1);
meas(i,:)=[];
species(i,:)=[];
% Create Data and labels (Considered 2 dimension data)
data = [ meas(1:end,3) meas(1:end,4)];
group = species;
% Divided data as training and testing
train_data=data(16:83,:);
train_label=group(16:83,:);
test_data=[data(1:15,:);data(84:end,:)];
clas=classify(test_data,train_data,train_label)
plot(data(:,1),data(:,2),'.')
hold on
plot(test_data(:,1),test_data(:,2),'.r');
the funtion classify by default perform "Linear Discriminant". Here I want to draw a discriminant line in the plot.
Can you please any one help me in this?
  1 Comment
Raviteja
Raviteja on 10 Feb 2012
Ok,I written this, and it is working....
K = str(1,2).const;
L = str(1,2).linear;
f = @(x,y) K+L(1)*x + L(2)*y;
ezplot(f,[1 6 0 2]);
hold off
title('Classification of Fisher iris data')
Comment on this...

Sign in to comment.

Answers (0)

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!