Drawing a discrimination line

11 次查看(过去 30 天)
Raviteja
Raviteja 2012-2-10
编辑: Yiming 2013-10-8
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 个评论
Raviteja
Raviteja 2012-2-10
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...

请先登录,再进行评论。

回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by