View Source Evision.ML.LogisticRegression (Evision v0.1.7)

Link to this section Summary

cv

Clears the algorithm state

Returns the algorithm string identifier. This string is used as top level xml/yml node tag when the object is saved to a file or string.

Reads algorithm parameters from a file storage

Positional Arguments

Saves the algorithm to a file. In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs).

simplified API for language bindings

simplified API for language bindings

cv.ml

Computes error on the training or test dataset

Computes error on the training or test dataset

Creates empty model.

Python prototype (for reference):

This function returns the trained parameters arranged across rows.

@see setIterations

@see setLearningRate

@see setMiniBatchSize

@see setRegularization

@see setTermCriteria

@see setTrainMethod

Returns the number of variables in training samples

Returns true if the model is classifier

Returns true if the model is trained

Loads and creates a serialized LogisticRegression from a file

Loads and creates a serialized LogisticRegression from a file

Predicts responses for input samples and returns a float type.

Predicts responses for input samples and returns a float type.

Positional Arguments
  • val: int

@copybrief getIterations @see getIterations

Positional Arguments
  • val: double

@copybrief getLearningRate @see getLearningRate

Positional Arguments
  • val: int

@copybrief getMiniBatchSize @see getMiniBatchSize

Positional Arguments
  • val: int

@copybrief getRegularization @see getRegularization

Positional Arguments
  • val: TermCriteria

@copybrief getTermCriteria @see getTermCriteria

Positional Arguments
  • val: int

@copybrief getTrainMethod @see getTrainMethod

Trains the statistical model

Trains the statistical model

Trains the statistical model

Functions

Raising version of clear/1.

Raising version of create/0.

Raising version of empty/1.

Raising version of getVarCount/1.

Raising version of isClassifier/1.

Raising version of isTrained/1.

Raising version of load/1.

Raising version of load/2.

Raising version of predict/2.

Raising version of read/2.

Raising version of save/2.

Raising version of train/2.

Raising version of write/2.

Raising version of write/3.

Link to this section cv

Clears the algorithm state

Python prototype (for reference):

clear() -> None

Returns the algorithm string identifier. This string is used as top level xml/yml node tag when the object is saved to a file or string.

Python prototype (for reference):

getDefaultName() -> retval

Reads algorithm parameters from a file storage

Positional Arguments
  • fn_: FileNode

Python prototype (for reference):

read(fn_) -> None
Positional Arguments

Saves the algorithm to a file. In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs).

Python prototype (for reference):

save(filename) -> None

simplified API for language bindings

Positional Arguments
  • fs: Ptr<FileStorage>
Keyword Arguments

Has overloading in C++

Python prototype (for reference):

write(fs[, name]) -> None

simplified API for language bindings

Positional Arguments
  • fs: Ptr<FileStorage>
Keyword Arguments

Has overloading in C++

Python prototype (for reference):

write(fs[, name]) -> None

Link to this section cv.ml

Link to this function

calcError(self, data, test)

View Source

Computes error on the training or test dataset

Positional Arguments
  • data: Ptr<TrainData>.

    the training data

  • test: bool.

    if true, the error is computed over the test subset of the data, otherwise it's computed over the training subset of the data. Please note that if you loaded a completely different dataset to evaluate already trained classifier, you will probably want not to set the test subset at all with TrainData::setTrainTestSplitRatio and specify test=false, so that the error is computed for the whole new set. Yes, this sounds a bit confusing.

Return

The method uses StatModel::predict to compute the error. For regression models the error is computed as RMS, for classifiers - as a percent of missclassified samples (0%-100%).

Python prototype (for reference):

calcError(data, test[, resp]) -> retval, resp
Link to this function

calcError(self, data, test, opts)

View Source

Computes error on the training or test dataset

Positional Arguments
  • data: Ptr<TrainData>.

    the training data

  • test: bool.

    if true, the error is computed over the test subset of the data, otherwise it's computed over the training subset of the data. Please note that if you loaded a completely different dataset to evaluate already trained classifier, you will probably want not to set the test subset at all with TrainData::setTrainTestSplitRatio and specify test=false, so that the error is computed for the whole new set. Yes, this sounds a bit confusing.

Return

The method uses StatModel::predict to compute the error. For regression models the error is computed as RMS, for classifiers - as a percent of missclassified samples (0%-100%).

Python prototype (for reference):

calcError(data, test[, resp]) -> retval, resp

Creates empty model.

Creates Logistic Regression model with parameters given.

Python prototype (for reference):

create() -> retval

Python prototype (for reference):

empty() -> 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.

Python prototype (for reference):

get_learnt_thetas() -> retval

@see setIterations

Python prototype (for reference):

getIterations() -> retval

@see setLearningRate

Python prototype (for reference):

getLearningRate() -> retval

@see setMiniBatchSize

Python prototype (for reference):

getMiniBatchSize() -> retval

@see setRegularization

Python prototype (for reference):

getRegularization() -> retval

@see setTermCriteria

Python prototype (for reference):

getTermCriteria() -> retval

@see setTrainMethod

Python prototype (for reference):

getTrainMethod() -> retval

Returns the number of variables in training samples

Python prototype (for reference):

getVarCount() -> retval

Returns true if the model is classifier

Python prototype (for reference):

isClassifier() -> retval

Returns true if the model is trained

Python prototype (for reference):

isTrained() -> retval

Loads and creates a serialized LogisticRegression from a file

Positional Arguments
  • filepath: String.

    path to serialized LogisticRegression

Keyword Arguments
  • nodeName: String.

    name of node containing the classifier

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

Python prototype (for reference):

load(filepath[, nodeName]) -> retval

Loads and creates a serialized LogisticRegression from a file

Positional Arguments
  • filepath: String.

    path to serialized LogisticRegression

Keyword Arguments
  • nodeName: String.

    name of node containing the classifier

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

Python prototype (for reference):

load(filepath[, nodeName]) -> retval

Predicts responses for input samples and returns a float type.

Positional Arguments
  • samples: Evision.Mat.

    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.

Keyword Arguments
  • flags: int.

    Not used.

Return
  • results: Evision.Mat.

    Predicted labels as a column matrix of type CV_32S.

Python prototype (for reference):

predict(samples[, results[, flags]]) -> retval, results
Link to this function

predict(self, samples, opts)

View Source

Predicts responses for input samples and returns a float type.

Positional Arguments
  • samples: Evision.Mat.

    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.

Keyword Arguments
  • flags: int.

    Not used.

Return
  • results: Evision.Mat.

    Predicted labels as a column matrix of type CV_32S.

Python prototype (for reference):

predict(samples[, results[, flags]]) -> retval, results
Link to this function

setIterations(self, val)

View Source
Positional Arguments
  • val: int

@copybrief getIterations @see getIterations

Python prototype (for reference):

setIterations(val) -> None
Link to this function

setLearningRate(self, val)

View Source
Positional Arguments
  • val: double

@copybrief getLearningRate @see getLearningRate

Python prototype (for reference):

setLearningRate(val) -> None
Link to this function

setMiniBatchSize(self, val)

View Source
Positional Arguments
  • val: int

@copybrief getMiniBatchSize @see getMiniBatchSize

Python prototype (for reference):

setMiniBatchSize(val) -> None
Link to this function

setRegularization(self, val)

View Source
Positional Arguments
  • val: int

@copybrief getRegularization @see getRegularization

Python prototype (for reference):

setRegularization(val) -> None
Link to this function

setTermCriteria(self, val)

View Source
Positional Arguments
  • val: TermCriteria

@copybrief getTermCriteria @see getTermCriteria

Python prototype (for reference):

setTermCriteria(val) -> None
Link to this function

setTrainMethod(self, val)

View Source
Positional Arguments
  • val: int

@copybrief getTrainMethod @see getTrainMethod

Python prototype (for reference):

setTrainMethod(val) -> None

Trains the statistical model

Positional Arguments
  • trainData: Ptr<TrainData>.

    training data that can be loaded from file using TrainData::loadFromCSV or created with TrainData::create.

Keyword Arguments
  • flags: int.

    optional flags, depending on the model. Some of the models can be updated with the new training samples, not completely overwritten (such as NormalBayesClassifier or ANN_MLP).

Python prototype (for reference):

train(trainData[, flags]) -> retval
Link to this function

train(self, trainData, opts)

View Source

Trains the statistical model

Positional Arguments
  • trainData: Ptr<TrainData>.

    training data that can be loaded from file using TrainData::loadFromCSV or created with TrainData::create.

Keyword Arguments
  • flags: int.

    optional flags, depending on the model. Some of the models can be updated with the new training samples, not completely overwritten (such as NormalBayesClassifier or ANN_MLP).

Python prototype (for reference):

train(trainData[, flags]) -> retval
Link to this function

train(self, samples, layout, responses)

View Source

Trains the statistical model

Positional Arguments
  • samples: Evision.Mat.

    training samples

  • layout: int.

    See ml::SampleTypes.

  • responses: Evision.Mat.

    vector of responses associated with the training samples.

Python prototype (for reference):

train(samples, layout, responses) -> retval

Link to this section Functions

Link to this function

calcError!(self, data, test)

View Source

Raising version of calcError/3.

Link to this function

calcError!(self, data, test, opts)

View Source

Raising version of calcError/4.

Raising version of clear/1.

Raising version of create/0.

Raising version of empty/1.

Link to this function

get_learnt_thetas!(self)

View Source

Raising version of get_learnt_thetas/1.

Raising version of getDefaultName/1.

Raising version of getIterations/1.

Raising version of getLearningRate/1.

Raising version of getMiniBatchSize/1.

Link to this function

getRegularization!(self)

View Source

Raising version of getRegularization/1.

Raising version of getTermCriteria/1.

Raising version of getTrainMethod/1.

Raising version of getVarCount/1.

Raising version of isClassifier/1.

Raising version of isTrained/1.

Raising version of load/1.

Raising version of load/2.

Raising version of predict/2.

Link to this function

predict!(self, samples, opts)

View Source

Raising version of predict/3.

Raising version of read/2.

Raising version of save/2.

Link to this function

setIterations!(self, val)

View Source

Raising version of setIterations/2.

Link to this function

setLearningRate!(self, val)

View Source

Raising version of setLearningRate/2.

Link to this function

setMiniBatchSize!(self, val)

View Source

Raising version of setMiniBatchSize/2.

Link to this function

setRegularization!(self, val)

View Source

Raising version of setRegularization/2.

Link to this function

setTermCriteria!(self, val)

View Source

Raising version of setTermCriteria/2.

Link to this function

setTrainMethod!(self, val)

View Source

Raising version of setTrainMethod/2.

Raising version of train/2.

Link to this function

train!(self, trainData, opts)

View Source

Raising version of train/3.

Link to this function

train!(self, samples, layout, responses)

View Source

Raising version of train/4.

Raising version of write/2.

Raising version of write/3.