To evaluate the classifier on a separate dataset, we will use the following steps:
- Let's start by importing the emails located in our test folder:
InstanceList testInstances = new InstanceList(classifier.getInstancePipe()); folderIterator = new FileIterator( new File[] {new File(testFolderPath)}, new TxtFilter(), FileIterator.LAST_DIRECTORY);
- We will pass the data through the same pipeline that we initialized during training:
testInstances.addThruPipe(folderIterator);
- To evaluate classifier performance, we'll use the cc.mallet.classify.Trial class, which is initialized with a classifier and set of test instances:
Trial trial = new Trial(classifier, testInstances);
- The evaluation is performed immediately at initialization. ...