Example usage for org.opencv.ml RTrees setMinSampleCount

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

Introduction

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

Prototype

public void setMinSampleCount(int 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);//from   w  w  w . java2s.c  om

        // 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
            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;
}