필터 지우기
필터 지우기

Drawing a discrimination line

조회 수: 2 (최근 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