Table of Contents

Class LogisticRegression

Namespace
OpenCvSharp.ML
Assembly
OpenCvSharp.dll

Implements Logistic Regression classifier.

public class LogisticRegression : StatModel, IDisposable, ICvPtrHolder
Inheritance
LogisticRegression
Implements
Inherited Members

Constructors

LogisticRegression(nint)

Creates instance by raw pointer cv::ml::LogisticRegression*

protected LogisticRegression(nint p)

Parameters

p nint

Properties

Iterations

Number of iterations.

public int Iterations { get; set; }

Property Value

int

LearningRate

Learning rate

public double LearningRate { get; set; }

Property Value

double

MiniBatchSize

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.

public int MiniBatchSize { get; set; }

Property Value

int

Regularization

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

public LogisticRegression.RegKinds Regularization { get; set; }

Property Value

LogisticRegression.RegKinds

TermCriteria

Termination criteria of the training algorithm.

public TermCriteria TermCriteria { get; set; }

Property Value

TermCriteria

TrainMethod

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

public LogisticRegression.Methods TrainMethod { get; set; }

Property Value

LogisticRegression.Methods

Methods

Create()

Creates the empty model.

public static LogisticRegression Create()

Returns

LogisticRegression

DisposeManaged()

Releases managed resources

protected override void DisposeManaged()

GetLearntThetas()

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.

public Mat GetLearntThetas()

Returns

Mat

Load(string)

Loads and creates a serialized model from a file.

public static LogisticRegression Load(string filePath)

Parameters

filePath string

Returns

LogisticRegression

LoadFromString(string)

Loads algorithm from a String.

public static LogisticRegression LoadFromString(string strModel)

Parameters

strModel string

he string variable containing the model you want to load.

Returns

LogisticRegression

Predict(InputArray, OutputArray?, int)

Predicts responses for input samples and returns a float type.

public float Predict(InputArray samples, OutputArray? results = null, int flags = 0)

Parameters

samples InputArray

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 OutputArray

Predicted labels as a column matrix of type CV_32S.

flags int

Not used.

Returns

float