View Source Evision.ML.RTrees (Evision v0.1.8)

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 the empty model. Use StatModel::train to train the model, StatModel::train to create and train the model, Algorithm::load to load the pre-trained model.

Python prototype (for reference):

@see setActiveVarCount

@see setCalculateVarImportance

@see setCVFolds

@see setMaxCategories

@see setMaxDepth

@see setMinSampleCount

Returns the OOB error value, computed at the training stage when calcOOBError is set to true. If this flag was set to false, 0 is returned. The OOB error is also scaled by sample weighting.

@see setPriors

@see setRegressionAccuracy

@see setTermCriteria

@see setTruncatePrunedTree

@see setUse1SERule

@see setUseSurrogates

Returns the number of variables in training samples

Returns the variable importance array. The method returns the variable importance vector, computed at the training stage when CalculateVarImportance is set to true. If this flag was set to false, the empty matrix is returned.

Positional Arguments
Positional Arguments

Returns true if the model is classifier

Returns true if the model is trained

Loads and creates a serialized RTree from a file

Loads and creates a serialized RTree from a file

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

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

Positional Arguments
  • val: int

@copybrief getActiveVarCount @see getActiveVarCount

Positional Arguments
  • val: bool

@copybrief getCalculateVarImportance @see getCalculateVarImportance

Positional Arguments
  • val: int

@copybrief getCVFolds @see getCVFolds

Positional Arguments
  • val: int

@copybrief getMaxCategories @see getMaxCategories

Positional Arguments
  • val: int

@copybrief getMaxDepth @see getMaxDepth

Positional Arguments
  • val: int

@copybrief getMinSampleCount @see getMinSampleCount

Positional Arguments

@copybrief getPriors @see getPriors

Positional Arguments
  • val: float

@copybrief getRegressionAccuracy @see getRegressionAccuracy

Positional Arguments
  • val: TermCriteria

@copybrief getTermCriteria @see getTermCriteria

Positional Arguments
  • val: bool

@copybrief getTruncatePrunedTree @see getTruncatePrunedTree

Positional Arguments
  • val: bool

@copybrief getUse1SERule @see getUse1SERule

Positional Arguments
  • val: bool

@copybrief getUseSurrogates @see getUseSurrogates

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 getCVFolds/1.

Raising version of getMaxDepth/1.

Raising version of getOOBError/1.

Raising version of getPriors/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 setCVFolds/2.

Raising version of setPriors/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 the empty model. Use StatModel::train to train the model, StatModel::train to create and train the model, Algorithm::load to load the pre-trained model.

Python prototype (for reference):

create() -> retval

Python prototype (for reference):

empty() -> retval

@see setActiveVarCount

Python prototype (for reference):

getActiveVarCount() -> retval
Link to this function

getCalculateVarImportance(self)

View Source

@see setCalculateVarImportance

Python prototype (for reference):

getCalculateVarImportance() -> retval

@see setCVFolds

Python prototype (for reference):

getCVFolds() -> retval

@see setMaxCategories

Python prototype (for reference):

getMaxCategories() -> retval

@see setMaxDepth

Python prototype (for reference):

getMaxDepth() -> retval

@see setMinSampleCount

Python prototype (for reference):

getMinSampleCount() -> retval

Returns the OOB error value, computed at the training stage when calcOOBError is set to true. If this flag was set to false, 0 is returned. The OOB error is also scaled by sample weighting.

Python prototype (for reference):

getOOBError() -> retval

@see setPriors

Python prototype (for reference):

getPriors() -> retval
Link to this function

getRegressionAccuracy(self)

View Source

@see setRegressionAccuracy

Python prototype (for reference):

getRegressionAccuracy() -> retval

@see setTermCriteria

Python prototype (for reference):

getTermCriteria() -> retval
Link to this function

getTruncatePrunedTree(self)

View Source

@see setTruncatePrunedTree

Python prototype (for reference):

getTruncatePrunedTree() -> retval

@see setUse1SERule

Python prototype (for reference):

getUse1SERule() -> retval

@see setUseSurrogates

Python prototype (for reference):

getUseSurrogates() -> retval

Returns the number of variables in training samples

Python prototype (for reference):

getVarCount() -> retval

Returns the variable importance array. The method returns the variable importance vector, computed at the training stage when CalculateVarImportance is set to true. If this flag was set to false, the empty matrix is returned.

Python prototype (for reference):

getVarImportance() -> retval
Link to this function

getVotes(self, samples, flags)

View Source
Positional Arguments
  • samples: Evision.Mat.

    Array containing the samples for which votes will be calculated.

  • flags: int.

    Flags for defining the type of RTrees.

Return
  • results: Evision.Mat.

    Array where the result of the calculation will be written.

Returns the result of each individual tree in the forest. In case the model is a regression problem, the method will return each of the trees' results for each of the sample cases. If the model is a classifier, it will return a Mat with samples + 1 rows, where the first row gives the class number and the following rows return the votes each class had for each sample.

Python prototype (for reference):

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

getVotes(self, samples, flags, opts)

View Source
Positional Arguments
  • samples: Evision.Mat.

    Array containing the samples for which votes will be calculated.

  • flags: int.

    Flags for defining the type of RTrees.

Return
  • results: Evision.Mat.

    Array where the result of the calculation will be written.

Returns the result of each individual tree in the forest. In case the model is a regression problem, the method will return each of the trees' results for each of the sample cases. If the model is a classifier, it will return a Mat with samples + 1 rows, where the first row gives the class number and the following rows return the votes each class had for each sample.

Python prototype (for reference):

getVotes(samples, flags[, results]) -> results

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

Positional Arguments
  • filepath: String.

    path to serialized RTree

Keyword Arguments
  • nodeName: String.

    name of node containing the classifier

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

Positional Arguments
  • filepath: String.

    path to serialized RTree

Keyword Arguments
  • nodeName: String.

    name of node containing the classifier

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

Positional Arguments
  • samples: Evision.Mat.

    The input samples, floating-point matrix

Keyword Arguments
  • flags: int.

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

Return
  • results: Evision.Mat.

    The optional output matrix of results.

Python prototype (for reference):

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

predict(self, samples, opts)

View Source

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

Positional Arguments
  • samples: Evision.Mat.

    The input samples, floating-point matrix

Keyword Arguments
  • flags: int.

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

Return
  • results: Evision.Mat.

    The optional output matrix of results.

Python prototype (for reference):

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

setActiveVarCount(self, val)

View Source
Positional Arguments
  • val: int

@copybrief getActiveVarCount @see getActiveVarCount

Python prototype (for reference):

setActiveVarCount(val) -> None
Link to this function

setCalculateVarImportance(self, val)

View Source
Positional Arguments
  • val: bool

@copybrief getCalculateVarImportance @see getCalculateVarImportance

Python prototype (for reference):

setCalculateVarImportance(val) -> None
Positional Arguments
  • val: int

@copybrief getCVFolds @see getCVFolds

Python prototype (for reference):

setCVFolds(val) -> None
Link to this function

setMaxCategories(self, val)

View Source
Positional Arguments
  • val: int

@copybrief getMaxCategories @see getMaxCategories

Python prototype (for reference):

setMaxCategories(val) -> None
Positional Arguments
  • val: int

@copybrief getMaxDepth @see getMaxDepth

Python prototype (for reference):

setMaxDepth(val) -> None
Link to this function

setMinSampleCount(self, val)

View Source
Positional Arguments
  • val: int

@copybrief getMinSampleCount @see getMinSampleCount

Python prototype (for reference):

setMinSampleCount(val) -> None
Positional Arguments

@copybrief getPriors @see getPriors

Python prototype (for reference):

setPriors(val) -> None
Link to this function

setRegressionAccuracy(self, val)

View Source
Positional Arguments
  • val: float

@copybrief getRegressionAccuracy @see getRegressionAccuracy

Python prototype (for reference):

setRegressionAccuracy(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

setTruncatePrunedTree(self, val)

View Source
Positional Arguments
  • val: bool

@copybrief getTruncatePrunedTree @see getTruncatePrunedTree

Python prototype (for reference):

setTruncatePrunedTree(val) -> None
Link to this function

setUse1SERule(self, val)

View Source
Positional Arguments
  • val: bool

@copybrief getUse1SERule @see getUse1SERule

Python prototype (for reference):

setUse1SERule(val) -> None
Link to this function

setUseSurrogates(self, val)

View Source
Positional Arguments
  • val: bool

@copybrief getUseSurrogates @see getUseSurrogates

Python prototype (for reference):

setUseSurrogates(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

getActiveVarCount!(self)

View Source

Raising version of getActiveVarCount/1.

Link to this function

getCalculateVarImportance!(self)

View Source

Raising version of getCalculateVarImportance/1.

Raising version of getCVFolds/1.

Raising version of getDefaultName/1.

Raising version of getMaxCategories/1.

Raising version of getMaxDepth/1.

Link to this function

getMinSampleCount!(self)

View Source

Raising version of getMinSampleCount/1.

Raising version of getOOBError/1.

Raising version of getPriors/1.

Link to this function

getRegressionAccuracy!(self)

View Source

Raising version of getRegressionAccuracy/1.

Raising version of getTermCriteria/1.

Link to this function

getTruncatePrunedTree!(self)

View Source

Raising version of getTruncatePrunedTree/1.

Raising version of getUse1SERule/1.

Raising version of getUseSurrogates/1.

Raising version of getVarCount/1.

Raising version of getVarImportance/1.

Link to this function

getVotes!(self, samples, flags)

View Source

Raising version of getVotes/3.

Link to this function

getVotes!(self, samples, flags, opts)

View Source

Raising version of getVotes/4.

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

setActiveVarCount!(self, val)

View Source

Raising version of setActiveVarCount/2.

Link to this function

setCalculateVarImportance!(self, val)

View Source

Raising version of setCalculateVarImportance/2.

Raising version of setCVFolds/2.

Link to this function

setMaxCategories!(self, val)

View Source

Raising version of setMaxCategories/2.

Raising version of setMaxDepth/2.

Link to this function

setMinSampleCount!(self, val)

View Source

Raising version of setMinSampleCount/2.

Raising version of setPriors/2.

Link to this function

setRegressionAccuracy!(self, val)

View Source

Raising version of setRegressionAccuracy/2.

Link to this function

setTermCriteria!(self, val)

View Source

Raising version of setTermCriteria/2.

Link to this function

setTruncatePrunedTree!(self, val)

View Source

Raising version of setTruncatePrunedTree/2.

Link to this function

setUse1SERule!(self, val)

View Source

Raising version of setUse1SERule/2.

Link to this function

setUseSurrogates!(self, val)

View Source

Raising version of setUseSurrogates/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.