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

Summary

Types

t()

Type that represents an ML.SVMSGD 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. Use StatModel::train to train the model. Since %SVMSGD has several parameters, you may want to find the best parameters for your problem or use setOptimalParameters() to set some default parameters.

getInitialStepSize

getMarginRegularization

getStepDecreasingPower

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 SVMSGD from a file

Loads and creates a serialized SVMSGD from a file

Predicts response(s) for the provided sample(s)

Predicts response(s) for the provided sample(s)

Reads algorithm parameters from a file storage

Function sets optimal parameters values for chosen SVM SGD model.

Function sets optimal parameters values for chosen SVM SGD model.

setTermCriteria

Trains the statistical model

Trains the statistical model

Trains the statistical model

Stores algorithm parameters in a file storage

Types

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

Type that represents an ML.SVMSGD 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.SVMSGD.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.SVMSGD.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.SVMSGD.t()

Python prototype (for reference only):

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

Creates empty model. Use StatModel::train to train the model. Since %SVMSGD has several parameters, you may want to find the best parameters for your problem or use setOptimalParameters() to set some default parameters.

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

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.SVMSGD.t()
Return
  • retval: bool

Python prototype (for reference only):

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

getInitialStepSize(named_args)

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

getInitialStepSize

Positional Arguments
  • self: Evision.ML.SVMSGD.t()
Return
  • retval: float

@see setInitialStepSize/2

Python prototype (for reference only):

getInitialStepSize() -> retval
Link to this function

getMarginRegularization(named_args)

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

getMarginRegularization

Positional Arguments
  • self: Evision.ML.SVMSGD.t()
Return
  • retval: float

@see setMarginRegularization/2

Python prototype (for reference only):

getMarginRegularization() -> retval
Link to this function

getMarginType(named_args)

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

getMarginType

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

@see setMarginType/2

Python prototype (for reference only):

getMarginType() -> retval
@spec getShift(Keyword.t()) :: any() | {:error, String.t()}
@spec getShift(t()) :: number() | {:error, String.t()}

getShift

Positional Arguments
  • self: Evision.ML.SVMSGD.t()
Return
  • retval: float

@return the shift of the trained model (decision function f(x) = weights * x + shift).

Python prototype (for reference only):

getShift() -> retval
Link to this function

getStepDecreasingPower(named_args)

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

getStepDecreasingPower

Positional Arguments
  • self: Evision.ML.SVMSGD.t()
Return
  • retval: float

@see setStepDecreasingPower/2

Python prototype (for reference only):

getStepDecreasingPower() -> retval
Link to this function

getSvmsgdType(named_args)

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

getSvmsgdType

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

@see setSvmsgdType/2

Python prototype (for reference only):

getSvmsgdType() -> 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.SVMSGD.t()
Return
  • retval: TermCriteria

@see setTermCriteria/2

Python prototype (for reference only):

getTermCriteria() -> 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.SVMSGD.t()
Return
  • retval: integer()

Python prototype (for reference only):

getVarCount() -> retval
@spec getWeights(Keyword.t()) :: any() | {:error, String.t()}
@spec getWeights(t()) :: Evision.Mat.t() | {:error, String.t()}

getWeights

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

@return the weights of the trained model (decision function f(x) = weights * x + shift).

Python prototype (for reference only):

getWeights() -> 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.SVMSGD.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.SVMSGD.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 SVMSGD from a file

Positional Arguments
  • filepath: String.

    path to serialized SVMSGD

Keyword Arguments
  • nodeName: String.

    name of node containing the classifier

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

Use SVMSGD::save to serialize and store an SVMSGD to disk. Load the SVMSGD 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 SVMSGD from a file

Positional Arguments
  • filepath: String.

    path to serialized SVMSGD

Keyword Arguments
  • nodeName: String.

    name of node containing the classifier

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

Use SVMSGD::save to serialize and store an SVMSGD to disk. Load the SVMSGD 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 response(s) for the provided sample(s)

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

  • samples: Evision.Mat.

    The input samples, floating-point matrix

Keyword Arguments
  • flags: integer().

    The optional flags, model-dependent. See cv::ml::StatModel::Flags.

Return
  • retval: float

  • results: Evision.Mat.t().

    The optional output matrix of results.

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 response(s) for the provided sample(s)

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

  • samples: Evision.Mat.

    The input samples, floating-point matrix

Keyword Arguments
  • flags: integer().

    The optional flags, model-dependent. See cv::ml::StatModel::Flags.

Return
  • retval: float

  • results: Evision.Mat.t().

    The optional output matrix of results.

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

setInitialStepSize(named_args)

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

setInitialStepSize(self, initialStepSize)

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

setInitialStepSize

Positional Arguments
  • self: Evision.ML.SVMSGD.t()
  • initialStepSize: float

@see getInitialStepSize/1

Python prototype (for reference only):

setInitialStepSize(InitialStepSize) -> None
Link to this function

setMarginRegularization(named_args)

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

setMarginRegularization(self, marginRegularization)

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

setMarginRegularization

Positional Arguments
  • self: Evision.ML.SVMSGD.t()
  • marginRegularization: float

@see getMarginRegularization/1

Python prototype (for reference only):

setMarginRegularization(marginRegularization) -> None
Link to this function

setMarginType(named_args)

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

setMarginType(self, marginType)

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

setMarginType

Positional Arguments
  • self: Evision.ML.SVMSGD.t()
  • marginType: integer()

@see getMarginType/1

Python prototype (for reference only):

setMarginType(marginType) -> None
Link to this function

setOptimalParameters(named_args)

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

Function sets optimal parameters values for chosen SVM SGD model.

Positional Arguments
  • self: Evision.ML.SVMSGD.t()
Keyword Arguments
  • svmsgdType: integer().

    is the type of SVMSGD classifier.

  • marginType: integer().

    is the type of margin constraint.

Python prototype (for reference only):

setOptimalParameters([, svmsgdType[, marginType]]) -> None
Link to this function

setOptimalParameters(self, opts)

View Source
@spec setOptimalParameters(t(), [marginType: term(), svmsgdType: term()] | nil) ::
  t() | {:error, String.t()}

Function sets optimal parameters values for chosen SVM SGD model.

Positional Arguments
  • self: Evision.ML.SVMSGD.t()
Keyword Arguments
  • svmsgdType: integer().

    is the type of SVMSGD classifier.

  • marginType: integer().

    is the type of margin constraint.

Python prototype (for reference only):

setOptimalParameters([, svmsgdType[, marginType]]) -> None
Link to this function

setStepDecreasingPower(named_args)

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

setStepDecreasingPower(self, stepDecreasingPower)

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

setStepDecreasingPower

Positional Arguments
  • self: Evision.ML.SVMSGD.t()
  • stepDecreasingPower: float

@see getStepDecreasingPower/1

Python prototype (for reference only):

setStepDecreasingPower(stepDecreasingPower) -> None
Link to this function

setSvmsgdType(named_args)

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

setSvmsgdType(self, svmsgdType)

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

setSvmsgdType

Positional Arguments
  • self: Evision.ML.SVMSGD.t()
  • svmsgdType: integer()

@see getSvmsgdType/1

Python prototype (for reference only):

setSvmsgdType(svmsgdType) -> 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.SVMSGD.t()
  • val: TermCriteria

@see getTermCriteria/1

Python prototype (for reference only):

setTermCriteria(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.SVMSGD.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.SVMSGD.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.SVMSGD.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