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

Summary

Types

t()

Type that represents an ML.LogisticRegression struct.

Functions

Computes error on the training or test dataset

Computes error on the training or test dataset

Clears the algorithm state

Creates empty model.

This function returns the trained parameters arranged across rows.

getLearningRate

getMiniBatchSize

getRegularization

getTermCriteria

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.

Reads algorithm parameters from a file storage

setIterations

setLearningRate

setMiniBatchSize

setRegularization

setTermCriteria

setTrainMethod

Trains the statistical model

Trains the statistical model

Trains the statistical model

Stores algorithm parameters in a file storage

Types

@type t() :: %Evision.ML.LogisticRegression{ref: reference()}

Type that represents an ML.LogisticRegression struct.

  • ref. reference()

    The underlying erlang resource variable.

Functions

@spec calcError(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

calcError(self, data, test)

View Source
@spec calcError(t(), Evision.ML.TrainData.t(), boolean()) ::
  {number(), Evision.Mat.t()} | {:error, String.t()}

Computes error on the training or test dataset

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()

  • data: Evision.ML.TrainData.t().

    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
  • retval: float

  • resp: Evision.Mat.t().

    the optional output responses.

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 only):

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

calcError(self, data, test, opts)

View Source
@spec calcError(
  t(),
  Evision.ML.TrainData.t(),
  boolean(),
  [{atom(), term()}, ...] | nil
) ::
  {number(), Evision.Mat.t()} | {:error, String.t()}

Computes error on the training or test dataset

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()

  • data: Evision.ML.TrainData.t().

    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
  • retval: float

  • resp: Evision.Mat.t().

    the optional output responses.

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 only):

calcError(data, test[, resp]) -> retval, resp
@spec clear(Keyword.t()) :: any() | {:error, String.t()}
@spec clear(t()) :: t() | {:error, String.t()}

Clears the algorithm state

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()

Python prototype (for reference only):

clear() -> None
@spec create() :: t() | {:error, String.t()}

Creates empty model.

Return
  • retval: Evision.ML.LogisticRegression.t()

Creates Logistic Regression model with parameters given.

Python prototype (for reference only):

create() -> retval
@spec create(Keyword.t()) :: any() | {:error, String.t()}
@spec empty(Keyword.t()) :: any() | {:error, String.t()}
@spec empty(t()) :: boolean() | {:error, String.t()}

empty

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
Return
  • retval: bool

Python prototype (for reference only):

empty() -> retval
Link to this function

get_learnt_thetas(named_args)

View Source
@spec get_learnt_thetas(Keyword.t()) :: any() | {:error, String.t()}
@spec get_learnt_thetas(t()) :: Evision.Mat.t() | {:error, String.t()}

This function returns the trained parameters arranged across rows.

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
Return
  • retval: Evision.Mat.t()

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 only):

get_learnt_thetas() -> retval
Link to this function

getDefaultName(named_args)

View Source
@spec getDefaultName(Keyword.t()) :: any() | {:error, String.t()}
@spec getDefaultName(t()) :: binary() | {:error, String.t()}

getDefaultName

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
Return

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 only):

getDefaultName() -> retval
Link to this function

getIterations(named_args)

View Source
@spec getIterations(Keyword.t()) :: any() | {:error, String.t()}
@spec getIterations(t()) :: integer() | {:error, String.t()}

getIterations

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
Return
  • retval: integer()

@see setIterations/2

Python prototype (for reference only):

getIterations() -> retval
Link to this function

getLearningRate(named_args)

View Source
@spec getLearningRate(Keyword.t()) :: any() | {:error, String.t()}
@spec getLearningRate(t()) :: number() | {:error, String.t()}

getLearningRate

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
Return
  • retval: double

@see setLearningRate/2

Python prototype (for reference only):

getLearningRate() -> retval
Link to this function

getMiniBatchSize(named_args)

View Source
@spec getMiniBatchSize(Keyword.t()) :: any() | {:error, String.t()}
@spec getMiniBatchSize(t()) :: integer() | {:error, String.t()}

getMiniBatchSize

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
Return
  • retval: integer()

@see setMiniBatchSize/2

Python prototype (for reference only):

getMiniBatchSize() -> retval
Link to this function

getRegularization(named_args)

View Source
@spec getRegularization(Keyword.t()) :: any() | {:error, String.t()}
@spec getRegularization(t()) :: integer() | {:error, String.t()}

getRegularization

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
Return
  • retval: integer()

@see setRegularization/2

Python prototype (for reference only):

getRegularization() -> retval
Link to this function

getTermCriteria(named_args)

View Source
@spec getTermCriteria(Keyword.t()) :: any() | {:error, String.t()}
@spec getTermCriteria(t()) :: {integer(), integer(), number()} | {:error, String.t()}

getTermCriteria

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
Return
  • retval: TermCriteria

@see setTermCriteria/2

Python prototype (for reference only):

getTermCriteria() -> retval
Link to this function

getTrainMethod(named_args)

View Source
@spec getTrainMethod(Keyword.t()) :: any() | {:error, String.t()}
@spec getTrainMethod(t()) :: integer() | {:error, String.t()}

getTrainMethod

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
Return
  • retval: integer()

@see setTrainMethod/2

Python prototype (for reference only):

getTrainMethod() -> retval
@spec getVarCount(Keyword.t()) :: any() | {:error, String.t()}
@spec getVarCount(t()) :: integer() | {:error, String.t()}

Returns the number of variables in training samples

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
Return
  • retval: integer()

Python prototype (for reference only):

getVarCount() -> retval
Link to this function

isClassifier(named_args)

View Source
@spec isClassifier(Keyword.t()) :: any() | {:error, String.t()}
@spec isClassifier(t()) :: boolean() | {:error, String.t()}

Returns true if the model is classifier

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
Return
  • retval: bool

Python prototype (for reference only):

isClassifier() -> retval
@spec isTrained(Keyword.t()) :: any() | {:error, String.t()}
@spec isTrained(t()) :: boolean() | {:error, String.t()}

Returns true if the model is trained

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
Return
  • retval: bool

Python prototype (for reference only):

isTrained() -> retval
@spec load(Keyword.t()) :: any() | {:error, String.t()}
@spec load(binary()) :: t() | {:error, String.t()}

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

Return
  • retval: Evision.ML.LogisticRegression.t()

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 only):

load(filepath[, nodeName]) -> retval
@spec load(binary(), [{:nodeName, term()}] | nil) :: t() | {:error, String.t()}

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

Return
  • retval: Evision.ML.LogisticRegression.t()

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 only):

load(filepath[, nodeName]) -> retval
@spec predict(Keyword.t()) :: any() | {:error, String.t()}
@spec predict(t(), Evision.Mat.maybe_mat_in()) ::
  {number(), Evision.Mat.t()} | {:error, String.t()}

Predicts responses for input samples and returns a float type.

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()

  • 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: integer().

    Not used.

Return
  • retval: float

  • results: Evision.Mat.t().

    Predicted labels as a column matrix of type CV_32S.

Python prototype (for reference only):

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

predict(self, samples, opts)

View Source
@spec predict(t(), Evision.Mat.maybe_mat_in(), [{:flags, term()}] | nil) ::
  {number(), Evision.Mat.t()} | {:error, String.t()}

Predicts responses for input samples and returns a float type.

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()

  • 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: integer().

    Not used.

Return
  • retval: float

  • results: Evision.Mat.t().

    Predicted labels as a column matrix of type CV_32S.

Python prototype (for reference only):

predict(samples[, results[, flags]]) -> retval, results
@spec read(Keyword.t()) :: any() | {:error, String.t()}
@spec read(t(), Evision.FileNode.t()) :: t() | {:error, String.t()}

Reads algorithm parameters from a file storage

Positional Arguments

Python prototype (for reference only):

read(fn) -> None
@spec save(Keyword.t()) :: any() | {:error, String.t()}
@spec save(t(), binary()) :: t() | {:error, String.t()}

save

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
  • filename: String

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 only):

save(filename) -> None
Link to this function

setIterations(named_args)

View Source
@spec setIterations(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

setIterations(self, val)

View Source
@spec setIterations(t(), integer()) :: t() | {:error, String.t()}

setIterations

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
  • val: integer()

@see getIterations/1

Python prototype (for reference only):

setIterations(val) -> None
Link to this function

setLearningRate(named_args)

View Source
@spec setLearningRate(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

setLearningRate(self, val)

View Source
@spec setLearningRate(t(), number()) :: t() | {:error, String.t()}

setLearningRate

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
  • val: double

@see getLearningRate/1

Python prototype (for reference only):

setLearningRate(val) -> None
Link to this function

setMiniBatchSize(named_args)

View Source
@spec setMiniBatchSize(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

setMiniBatchSize(self, val)

View Source
@spec setMiniBatchSize(t(), integer()) :: t() | {:error, String.t()}

setMiniBatchSize

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
  • val: integer()

@see getMiniBatchSize/1

Python prototype (for reference only):

setMiniBatchSize(val) -> None
Link to this function

setRegularization(named_args)

View Source
@spec setRegularization(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

setRegularization(self, val)

View Source
@spec setRegularization(t(), integer()) :: t() | {:error, String.t()}

setRegularization

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
  • val: integer()

@see getRegularization/1

Python prototype (for reference only):

setRegularization(val) -> None
Link to this function

setTermCriteria(named_args)

View Source
@spec setTermCriteria(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

setTermCriteria(self, val)

View Source
@spec setTermCriteria(t(), {integer(), integer(), number()}) ::
  t() | {:error, String.t()}

setTermCriteria

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
  • val: TermCriteria

@see getTermCriteria/1

Python prototype (for reference only):

setTermCriteria(val) -> None
Link to this function

setTrainMethod(named_args)

View Source
@spec setTrainMethod(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

setTrainMethod(self, val)

View Source
@spec setTrainMethod(t(), integer()) :: t() | {:error, String.t()}

setTrainMethod

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()
  • val: integer()

@see getTrainMethod/1

Python prototype (for reference only):

setTrainMethod(val) -> None
@spec train(Keyword.t()) :: any() | {:error, String.t()}
@spec train(t(), Evision.ML.TrainData.t()) :: boolean() | {:error, String.t()}

Trains the statistical model

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()

  • trainData: Evision.ML.TrainData.t().

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

Keyword Arguments
  • flags: integer().

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

Return
  • retval: bool

Python prototype (for reference only):

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

train(self, trainData, opts)

View Source
@spec train(t(), Evision.ML.TrainData.t(), [{:flags, term()}] | nil) ::
  boolean() | {:error, String.t()}

Trains the statistical model

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()

  • trainData: Evision.ML.TrainData.t().

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

Keyword Arguments
  • flags: integer().

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

Return
  • retval: bool

Python prototype (for reference only):

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

train(self, samples, layout, responses)

View Source
@spec train(t(), Evision.Mat.maybe_mat_in(), integer(), Evision.Mat.maybe_mat_in()) ::
  boolean() | {:error, String.t()}

Trains the statistical model

Positional Arguments
  • self: Evision.ML.LogisticRegression.t()

  • samples: Evision.Mat.

    training samples

  • layout: integer().

    See ml::SampleTypes.

  • responses: Evision.Mat.

    vector of responses associated with the training samples.

Return
  • retval: bool

Python prototype (for reference only):

train(samples, layout, responses) -> retval
@spec write(Keyword.t()) :: any() | {:error, String.t()}
@spec write(t(), Evision.FileStorage.t()) :: t() | {:error, String.t()}

Stores algorithm parameters in a file storage

Positional Arguments

Python prototype (for reference only):

write(fs) -> None
@spec write(t(), Evision.FileStorage.t(), binary()) :: t() | {:error, String.t()}

write

Positional Arguments

Has overloading in C++

Python prototype (for reference only):

write(fs, name) -> None