Search code examples
javahadoopclassificationmahoutrandom-forest

convert mahout random forest classification output to readable


I am learning the mahout random forest with tutorial in mahout site: http://mahout.apache.org/users/classification/partial-implementation.html

but when all jobs finishes successfully my output file is like this:

@1@.@0@

@1@.@0@

@0@.@0@

@1@.@0@

@1@.@0@

@0@.@0@

@0@.@0@

@0@.@0@

how can I convert it to human readable output?


Solution

  • finally i found that this numbers are the code of labels.

    we can change them to labels.

    after this code in TestForest.java example:

    classifier.run();
    

    get the results:

    double[][] results = classifier.getResults();
    

    the second column is the prediction. change it to label with this code:

    Dataset dataset = Dataset.load(getConf(), datasetPath);
    for (double[] res : results) {
        dataset.getLabelString(res[1]);
    }