perClass Documentation
version 5.4 (7-Dec-2018)

kb27: Upgrading to perClass 4

Published on: 26-jul-2013

perClass version used: 4.0 (26-jul-2013)

Problem: How can I upgrade from perClass 3.x to 4.0?

Solution: Update your Matlab scripts and re-export classifiers for execution.

27.1. Introduction ↩

perClass 4.0 release brings several simplifications of Matlab scripts mostly regarding classifier pipelines. Moving from perClass 3.x to 4.0 is matter of minutes.

Quick list:

27.2. Toolbox ↩

27.2.1. Matlab pipeline import ↩

Format of Matlab sdppl pipelines changed in 4.0. Your existing 3.x pipelines are converted automatically when loaded into perClass 4.0. If you encounter any difficulty when loading 3.x pipelines, contact as via sdfeedback or support@perclass.com.

27.2.2. Classifiers return decisions by default ↩

In 4.0, all classifiers provide decisions by default.

What to do: Remove sddecide in your scripts as it is not necessary anymore.

27.2.3. ROC fails because 3.x code passes decisions, not soft outputs ↩

The sdroc in your 3.x scripts will raise an error because the output of out=test_set * classifier now returns decisions, not soft outputs.

3.x code:

>> load fruit
>> p=sdlinear(a);
>> out=a*p;
>> r=sdroc(out);

There are two solutions available in 4.x:

Solution 1: Use unary minus operator (-p) to remove decision step:

>> p=sdlinear(a)
sequential pipeline       2x1 'Gaussian model+Normalization+Decision'
1 Gaussian model          2x3  single cov.mat.
2 Normalization           3x3 
3 Decision                3x1  weighting, 3 classes

>> -p
sequential pipeline       2x3 'Gaussian model+Normalization'
1 Gaussian model          2x3  single cov.mat.
2 Normalization           3x3 

>> out=a* -p
'Fruit set' 260 by 3 sddata, 3 classes: 'apple'(100) 'banana'(100) 'stone'(60) 

>> r=sdroc(out)
..........
ROC (260 w-based op.points, 4 measures), curop: 2
est: 1:err(apple)=0.11, 2:err(banana)=0.11, 3:err(stone)=0.05, 4:mean-error=0.09

Solution 2: Pass test set and classifier to sdroc instead of soft outputs

>> r=sdroc(test_set,p)
..........
ROC (260 w-based op.points, 4 measures), curop: 2
est: 1:err(apple)=0.11, 2:err(banana)=0.11, 3:err(stone)=0.05, 4:mean-error=0.09

27.2.4. New syntax of label constructor ↩

The syntax of sdlab constructor is updated in 4.0 so that, in all cases, we provide class names first and other information later.

The case that requires intervention in your existing 3.x scripts is when constructing label object by providing class names and per-class number of samples.

Using 3.x syntax will lead to error in perClass 4:

>> lab=sdlab({'apple','banana'},[3 4])
{??? Error using ==> sdlist.ind2code at 12
Index out of bounds. Category indices are expected (values from 1 to 2)

What to do: Add a 'sizes' option after the list of names:

>> lab=sdlab({'apple','banana'},'sizes',[3 4])
sdlab with 7 entries, 2 groups: 'apple'(3) 'banana'(4) 
>> +lab

ans =

apple 
apple 
apple 
banana
banana
banana
banana

27.2.5. sddetector renamed into sddetect ↩

In perClass 4, sddetector is renamed into sddetect.

Both sddetect and sdreject return by default decisions so that all training objects (for sddetect the targets) are accepted.

27.2.6. ROC with cost specification sets different operating point ↩

In perClass 4, if sdroc/sdroc is give cost specification, the operating point minimizing the related loss is chosen as current by default.

27.3. Classifier execution out of Matlab ↩

To use perClass 4 Runtime in your project, re-export your classifiers with perClass 4 sdexport. The perClass 4 Runtime is a drop-in replacement in 3.x projects. Just copy the DLL, 4.x license file and re-exported pipelines.

The 4.0 API provides two new functions:

The sd_LicenseCheck function is removed.