Hyper Classifier Example
Contents
Warning
Expect this file to take a relatively long time to execute due to expensive calculations. Please be patient.
Preparing the data
This example comes with two files, 'simpleCurveSegments.mat' and 'realCurveShapeAnalystSamples400_.mat', which contain basic curve samples for the lowest level classifier and real curve samples respectively. All samples are associated with a correct classification id.
load('simpleCurveSegments.mat'); load('realCurveShapeAnalystSamples400_.mat');
Initializing and training the classifier
As the algorithm requires a simple LCC classifier at its lowest level, we create one and train it using the basic curve samples.
nDCT = 0; nCV = [ 3 5 7 9 11 15 17 ]; config.scalePercentage= 0.3; config.growthThresh= 0.95; config.keepHistory= 0; config = createClassifierConfig(config); classifier = newClassifier(protos3CV, protosIds, [], config);
This LCC classifier is then used to build the hyper classifier.
configH.filterClassifier = classifier;
We reset the previous basic configuration object and recreate it to have a clean start with specific parameters. Within the hyper classifier this new configuration will be used as a template for the higher level LCC classifiers.
clear config; config.scalePercentage = 0.3; config.growthThresh = 0.95; config.keepHistory = 0; config.generateNewClasses = 1; config.recycleRubbish = 0; config.scaleAdaptation = 'allMean'; configH.classifierConfigs = createClassifierConfig(config);
Finally the actual hyper classifier can be created, following the usual steps:
1. Specify non-default parameters in a structure
configH.nHierarchyLevels = maxLevel; for lev = 1 : maxLevel configH.featureParams(lev).nFeatures = [ 0 0 nCV(lev) ]; end
2. Create complete configuration object for hyper classifiers
configH = createHyperClassifierConfig(configH);
3. Create hyper classifier
hyperClassif = newHyperClassifier(samples, classIds, configH);
.......... .......... .......... ..........
Getting a response
Although the algorithm is capable of considering multiple hypotheses and thus achieve better results, we will use only one hypothesis here. However, in general the responses are returned in a matrix with one row for each considered hypothesis.
nHypos = 1; [ responses, responseValues ] = getHyperClassifierResponse(hyperClassif, samples, nHypos);
The quality of the response can easily be evaluated, since the data we used here has already been pre-classified.
nFalse = sum((classIds - responses(1, :)) ~= 0); fprintf('false classified: %d\n', nFalse); fprintf('false classified: %5.3f\n\n', nFalse / length(samples));
false classified: 0 false classified: 0.000
Further information
Details about the LCC classifiers which are used to construct the hyper classifier can be found in the LCC standalone package.