Class cv::ml::LogisticRegression#
Implements Logistic Regression classifier. View details
#include <opencv2/ml.hpp>Collaboration diagram for cv::ml::LogisticRegression:
Public Types#
Training methods.
enum Methods {
BATCH = 0,
MINI_BATCH = 1
}Regularization kinds.
enum RegKinds {
REG_DISABLE = -1,
REG_L1 = 0,
REG_L2 = 1
}Public Types inherited from cv::ml::StatModel
Return |
Name |
Description |
|---|---|---|
Public Member Functions#
Public Member Functions inherited from cv::ml::StatModel
Return |
Name |
Description |
|---|---|---|
|
|
Computes error on the training or test dataset. |
|
Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read. |
|
|
Returns the number of variables in training samples. |
|
|
Returns true if the model is classifier. |
|
|
Returns true if the model is trained. |
|
|
|
Predicts response(s) for the provided sample(s) |
|
Trains the statistical model. |
|
|
|
Trains the statistical model. |
Public Member Functions inherited from cv::Algorithm
Return |
Name |
Description |
|---|---|---|
|
Clears the algorithm state. |
|
|
Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read. |
|
|
Reads algorithm parameters from a file storage. |
|
|
||
|
|
|
|
Stores algorithm parameters in a file storage. |
|
|
Static Public Member Functions#
Static Public Member Functions inherited from cv::ml::StatModel
Return |
Name |
Description |
|---|---|---|
|
Create and train model with default parameters. |
Static Public Member Functions inherited from cv::Algorithm
Return |
Name |
Description |
|---|---|---|
|
|
Loads algorithm from the file. |
|
|
Loads algorithm from a String. |
|
Reads algorithm from the file node. |
Additional Inherited Members#
Protected Member Functions inherited from cv::Algorithm
Return |
Name |
Description |
|---|---|---|
|
Detailed Description#
Implements Logistic Regression classifier.
See also
ml_intro_lr
Member Enumeration Documentation#
enum Methods
Training methods.
|
|
|
Set MiniBatchSize to a positive integer when using this method. |
enum RegKinds
Regularization kinds.
|
Regularization disabled. |
|
L1 norm |
|
L2 norm |
Member Function Documentation#
get_learnt_thetas()#
Mat cv::ml::LogisticRegression::get_learnt_thetas()
Python:
cv.ml.LogisticRegression.get_learnt_thetas() -> retval
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.
getIterations()#
int cv::ml::LogisticRegression::getIterations()
Python:
cv.ml.LogisticRegression.getIterations() -> retval
Number of iterations.
See also
getLearningRate()#
double cv::ml::LogisticRegression::getLearningRate()
Python:
cv.ml.LogisticRegression.getLearningRate() -> retval
Learning rate.
See also
getMiniBatchSize()#
int cv::ml::LogisticRegression::getMiniBatchSize()
Python:
cv.ml.LogisticRegression.getMiniBatchSize() -> retval
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 also
getRegularization()#
int cv::ml::LogisticRegression::getRegularization()
Python:
cv.ml.LogisticRegression.getRegularization() -> retval
Kind of regularization to be applied. See LogisticRegression::RegKinds.
See also
getTermCriteria()#
TermCriteria cv::ml::LogisticRegression::getTermCriteria()
Python:
cv.ml.LogisticRegression.getTermCriteria() -> retval
Termination criteria of the algorithm.
See also
getTrainMethod()#
int cv::ml::LogisticRegression::getTrainMethod()
Python:
cv.ml.LogisticRegression.getTrainMethod() -> retval
Kind of training method used. See LogisticRegression::Methods.
See also
predict()#
float cv::ml::LogisticRegression::predict(
InputArray samples,
OutputArray results = noArray(),
int flags = 0 )
Python:
cv.ml.LogisticRegression.predict(samples[, results[, flags]]) -> retval, results
Predicts responses for input samples and returns a float type.
Parameters
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— Predicted labels as a column matrix of type CV_32S.flags— Not used.
Here is the call graph for this function:
setIterations()#
void cv::ml::LogisticRegression::setIterations(int val)
Python:
cv.ml.LogisticRegression.setIterations(val)
See also
setLearningRate()#
void cv::ml::LogisticRegression::setLearningRate(double val)
Python:
cv.ml.LogisticRegression.setLearningRate(val)
See also
setMiniBatchSize()#
void cv::ml::LogisticRegression::setMiniBatchSize(int val)
Python:
cv.ml.LogisticRegression.setMiniBatchSize(val)
See also
setRegularization()#
void cv::ml::LogisticRegression::setRegularization(int val)
Python:
cv.ml.LogisticRegression.setRegularization(val)
See also
setTermCriteria()#
void cv::ml::LogisticRegression::setTermCriteria(TermCriteria val)
Python:
cv.ml.LogisticRegression.setTermCriteria(val)
See also
setTrainMethod()#
void cv::ml::LogisticRegression::setTrainMethod(int val)
Python:
cv.ml.LogisticRegression.setTrainMethod(val)
See also
create()#
static Ptr< LogisticRegression > cv::ml::LogisticRegression::create()
Python:
cv.ml.LogisticRegression.create() -> retval
cv.ml.LogisticRegression_create() -> retval
Creates empty model.
Creates Logistic Regression model with parameters given.
load()#
static Ptr< LogisticRegression > cv::ml::LogisticRegression::load(
const String & filepath,
const String & nodeName = String() )
Python:
cv.ml.LogisticRegression.load(filepath[, nodeName]) -> retval
cv.ml.LogisticRegression_load(filepath[, nodeName]) -> retval
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
Parameters
filepath— path to serialized LogisticRegressionnodeName— name of node containing the classifier
Source file#
The documentation for this class was generated from the following file:
opencv2/ml.hpp