Model performance

To evaluate the classifier on a separate dataset, we will use the following steps:

  1. 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); 
  1. We will pass the data through the same pipeline that we initialized during training:
testInstances.addThruPipe(folderIterator); 
  1. 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); 
  1. The evaluation is performed immediately at initialization. ...

Get Machine Learning in Java - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.