Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: classify in 3D
Date: Tue, 3 Nov 2009 00:37:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 52
Message-ID: <hcntve$ie3$1@fred.mathworks.com>
References: <hchee8$45d$1@fred.mathworks.com> <hcnodi$aob$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257208622 18883 172.30.248.38 (3 Nov 2009 00:37:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 3 Nov 2009 00:37:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2070035
Xref: news.mathworks.com comp.soft-sys.matlab:581941


Hallo Tom,

Your help solved my problem. Thank You very much.

Thomas
 "Tom Lane" <tlane@mathworks.com> wrote in message <hcnodi$aob$1@fred.mathworks.com>...
> > I have data similar to that of the fisheriris data in the classification 
> > demo
> . . .
> > How would I extend the formula for 3 variables ? It seems that the order 
> > of the coefficients provided by classify is not further documented in 
> > detail.
> 
> Thomas, the example picks apart the coefficient arrays into separate scalars 
> so they can be conveniently used in a two-dimensional example. The intent is 
> that the coefficients are documented using the following matrix-oriented 
> expression given in the help:
> 
>     0 < K + x*L + x*Q*x'
> 
> To plot this, the isosurface function may be useful. I don't know of an 
> easier way. Try this:
> 
> % Get 3 measurements from 2 iris species
> load fisheriris
> rows = 51:150;
> X = meas(rows,1:3);
> x = X(:,1); y = X(:,2); z = X(:,3);
> s = species(rows);
> a = 1:50; b = 51:100;
> 
> % Do quadratic classification and get coefficients of boundary
> [c,err,post,logl,str] = classify(X,X,s,'quadratic');
> K = str(1,2).const;
> L = str(1,2).linear;
> Q = str(1,2).quadratic;
> 
> % Plot the data and curve K + [x,y,z]*L + [x,y,z]*Q*[x,y,z]' = 0:
> xv = linspace(4.5,8,10); % vectors to cover the range of each column
> yv = linspace(2,4,10);
> zv = linspace(2.5,7,10);
> [xx,yy,zz] = meshgrid(xv,yv,zv);
> f = @(x,y,z) K + [x y z]*L + sum([x y z] .* ([x y z]*Q), 2);
> v = f(xx(:),yy(:),zz(:));
> v = reshape(v,size(xx));
> plot3(x(a),y(a),z(a),'rv', x(b),y(b),z(b),'b^');
> hold on
> isosurface(xx,yy,zz,v,0);
> hold off
> 
> -- Tom 
>