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

Summary

Types

t()

Type that represents an ML.TrainData struct.

Functions

Creates training data from in-memory arrays.

Creates training data from in-memory arrays.

getCatCount

Returns the vector of class labels

getDefaultSubstValues

Returns vector of symbolic names captured in loadFromCSV()

getNormCatResponses

getNTestSamples

getNTrainSamples

getResponseType

getSampleWeights

Extract from matrix rows/cols specified by passed indexes.

Extract from 1D vector elements specified by passed indexes.

getTestNormCatResponses

getTestResponses

getTestSampleIdx

Returns matrix of test samples

getTestSampleWeights

Returns the vector of normalized categorical responses

Returns the vector of responses

getTrainSampleIdx

Returns matrix of train samples

Returns matrix of train samples

getTrainSampleWeights

getVarSymbolFlags

Splits the training data into the training and test parts

Splits the training data into the training and test parts

Splits the training data into the training and test parts

Splits the training data into the training and test parts

shuffleTrainTest

Types

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

Type that represents an ML.TrainData struct.

  • ref. reference()

    The underlying erlang resource variable.

Functions

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

create(samples, layout, responses)

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

Creates training data from in-memory arrays.

Positional Arguments
  • samples: Evision.Mat.

    matrix of samples. It should have CV_32F type.

  • layout: integer().

    see ml::SampleTypes.

  • responses: Evision.Mat.

    matrix of responses. If the responses are scalar, they should be stored as a single row or as a single column. The matrix should have type CV_32F or CV_32S (in the former case the responses are considered as ordered by default; in the latter case - as categorical)

Keyword Arguments
  • varIdx: Evision.Mat.

    vector specifying which variables to use for training. It can be an integer vector (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of active variables.

  • sampleIdx: Evision.Mat.

    vector specifying which samples to use for training. It can be an integer vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask of training samples.

  • sampleWeights: Evision.Mat.

    optional vector with weights for each sample. It should have CV_32F type.

  • varType: Evision.Mat.

    optional vector of type CV_8U and size <number_of_variables_in_samples> + <number_of_variables_in_responses>, containing types of each input and output variable. See ml::VariableTypes.

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

Python prototype (for reference only):

create(samples, layout, responses[, varIdx[, sampleIdx[, sampleWeights[, varType]]]]) -> retval
Link to this function

create(samples, layout, responses, opts)

View Source
@spec create(
  Evision.Mat.maybe_mat_in(),
  integer(),
  Evision.Mat.maybe_mat_in(),
  [sampleIdx: term(), sampleWeights: term(), varIdx: term(), varType: term()]
  | nil
) :: t() | {:error, String.t()}

Creates training data from in-memory arrays.

Positional Arguments
  • samples: Evision.Mat.

    matrix of samples. It should have CV_32F type.

  • layout: integer().

    see ml::SampleTypes.

  • responses: Evision.Mat.

    matrix of responses. If the responses are scalar, they should be stored as a single row or as a single column. The matrix should have type CV_32F or CV_32S (in the former case the responses are considered as ordered by default; in the latter case - as categorical)

Keyword Arguments
  • varIdx: Evision.Mat.

    vector specifying which variables to use for training. It can be an integer vector (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of active variables.

  • sampleIdx: Evision.Mat.

    vector specifying which samples to use for training. It can be an integer vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask of training samples.

  • sampleWeights: Evision.Mat.

    optional vector with weights for each sample. It should have CV_32F type.

  • varType: Evision.Mat.

    optional vector of type CV_8U and size <number_of_variables_in_samples> + <number_of_variables_in_responses>, containing types of each input and output variable. See ml::VariableTypes.

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

Python prototype (for reference only):

create(samples, layout, responses[, varIdx[, sampleIdx[, sampleWeights[, varType]]]]) -> retval
@spec getCatCount(Keyword.t()) :: any() | {:error, String.t()}
@spec getCatCount(t(), integer()) :: integer() | {:error, String.t()}

getCatCount

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

Python prototype (for reference only):

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

getCatMap

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

Python prototype (for reference only):

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

getCatOfs

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

Python prototype (for reference only):

getCatOfs() -> retval
Link to this function

getClassLabels(named_args)

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

Returns the vector of class labels

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

The function returns vector of unique labels occurred in the responses.

Python prototype (for reference only):

getClassLabels() -> retval
Link to this function

getDefaultSubstValues(named_args)

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

getDefaultSubstValues

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

Python prototype (for reference only):

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

getLayout

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

Python prototype (for reference only):

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

getMissing

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

Python prototype (for reference only):

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

getNAllVars

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

Python prototype (for reference only):

getNAllVars() -> retval
@spec getNames(Keyword.t()) :: any() | {:error, String.t()}
@spec getNames(t(), [binary()]) :: t() | {:error, String.t()}

Returns vector of symbolic names captured in loadFromCSV()

Positional Arguments
  • self: Evision.ML.TrainData.t()
  • names: [String]

Python prototype (for reference only):

getNames(names) -> None
Link to this function

getNormCatResponses(named_args)

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

getNormCatResponses

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

Python prototype (for reference only):

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

getNSamples

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

Python prototype (for reference only):

getNSamples() -> retval
Link to this function

getNTestSamples(named_args)

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

getNTestSamples

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

Python prototype (for reference only):

getNTestSamples() -> retval
Link to this function

getNTrainSamples(named_args)

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

getNTrainSamples

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

Python prototype (for reference only):

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

getNVars

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

Python prototype (for reference only):

getNVars() -> retval
Link to this function

getResponses(named_args)

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

getResponses

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

Python prototype (for reference only):

getResponses() -> retval
Link to this function

getResponseType(named_args)

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

getResponseType

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

Python prototype (for reference only):

getResponseType() -> retval
@spec getSample(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

getSample(self, varIdx, sidx, buf)

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

getSample

Positional Arguments
  • self: Evision.ML.TrainData.t()
  • varIdx: Evision.Mat
  • sidx: integer()
  • buf: float*

Python prototype (for reference only):

getSample(varIdx, sidx, buf) -> None
@spec getSamples(Keyword.t()) :: any() | {:error, String.t()}
@spec getSamples(t()) :: Evision.Mat.t() | {:error, String.t()}

getSamples

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

Python prototype (for reference only):

getSamples() -> retval
Link to this function

getSampleWeights(named_args)

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

getSampleWeights

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

Python prototype (for reference only):

getSampleWeights() -> retval
Link to this function

getSubMatrix(named_args)

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

getSubMatrix(matrix, idx, layout)

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

Extract from matrix rows/cols specified by passed indexes.

Positional Arguments
  • matrix: Evision.Mat.

    input matrix (supported types: CV_32S, CV_32F, CV_64F)

  • idx: Evision.Mat.

    1D index vector

  • layout: integer().

    specifies to extract rows (cv::ml::ROW_SAMPLES) or to extract columns (cv::ml::COL_SAMPLES)

Return
  • retval: Evision.Mat.t()

Python prototype (for reference only):

getSubMatrix(matrix, idx, layout) -> retval
Link to this function

getSubVector(named_args)

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

Extract from 1D vector elements specified by passed indexes.

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

Python prototype (for reference only):

getSubVector(vec, idx) -> retval
Link to this function

getTestNormCatResponses(named_args)

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

getTestNormCatResponses

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

Python prototype (for reference only):

getTestNormCatResponses() -> retval
Link to this function

getTestResponses(named_args)

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

getTestResponses

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

Python prototype (for reference only):

getTestResponses() -> retval
Link to this function

getTestSampleIdx(named_args)

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

getTestSampleIdx

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

Python prototype (for reference only):

getTestSampleIdx() -> retval
Link to this function

getTestSamples(named_args)

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

Returns matrix of test samples

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

Python prototype (for reference only):

getTestSamples() -> retval
Link to this function

getTestSampleWeights(named_args)

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

getTestSampleWeights

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

Python prototype (for reference only):

getTestSampleWeights() -> retval
Link to this function

getTrainNormCatResponses(named_args)

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

Returns the vector of normalized categorical responses

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

The function returns vector of responses. Each response is integer from 0 to <number of classes>-1. The actual label value can be retrieved then from the class label vector, see TrainData::getClassLabels.

Python prototype (for reference only):

getTrainNormCatResponses() -> retval
Link to this function

getTrainResponses(named_args)

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

Returns the vector of responses

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

The function returns ordered or the original categorical responses. Usually it's used in regression algorithms.

Python prototype (for reference only):

getTrainResponses() -> retval
Link to this function

getTrainSampleIdx(named_args)

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

getTrainSampleIdx

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

Python prototype (for reference only):

getTrainSampleIdx() -> retval
Link to this function

getTrainSamples(named_args)

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

Returns matrix of train samples

Positional Arguments
  • self: Evision.ML.TrainData.t()
Keyword Arguments
  • layout: integer().

    The requested layout. If it's different from the initial one, the matrix is transposed. See ml::SampleTypes.

  • compressSamples: bool.

    if true, the function returns only the training samples (specified by sampleIdx)

  • compressVars: bool.

    if true, the function returns the shorter training samples, containing only the active variables.

Return
  • retval: Evision.Mat.t()

In current implementation the function tries to avoid physical data copying and returns the matrix stored inside TrainData (unless the transposition or compression is needed).

Python prototype (for reference only):

getTrainSamples([, layout[, compressSamples[, compressVars]]]) -> retval
Link to this function

getTrainSamples(self, opts)

View Source
@spec getTrainSamples(
  t(),
  [compressSamples: term(), compressVars: term(), layout: term()] | nil
) ::
  Evision.Mat.t() | {:error, String.t()}

Returns matrix of train samples

Positional Arguments
  • self: Evision.ML.TrainData.t()
Keyword Arguments
  • layout: integer().

    The requested layout. If it's different from the initial one, the matrix is transposed. See ml::SampleTypes.

  • compressSamples: bool.

    if true, the function returns only the training samples (specified by sampleIdx)

  • compressVars: bool.

    if true, the function returns the shorter training samples, containing only the active variables.

Return
  • retval: Evision.Mat.t()

In current implementation the function tries to avoid physical data copying and returns the matrix stored inside TrainData (unless the transposition or compression is needed).

Python prototype (for reference only):

getTrainSamples([, layout[, compressSamples[, compressVars]]]) -> retval
Link to this function

getTrainSampleWeights(named_args)

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

getTrainSampleWeights

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

Python prototype (for reference only):

getTrainSampleWeights() -> retval
@spec getValues(Keyword.t()) :: any() | {:error, String.t()}
Link to this function

getValues(self, vi, sidx, values)

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

getValues

Positional Arguments
  • self: Evision.ML.TrainData.t()
  • vi: integer()
  • sidx: Evision.Mat
  • values: float*

Python prototype (for reference only):

getValues(vi, sidx, values) -> None
@spec getVarIdx(Keyword.t()) :: any() | {:error, String.t()}
@spec getVarIdx(t()) :: Evision.Mat.t() | {:error, String.t()}

getVarIdx

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

Python prototype (for reference only):

getVarIdx() -> retval
Link to this function

getVarSymbolFlags(named_args)

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

getVarSymbolFlags

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

Python prototype (for reference only):

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

getVarType

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

Python prototype (for reference only):

getVarType() -> retval
Link to this function

setTrainTestSplit(named_args)

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

setTrainTestSplit(self, count)

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

Splits the training data into the training and test parts

Positional Arguments
  • self: Evision.ML.TrainData.t()
  • count: integer()
Keyword Arguments
  • shuffle: bool.

@sa TrainData::setTrainTestSplitRatio

Python prototype (for reference only):

setTrainTestSplit(count[, shuffle]) -> None
Link to this function

setTrainTestSplit(self, count, opts)

View Source
@spec setTrainTestSplit(t(), integer(), [{:shuffle, term()}] | nil) ::
  t() | {:error, String.t()}

Splits the training data into the training and test parts

Positional Arguments
  • self: Evision.ML.TrainData.t()
  • count: integer()
Keyword Arguments
  • shuffle: bool.

@sa TrainData::setTrainTestSplitRatio

Python prototype (for reference only):

setTrainTestSplit(count[, shuffle]) -> None
Link to this function

setTrainTestSplitRatio(named_args)

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

setTrainTestSplitRatio(self, ratio)

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

Splits the training data into the training and test parts

Positional Arguments
  • self: Evision.ML.TrainData.t()
  • ratio: double
Keyword Arguments
  • shuffle: bool.

The function selects a subset of specified relative size and then returns it as the training set. If the function is not called, all the data is used for training. Please, note that for each of TrainData::getTrain* there is corresponding TrainData::getTest*, so that the test subset can be retrieved and processed as well. @sa TrainData::setTrainTestSplit

Python prototype (for reference only):

setTrainTestSplitRatio(ratio[, shuffle]) -> None
Link to this function

setTrainTestSplitRatio(self, ratio, opts)

View Source
@spec setTrainTestSplitRatio(t(), number(), [{:shuffle, term()}] | nil) ::
  t() | {:error, String.t()}

Splits the training data into the training and test parts

Positional Arguments
  • self: Evision.ML.TrainData.t()
  • ratio: double
Keyword Arguments
  • shuffle: bool.

The function selects a subset of specified relative size and then returns it as the training set. If the function is not called, all the data is used for training. Please, note that for each of TrainData::getTrain* there is corresponding TrainData::getTest*, so that the test subset can be retrieved and processed as well. @sa TrainData::setTrainTestSplit

Python prototype (for reference only):

setTrainTestSplitRatio(ratio[, shuffle]) -> None
Link to this function

shuffleTrainTest(named_args)

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

shuffleTrainTest

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

Python prototype (for reference only):

shuffleTrainTest() -> None