Package qupath.opencv.ml
Class OpenCVClassifiers.LogisticRegressionClassifier
java.lang.Object
qupath.opencv.ml.OpenCVClassifiers.OpenCVStatModel
qupath.opencv.ml.OpenCVClassifiers.LogisticRegressionClassifier
- Enclosing class:
OpenCVClassifiers
public static class OpenCVClassifiers.LogisticRegressionClassifier
extends OpenCVClassifiers.OpenCVStatModel
Classifier based on
LogisticRegression.-
Method Summary
Modifier and TypeMethodDescriptioncreateTrainData(Mat samples, Mat targets, Mat weights, boolean doMulticlass) Create training data in the format required by this classifier.getName()User-friendly, readable name for the classifierRetrieve a list of adjustable parameter that can be used to customize the classifier.protected intbooleanClassifier has already been trained and is ready to predict.voidDefault implementation callingprotected voidpredictWithLock(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
-
createTrainData
Description copied from class:OpenCVClassifiers.OpenCVStatModelCreate training data in the format required by this classifier.- Parameters:
samples-targets-weights- optional weightsdoMulticlass-- Returns:
- See Also:
-
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
-
train
Description copied from class:OpenCVClassifiers.OpenCVStatModelTrain the classifier using data in an appropriate format.- Specified by:
trainin classOpenCVClassifiers.OpenCVStatModel- Parameters:
trainData-- 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
-
predictWithLock
Implement predictWithLock rather than predict to ensure predict is not called while training.- Parameters:
samples-results-probabilities-- See Also:
-
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
-