Example usage for org.opencv.ml RTrees setUse1SERule

List of usage examples for org.opencv.ml RTrees setUse1SERule

Introduction

In this page you can find the example usage for org.opencv.ml RTrees setUse1SERule.

Prototype

public void setUse1SERule(boolean val) 

Source Link

Usage

From source file:qupath.opencv.classify.RTreesClassifier.java

License:Open Source License

@Override
protected RTrees createClassifier() {
    RTrees trees = RTrees.create();
    ParameterList params = getParameterList();
    if (params != null) {
        int maxDepth = params.getIntParameterValue("maxDepth");
        int minSamples = params.getIntParameterValue("minSamples");
        boolean use1SE = params.getBooleanParameterValue("use1SE");
        trees.setMaxDepth(maxDepth == 0 ? Integer.MAX_VALUE : maxDepth);
        trees.setMinSampleCount(minSamples);
        trees.setUse1SERule(use1SE);

        // setUseSurrogates should help with missing data... but it appears not actually to be implemented
        //         System.out.println("DEFAULT SURROGATES: " + trees.getUseSurrogates());
        //         trees.setUseSurrogates(true);

        // Set termination criteria
        int termCritMaxTrees = params.getIntParameterValue("termCritMaxTrees");
        double termCritEPS = params.getDoubleParameterValue("termCritEPS");
        termCriteria = createTerminationCriteria(termCritMaxTrees, termCritEPS);
        if (termCriteria != null)
            trees.setTermCriteria(termCriteria);
        else//from w ww. j a  v  a  2  s . c om
            termCriteria = trees.getTermCriteria();

        logger.info("RTrees classifier termination criteria: {}", termCriteria);
    }
    //         lastDescription = getName() + "\n\nMain parameters:\n  " + DefaultPluginWorkflowStep.getParameterListJSON(params, "\n  ") + "\n\nTermination criteria:\n  " + termCriteria.toString();
    //         
    //      } else
    //         lastDescription = null;

    //      trees.setCVFolds(5); // Seems to cause segfault...
    //      trees.setCalculateVarImportance(true); // Seems to require surrogates, but...
    //      trees.setUseSurrogates(true); // // Seems not yet to be supported...

    return trees;
}