Java Reference
In-Depth Information
Iter 1 evals 1 <D> [113M 3.107E-4] 5.985E1 0.00s |3.829E1|
{1.959E-1} 0.000E0 -
Iter 2 evals 5 <D> [M 1.000E0] 5.949E1 0.01s |1.862E1|
{9.525E-2} 3.058E-3 -
Iter 3 evals 6 <D> [M 1.000E0] 5.923E1 0.01s |1.741E1|
{8.904E-2} 3.485E-3 -
...
Iter 21 evals 24 <D> [1M 2.850E-1] 3.306E1 0.02s |4.149E-1|
{2.122E-3} 1.775E-4 -
Iter 22 evals 26 <D> [M 1.000E0] 3.306E1 0.02s
QNMinimizer terminated due to average improvement: |
newest_val - previous_val | / |newestVal| < TOL
Total time spent in optimization: 0.07s
At this point, the classifier is ready to use. Next, we use the test file to verify the classifier.
We start by getting a line from the text file using the ObjectBank class'
getLineIterator method. This class supports the conversion of data read into a more
standardized form. The getLineIterator method returns one line at a time in a
format that can be used by the classifier. The loop for this process is shown here:
for (String line :
ObjectBank.getLineIterator("box.test", "utf-8")) {
...
}
Within the for-each statement, a Datum instance is created from the line and then its
classOf method is used to return the predicted category as shown here. The Datum in-
terface supports objects that contain features. When used as the argument of the
classOf method, the category determined by the classifier is returned:
Datum<String, String> datum = cdc.makeDatumFromLine(line);
System.out.println("Datum: {"
+ line + "]\tPredicted Category: "
+ classifier.classOf(datum));
When this sequence is executed, each line of the test file is processed and the predicted
category is displayed, as follows. Only the first two and last two lines are shown here. The
classifier was able to correctly classify all of the test data:
Search WWH ::




Custom Search