Skip to content

ml_LogisticRegression

mlclassOpenCV 5.0.0
import { ml_LogisticRegression } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSConstructor or factory
CLASSml_LogisticRegression
RETURN TYPEOwned native handle
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Native object: release it with using or delete(). Factories can return null; check before calling methods. Inherits ml_StatModel.


Logistic Regression * *************************************************************************************** Implements Logistic Regression classifier.

See: ml_intro_lr

Constructors and members

static create

Creates empty model.

Creates Logistic Regression model with parameters given.
create(): ml_LogisticRegression | null;
Returns

The ml_LogisticRegression | null result.

static load

Loads and creates a serialized LogisticRegression from a file

Use LogisticRegression::save to serialize and store an LogisticRegression to disk. Load the LogisticRegression from this file again, by calling this function with the path to the file. Optionally specify the node for the file containing the classifier

load(filepath: EmbindString, nodeName: EmbindString): ml_LogisticRegression | null;
2 available overloads
load(filepath: EmbindString): ml_LogisticRegression | null;
load(filepath: EmbindString, nodeName: EmbindString): ml_LogisticRegression | null;
filepath

path to serialized LogisticRegression

nodeName

name of node containing the classifier

Returns

The ml_LogisticRegression | null result.

clone

Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.

clone(): this;
Returns

The this result.

getLearningRate

Learning rate. See: setLearningRate

getLearningRate(): number;
Returns

The number result.

setLearningRate

Learning rate. See: setLearningRate See: getLearningRate

setLearningRate(val: number): void;
val

val argument (number).

getIterations

Number of iterations. See: setIterations

getIterations(): number;
Returns

The number result.

setIterations

Number of iterations. See: setIterations See: getIterations

setIterations(val: number): void;
val

val argument (number).

getRegularization

Kind of regularization to be applied. See LogisticRegression::RegKinds. See: setRegularization

getRegularization(): number;
Returns

The number result.

setRegularization

Kind of regularization to be applied. See LogisticRegression::RegKinds. See: setRegularization See: getRegularization

setRegularization(val: number): void;
val

val argument (number).

getTrainMethod

Kind of training method used. See LogisticRegression::Methods. See: setTrainMethod

getTrainMethod(): number;
Returns

The number result.

setTrainMethod

Kind of training method used. See LogisticRegression::Methods. See: setTrainMethod See: getTrainMethod

setTrainMethod(val: number): void;
val

val argument (number).

getMiniBatchSize

Specifies the number of training samples taken in each step of Mini-Batch Gradient Descent. Will only be used if using LogisticRegression::MINI_BATCH training algorithm. It has to take values less than the total number of training samples. See: setMiniBatchSize

getMiniBatchSize(): number;
Returns

The number result.

setMiniBatchSize

Specifies the number of training samples taken in each step of Mini-Batch Gradient Descent. Will only be used if using LogisticRegression::MINI_BATCH training algorithm. It has to take values less than the total number of training samples. See: setMiniBatchSize See: getMiniBatchSize

setMiniBatchSize(val: number): void;
val

val argument (number).

getTermCriteria

Termination criteria of the algorithm. See: setTermCriteria

getTermCriteria(): TermCriteria;
Returns

The TermCriteria result.

setTermCriteria

Termination criteria of the algorithm. See: setTermCriteria See: getTermCriteria

setTermCriteria(val: TermCriteria): void;
val

val argument (TermCriteria).

predict

Predicts responses for input samples and returns a float type.

predict(samples: Mat, results: Mat, flags: number): number;
3 available overloads
predict(samples: Mat): number;
predict(samples: Mat, results: Mat): number;
predict(samples: Mat, results: Mat, flags: number): number;
samples

The input data for the prediction algorithm. Matrix [m x n], where each row contains variables (features) of one object being classified. Should have data type CV_32F.

results

Output destination, filled by the native operation. Predicted labels as a column matrix of type CV_32S.

flags

Not used.

Returns

The number result.

get_learnt_thetas

This function returns the trained parameters arranged across rows.

For a two class classification problem, it returns a row matrix. It returns learnt parameters of
the Logistic Regression as a matrix of type CV_32F.
get_learnt_thetas(): Mat;
Returns

The Mat result. Release returned native handles with using or delete(), including handles nested in results.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.