Azzera filtri
Azzera filtri

Drawing a discrimination line

2 visualizzazioni (ultimi 30 giorni)
Raviteja
Raviteja il 10 Feb 2012
Modificato: Yiming il 8 Ott 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 Commento
Raviteja
Raviteja il 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...

Accedi per commentare.

Risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by