Drawing a discrimination line

3 ビュー (過去 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