PRTools Introductory Example
A very short intro into some of the PRTools possibilities and notation.
Make sure PRTools is in the path.
if exist('ldc','file') ~= 2
error('PRTools is not in the path, please add it.')
end
disp([newline '--- Everything is fine ---'])
Get rid of old figures
delfigs
Take an arbitrary 2D dataset of two classes and plot it
A = gendatb; % The banana set
scatterd(A); % A scatterplot
The dataset A
is a PRTools ‘object’. Typing A
, without ‘;
‘ gives some info:
A
It can be converted to a structure by
struct(A)
Its contents can be listed by
+A
The 2 feature values of the first 5 objects can be inspected by
+A(1:5,:)
Mark them in the scatterplot
hold on; scatterd(A(1:5,:),'o');
Compute a simple classifier: Fisher’s Linear Discriminant
W1 = A*fisherc;
Note that in PRTools A*PROC([],PARS)
is an alternative for PROC(A,PARS)
The error on the training set
A*W1*testc
Plot it in the scatterplot
plotc(W1)
Compute a 3rd degree polynomial classifier based on fisherc
and plot it
W2 = A*polyc([],fisherc,3);
plotc(W2,'r')
The error on the training set
A*W2*testc
Split for separate training and testing
[AT,AS] = gendat(A,0.5)
% 50-50 split in trainset and testset
W = AT*{fisherc,polyc([],fisherc,3)}
% Train classifiers by AT
testc(AS,W)
% Test classifiers by AS
Return to DisTools Introductory Examples | Continue with next DisTools Example |