Package qupath.opencv.ml
Class OpenCVClassifiers.RTreesClassifier
java.lang.Object
qupath.opencv.ml.OpenCVClassifiers.OpenCVStatModel
qupath.opencv.ml.OpenCVClassifiers.RTreesClassifier
- Enclosing class:
- OpenCVClassifiers
Classifier based on
RTrees.-
Method Summary
Modifier and TypeMethodDescriptioncreateTrainData(Mat samples, Mat targets, Mat weights, boolean doMulticlass) Create training data in the format required by this classifier.double[]Request the variable importance values from the last trained RTrees classifier, if available.getName()User-friendly, readable name for the classifierRetrieve a list of adjustable parameter that can be used to customize the classifier.protected intbooleanCheck if the last time train was called, variable (feature) importance was calculated.booleanClassifier has already been trained and is ready to predict.voidDefault implementation callingvoidpredictWithLock(Mat samples, Mat results, Mat probabilities) Implement predictWithLock rather than predict to ensure predict is not called while training.booleanReturns true (the default value).booleanTree classifiers in OpenCV support missing values, others do not.booleanReturns false (the default value).booleanClassifier can output a prediction confidence (expressed between 0 and 1), so may be interpreted as a probability...toString()voidTrain the classifier using data in an appropriate format.voidtrainWithLock(TrainData trainData) Implement trainWithLock rather than train directly to ensure a lock is set when training, which can be used to prevent prediction occurring simultaneously.
-
Method Details
-
train
Description copied from class:OpenCVClassifiers.OpenCVStatModelTrain the classifier using data in an appropriate format. -
hasFeatureImportance
public boolean hasFeatureImportance()Check if the last time train was called, variable (feature) importance was calculated.- Returns:
- See Also:
-
getFeatureImportance
public double[] getFeatureImportance()Request the variable importance values from the last trained RTrees classifier, if available.- Returns:
- the ordered array of importance values, or null if this is unavailable
- See Also:
-
predictWithLock
Implement predictWithLock rather than predict to ensure predict is not called while training. -
supportsMulticlass
public boolean supportsMulticlass()Returns false (the default value).- Specified by:
supportsMulticlassin classOpenCVClassifiers.OpenCVStatModel- Returns:
- true if multiclass classification is supported, false otherwise
-
supportsAutoUpdate
public boolean supportsAutoUpdate()Returns true (the default value).- Specified by:
supportsAutoUpdatein classOpenCVClassifiers.OpenCVStatModel- Returns:
- true if interactive classification is supported, false otherwise
-
supportsProbabilities
public boolean supportsProbabilities()Description copied from class:OpenCVClassifiers.OpenCVStatModelClassifier can output a prediction confidence (expressed between 0 and 1), so may be interpreted as a probability... even if it isn't necessarily one.- Specified by:
supportsProbabilitiesin classOpenCVClassifiers.OpenCVStatModel- Returns:
- true if (pseudo-)probabilities can be provided
-
isTrained
public boolean isTrained()Description copied from class:OpenCVClassifiers.OpenCVStatModelClassifier has already been trained and is ready to predict.- Specified by:
isTrainedin classOpenCVClassifiers.OpenCVStatModel- Returns:
- true if the classifier is trained, false otherwise
-
getParameterList
Description copied from class:OpenCVClassifiers.OpenCVStatModelRetrieve a list of adjustable parameter that can be used to customize the classifier. After making changes to theParameterList, the classifier should be retrained before being used.- Specified by:
getParameterListin classOpenCVClassifiers.OpenCVStatModel- Returns:
- the parameter list for this classifier
-
toString
- Overrides:
toStringin classOpenCVClassifiers.OpenCVStatModel
-
createTrainData
Description copied from class:OpenCVClassifiers.OpenCVStatModelCreate training data in the format required by this classifier.- Specified by:
createTrainDatain classOpenCVClassifiers.OpenCVStatModelweights- optional weights- Returns:
- See Also:
-
trainWithLock
Implement trainWithLock rather than train directly to ensure a lock is set when training, which can be used to prevent prediction occurring simultaneously.- Parameters:
trainData-- See Also:
-
getTrainFlags
protected int getTrainFlags() -
getName
Description copied from class:OpenCVClassifiers.OpenCVStatModelUser-friendly, readable name for the classifier- Specified by:
getNamein classOpenCVClassifiers.OpenCVStatModel- Returns:
- the classifier name
-
predict
Default implementation callingstatModel.predict(samples, results, 0);
before attempting to sanitize the outcome so that results always contains a signed int Mat containing classifications.If results originally had more than 1 column, it will be returned as probabilities (if probabilities is not null);
probabilitieswill be an empty matrix (i.e. no probabilities calculated).- Specified by:
predictin classOpenCVClassifiers.OpenCVStatModel- Parameters:
samples- the input samplesresults- a Mat to receive the resultsprobabilities- a Mat to receive probability estimates, or null if probabilities are not needed
-
supportsMissingValues
public boolean supportsMissingValues()Tree classifiers in OpenCV support missing values, others do not.- Specified by:
supportsMissingValuesin classOpenCVClassifiers.OpenCVStatModel- Returns:
- true if NaNs are supported, false otherwise
-