% INF5300, v2015
% Note: Requires the PRTools package.

prdatasets; % Run this to allow on-the-fly access to the example datasets

A = mfeat_zer;      % Load the mfeat_zer dataset
A = setprior(A,0);  % Set equal prior for each class
[T,S] = gendat(A,0.5);  % Partition data randomly into train / test set

nSelFeat = 8;       % Number of features we seek

% Find the best nSelFeat features using the sum of Mahalanobis distances criterion
U = T*featseli([], 'maha-s', nSelFeat); % Individual feature selection
% U = T*featself([], 'maha-s', nSelFeat); % Forward selection
% U = T*featselb([], 'maha-s', nSelFeat); % Backward selection
% U = T*featselp([], 'maha-s', nSelFeat); % "Forward floating selection"

% .. or using a wrapper-based approach based on the quadratic classifier
% U = T*featseli([], qdc, nSelFeat); % Individual feature selection

+U % List which variables were selected

W = (T*U)*qdc; % Train a quadratic classifier on the selected variables

testc(S*U*W) % Compute the classification error rate for the test set



