Open kennethmorton opened 11 years ago
These unit test objects appear to be awesome. For example, the following will handle all our tests for classifiers, if we set it up properly. We can also make methods to automatically generate, say, the MAT files used to make sure the performance is good- e.g., "run this 20 times, and get me reasonable bounds, then save them".
The M-file is also in ]internal]unitTests, in the newest version, and should work with 2013A
classdef prtUnitTestClassifier < matlab.unittest.TestCase % prtUnitTestClassifier % Example test for classifiers. % % tester = prtUnitTestClassifier('classifier',prtClassFld,'perfLimsKfoldsUnimodal',[.9 1]) % fldResults = tester.run; % % tester = prtUnitTestClassifier('classifier',prtClassKnn,'perfLimsKfoldsUnimodal',[.95 1]) % knnResults = tester.run; % properties classifier perfLimsKfoldsUnimodal = [.9 1]; end
methods
function self = prtUnitTestClassifier(varargin)
self = prtUtilAssignStringValuePairs(self,varargin{:});
end
end
methods (Test)
function testKfoldsPercentCorrectUnimodal(self)
ds = prtDataGenUnimodal;
yOut = kfolds(self.classifier,ds,3);
yOut = rt(prtDecisionBinaryMinPe,yOut);
answer = prtScorePercentCorrect(yOut);
self.verifyGreaterThan(answer,self.perfLimsKfoldsUnimodal(1));
self.verifyLessThan(answer,self.perfLimsKfoldsUnimodal(2));
end
function testPlot2D(self)
c = self.classifier.train(prtDataGenUnimodal);
plot(c);
end
function testPlot3D(self)
ds = catFeatures(prtDataGenUnimodal,prtDataGenUnimodal);
ds = ds.retainFeatures(1:3);
c = self.classifier.train(ds);
plot(c);
end
end
end
The current unit test framework is jankety. The new MATLAB unit test framework introduced in 2013a seems like a good idea. Should we consider making the switch?
http://blogs.mathworks.com/steve/2013/03/12/matlab-software-testing-tools-old-and-new-r2013a/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+SteveOnImageProcessing+%28Steve+on+Image+Processing%29