Package qupath.opencv.ml
Class OpenCVClassifiers.SVMSGDClassifierCV
java.lang.Object
qupath.opencv.ml.OpenCVClassifiers.OpenCVStatModel
qupath.opencv.ml.OpenCVClassifiers.SVMSGDClassifierCV
- Enclosing class:
OpenCVClassifiers
Classifier based on
SVMSGD
.-
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 int
boolean
Classifier has already been trained and is ready to predict.void
Default implementation callingprotected void
predictWithLock
(Mat samples, Mat results, Mat probabilities) Implement predictWithLock rather than predict to ensure predict is not called while training.boolean
Returns true (the default value).boolean
Tree classifiers in OpenCV support missing values, others do not.boolean
Returns false (the default value).boolean
Classifier can output a prediction confidence (expressed between 0 and 1), so may be interpreted as a probability...toString()
void
Train the classifier using data in an appropriate format.void
trainWithLock
(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
-
supportsAutoUpdate
public boolean supportsAutoUpdate()Returns true (the default value).- Returns:
- true if interactive classification is supported, false otherwise
-
supportsMulticlass
public boolean supportsMulticlass()Returns false (the default value).- Specified by:
supportsMulticlass
in classOpenCVClassifiers.OpenCVStatModel
- Returns:
- true if multiclass classification is supported, false otherwise
-
supportsProbabilities
public boolean supportsProbabilities()Description copied from class:OpenCVClassifiers.OpenCVStatModel
Classifier 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:
supportsProbabilities
in classOpenCVClassifiers.OpenCVStatModel
- Returns:
- true if (pseudo-)probabilities can be provided
-
isTrained
public boolean isTrained()Description copied from class:OpenCVClassifiers.OpenCVStatModel
Classifier has already been trained and is ready to predict.- Specified by:
isTrained
in classOpenCVClassifiers.OpenCVStatModel
- Returns:
- true if the classifier is trained, false otherwise
-
getParameterList
Description copied from class:OpenCVClassifiers.OpenCVStatModel
Retrieve 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:
getParameterList
in classOpenCVClassifiers.OpenCVStatModel
- Returns:
- the parameter list for this classifier
-
toString
- Overrides:
toString
in classOpenCVClassifiers.OpenCVStatModel
-
createTrainData
Description copied from class:OpenCVClassifiers.OpenCVStatModel
Create training data in the format required by this classifier.- Specified by:
createTrainData
in classOpenCVClassifiers.OpenCVStatModel
- Parameters:
samples
-targets
-weights
- optional weightsdoMulticlass
-- Returns:
- See Also:
-
train
Description copied from class:OpenCVClassifiers.OpenCVStatModel
Train the classifier using data in an appropriate format.- Specified by:
train
in 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.OpenCVStatModel
User-friendly, readable name for the classifier- Specified by:
getName
in 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);
probabilities
will be an empty matrix (i.e. no probabilities calculated).- Specified by:
predict
in 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:
supportsMissingValues
in classOpenCVClassifiers.OpenCVStatModel
- Returns:
- true if NaNs are supported, false otherwise
-