LogisticRegression class
Implements Logistic Regression classifier.
Training needs CV_32F responses; predicted labels are CV_32S (CV_32F with
StatModel.RAW_OUTPUT). With MINI_BATCH the number of steps is termCriteria.maxCount, not
iterations.
https://docs.opencv.org/4.x/d6/df9/classcv_1_1ml_1_1LogisticRegression.html
- Inheritance
- Available extensions
Constructors
- LogisticRegression.create()
-
Creates an empty model. Use one of the train methods to train it, or LogisticRegression.load.
factory
- LogisticRegression.fromPointer(LogisticRegressionPtr ptr, [bool attach = true])
-
factory
- LogisticRegression.load(String filepath)
-
Loads a model saved with save from
filepath. Throws CvException when the file does not hold a valid model.factory - LogisticRegression.loadFromString(String strModel, {String objname = ''})
-
Loads a model from the content of a file saved with save (e.g. a Flutter asset).
factory
Properties
- defaultName → String
-
The name used when saving the model,
opencv_ml_lr.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- isClassifier → bool
-
Whether the model is a classifier (false for a regressor).
no setter
- isDisposed → bool
-
Whether this object has been disposed.
no setterinherited
- isEmpty → bool
-
no setter
- isTrained → bool
-
no setter
- iterations ↔ int
-
Number of iterations.
getter/setter pair
- learningRate ↔ double
-
Learning rate.
getter/setter pair
- learntThetas → Mat
-
The trained parameters, arranged across rows; for a two-class classification problem a single row.
no setter
- miniBatchSize ↔ int
-
Number of training samples taken in each step of Mini-Batch Gradient Descent.
getter/setter pair
-
props
→ List<
Object?> -
no setterinherited
-
ptr
↔ Pointer<
LogisticRegression> -
getter/setter pairinherited
- ref → LogisticRegression
-
A view of the native memory behind ptr, not a copy.
no setteroverride
- regularization ↔ int
-
Kind of regularization to be applied, one of REG_DISABLE, REG_L1, REG_L2.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- termCriteria ↔ TermCriteria
-
Termination criteria of the training algorithm.
getter/setter pair
- trainMethod ↔ int
-
Kind of training method used, one of BATCH, MINI_BATCH.
getter/setter pair
- varCount → int
-
Number of learnt parameters per class: the number of variables plus one (the bias).
no setter
Methods
-
calcError(
TrainData data, bool test) → (double, Mat) -
Computes the error on the training (
testfalse) or test (testtrue) part ofdata. -
calcErrorAsync(
TrainData data, bool test) → Future< (double, Mat)> -
Available on LogisticRegression, provided by the LogisticRegressionAsync extension
-
clear(
) → void - Clears the model, it becomes untrained.
-
dispose(
) → void -
Releases the underlying native resources. Idempotent: calling it more
than once is safe, but the object must not be used after dispose.
inherited
-
freeNative(
) → void -
Frees the native resources owned by this object. Subclasses implement the
concrete free logic here; callers must use dispose instead.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
predict(
Mat samples, {int flags = 0}) → Mat -
Predicts the response for each row of
samples, one row of the returned Mat per sample. -
predictAsync(
Mat samples, {int flags = 0}) → Future< Mat> -
Available on LogisticRegression, provided by the LogisticRegressionAsync extension
-
save(
String filename) → void -
Saves the model to
filename(.xml, .yml or .json). -
toString(
) → String -
A string representation of this object.
inherited
-
train(
Mat samples, int layout, Mat responses) → bool -
Trains the model on
samples(CV_32F, one sample per row for ROW_SAMPLE). -
trainAsync(
Mat samples, int layout, Mat responses) → Future< bool> -
Available on LogisticRegression, provided by the LogisticRegressionAsync extension
-
trainWithData(
TrainData data, {int flags = 0}) → bool -
Trains the model on
data,flagsmay be StatModel.UPDATE_MODEL or model-specific flags. -
trainWithDataAsync(
TrainData data, {int flags = 0}) → Future< bool> -
Available on LogisticRegression, provided by the LogisticRegressionAsync extension
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- finalizer → NativeFinalizer
-
final
Constants
- BATCH → const int
- MINI_BATCH → const int
- REG_DISABLE → const int
- REG_L1 → const int
- REG_L2 → const int