Documentation

The most up-to-date documentation can be found in the PRTools manual. Also the book "Classification, Parameter Estimation and State estimation" has many example scripts using PRTools.

The toolbox itself contains several example scripts, starting with prex_. They illustrate very simple training and plotting of classifiers, as in prex_plotc, but also very advanced combining of classifiers prex_combining or cost-based classification prex_cost.

If you still have a question, or found a bug, please first check the Frequently Asked Questions. If your problem is not covered there, please check the forum.

Example session in PRTools

Although manuals and books are nice, nothing is more enlightening than an example session in Matlab to give an impression of PRTools. Let us define a task. The task is to generate some artificial data, train a few classifiers on it, estimate the error of the classifiers and make a plot of their decision boundaries.

First generate some artificial 2D data, and split it in a training and test set. In this example we use 20% for training, and the remaining 80% will be used for testing.

>> A = gendatb([50 50]);
>> [C,D] = gendat(A,0.2);

Next, we train two classifiers on the training set, a quadratic classifier and a k-nearest neighbor classifier (with k=3).

>> w1 = qdc(C);
>> w2 = knnc(C,3);

Objects from the test set can be evaluated by the classifier by mapping the dataset using the classifier:

>> mappedD = D*w1

To obtain the classification labels, use

>> labels = mappedD*labeld

Estimate the error of both classifiers on the test set

>> err1 = D*w1*testc
>> err2 = D*w2*testc

We are dealing with a 2D dataset so we can make a scatterplot of this data and plot the decision boundary in it.

>> figure(1); clf;
>> scatterd(D);
>> plotc(w1,'k');
>> plotc(w2,'r');
The result might look something like:

Frequently Asked Questions

So I trained a classifier, but how can I see how a new dataset is classified?

Well, if you have a classifier called w, and a new dataset D, you can map your data by the classifier by mappedD = D*w. To find the actual class labels, type D*w*labeld. And to find the classification error, type D*w*testc.

When I try to train a support vector classifier (svc.m) under Windows, I get an error 'Segmentation violation in qld.dll'.

There are actually two versions of the quadratic optimizer compiled for Windows. They are qld.dll and qld.dll.og. They are stored in the private directory in the prtools directory. If Matlab crashes when using qld.dll, rename qld.dll.og to qld.dll. When the support vector classifier might still not work, please send us an email.