PRT Blog

MATLAB Pattern Recognition Open Free and Easy


In the PRT we have a a few hidden features that we don’t really advertise but at times they make life easier. This quick post is to reveal one of those quick features, prtAction.rt()

rt() stands run, train. You can use it to perform a “run on train” operation and you only the output dataset. In other words, it’s a quick and dirty method for when you would otherwise need to call run(train(action, dataset), dataset). To see how one might use rt(), let’s calculated the first two principal components of Fisher’s Iris dataset.

ds = prtDataGenIris;
pca = train(prtPreProcPca('nComponents',2), ds);
dsPca = run(pca, ds);

If we didn’t really care about keeping the (trained) PCA object around we could have done this all in one line.

dsPca = run(train(prtPreProcPca('nComponents',2), ds),ds);

That string at the end ds),ds) is odd looking and this is when rt() comes to the rescue.

dsPca = rt(prtPreProcPca('nComponents',2), ds);

That’s how you can use rt() in a nutshell. It’s a nice method to keep in your back pocket when you are just beginning to explore a dataset and cross-validation isn’t yet on your mind. Remember rt() is a (hidden) method of prtAction and therefore can be used with all classifiers, pre-processors etc. Let us know if you find any use for it. We do.