View Source Evision.ML.RTrees (Evision v0.2.9)
Summary
Functions
Computes error on the training or test dataset
Computes error on the training or test dataset
Clears the algorithm state
create
empty
getActiveVarCount
getCalculateVarImportance
getCVFolds
getDefaultName
getMaxCategories
getMaxDepth
getMinSampleCount
getOOBError
getPriors
getRegressionAccuracy
getTermCriteria
getTruncatePrunedTree
getUse1SERule
getUseSurrogates
Returns the number of variables in training samples
getVarImportance
getVotes
getVotes
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)
Reads algorithm parameters from a file storage
save
setActiveVarCount
setCalculateVarImportance
setCVFolds
setMaxCategories
setMaxDepth
setMinSampleCount
setPriors
setRegressionAccuracy
setTermCriteria
setTruncatePrunedTree
setUse1SERule
setUseSurrogates
Trains the statistical model
Trains the statistical model
Trains the statistical model
Stores algorithm parameters in a file storage
write
Types
@type t() :: %Evision.ML.RTrees{ref: reference()}
Type that represents an ML.RTrees
struct.
ref.
reference()
The underlying erlang resource variable.
Functions
@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.RTrees.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 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.RTrees.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.RTrees.t()
Python prototype (for reference only):
clear() -> None
create
Return
- retval:
Evision.ML.RTrees.t()
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 only):
create() -> retval
@spec empty(Keyword.t()) :: any() | {:error, String.t()}
@spec empty(t()) :: boolean() | {:error, String.t()}
empty
Positional Arguments
- self:
Evision.ML.RTrees.t()
Return
- retval:
bool
Python prototype (for reference only):
empty() -> retval
@spec getActiveVarCount(Keyword.t()) :: any() | {:error, String.t()}
@spec getActiveVarCount(t()) :: integer() | {:error, String.t()}
getActiveVarCount
Positional Arguments
- self:
Evision.ML.RTrees.t()
Return
- retval:
integer()
@see setActiveVarCount/2
Python prototype (for reference only):
getActiveVarCount() -> retval
@spec getCalculateVarImportance(Keyword.t()) :: any() | {:error, String.t()}
@spec getCalculateVarImportance(t()) :: boolean() | {:error, String.t()}
getCalculateVarImportance
Positional Arguments
- self:
Evision.ML.RTrees.t()
Return
- retval:
bool
@see setCalculateVarImportance/2
Python prototype (for reference only):
getCalculateVarImportance() -> retval
@spec getCVFolds(Keyword.t()) :: any() | {:error, String.t()}
@spec getCVFolds(t()) :: integer() | {:error, String.t()}
getCVFolds
Positional Arguments
- self:
Evision.ML.RTrees.t()
Return
- retval:
integer()
@see setCVFolds/2
Python prototype (for reference only):
getCVFolds() -> retval
@spec getDefaultName(Keyword.t()) :: any() | {:error, String.t()}
@spec getDefaultName(t()) :: binary() | {:error, String.t()}
getDefaultName
Positional Arguments
- self:
Evision.ML.RTrees.t()
Return
- retval:
String
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
@spec getMaxCategories(Keyword.t()) :: any() | {:error, String.t()}
@spec getMaxCategories(t()) :: integer() | {:error, String.t()}
getMaxCategories
Positional Arguments
- self:
Evision.ML.RTrees.t()
Return
- retval:
integer()
@see setMaxCategories/2
Python prototype (for reference only):
getMaxCategories() -> retval
@spec getMaxDepth(Keyword.t()) :: any() | {:error, String.t()}
@spec getMaxDepth(t()) :: integer() | {:error, String.t()}
getMaxDepth
Positional Arguments
- self:
Evision.ML.RTrees.t()
Return
- retval:
integer()
@see setMaxDepth/2
Python prototype (for reference only):
getMaxDepth() -> retval
@spec getMinSampleCount(Keyword.t()) :: any() | {:error, String.t()}
@spec getMinSampleCount(t()) :: integer() | {:error, String.t()}
getMinSampleCount
Positional Arguments
- self:
Evision.ML.RTrees.t()
Return
- retval:
integer()
@see setMinSampleCount/2
Python prototype (for reference only):
getMinSampleCount() -> retval
@spec getOOBError(Keyword.t()) :: any() | {:error, String.t()}
@spec getOOBError(t()) :: number() | {:error, String.t()}
getOOBError
Positional Arguments
- self:
Evision.ML.RTrees.t()
Return
- retval:
double
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 only):
getOOBError() -> retval
@spec getPriors(Keyword.t()) :: any() | {:error, String.t()}
@spec getPriors(t()) :: Evision.Mat.t() | {:error, String.t()}
getPriors
Positional Arguments
- self:
Evision.ML.RTrees.t()
Return
- retval:
Evision.Mat.t()
@see setPriors/2
Python prototype (for reference only):
getPriors() -> retval
@spec getRegressionAccuracy(Keyword.t()) :: any() | {:error, String.t()}
@spec getRegressionAccuracy(t()) :: number() | {:error, String.t()}
getRegressionAccuracy
Positional Arguments
- self:
Evision.ML.RTrees.t()
Return
- retval:
float
Python prototype (for reference only):
getRegressionAccuracy() -> retval
@spec getTermCriteria(Keyword.t()) :: any() | {:error, String.t()}
@spec getTermCriteria(t()) :: {integer(), integer(), number()} | {:error, String.t()}
getTermCriteria
Positional Arguments
- self:
Evision.ML.RTrees.t()
Return
- retval:
TermCriteria
@see setTermCriteria/2
Python prototype (for reference only):
getTermCriteria() -> retval
@spec getTruncatePrunedTree(Keyword.t()) :: any() | {:error, String.t()}
@spec getTruncatePrunedTree(t()) :: boolean() | {:error, String.t()}
getTruncatePrunedTree
Positional Arguments
- self:
Evision.ML.RTrees.t()
Return
- retval:
bool
Python prototype (for reference only):
getTruncatePrunedTree() -> retval
@spec getUse1SERule(Keyword.t()) :: any() | {:error, String.t()}
@spec getUse1SERule(t()) :: boolean() | {:error, String.t()}
getUse1SERule
Positional Arguments
- self:
Evision.ML.RTrees.t()
Return
- retval:
bool
@see setUse1SERule/2
Python prototype (for reference only):
getUse1SERule() -> retval
@spec getUseSurrogates(Keyword.t()) :: any() | {:error, String.t()}
@spec getUseSurrogates(t()) :: boolean() | {:error, String.t()}
getUseSurrogates
Positional Arguments
- self:
Evision.ML.RTrees.t()
Return
- retval:
bool
@see setUseSurrogates/2
Python prototype (for reference only):
getUseSurrogates() -> 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.RTrees.t()
Return
- retval:
integer()
Python prototype (for reference only):
getVarCount() -> retval
@spec getVarImportance(Keyword.t()) :: any() | {:error, String.t()}
@spec getVarImportance(t()) :: Evision.Mat.t() | {:error, String.t()}
getVarImportance
Positional Arguments
- self:
Evision.ML.RTrees.t()
Return
- retval:
Evision.Mat.t()
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 only):
getVarImportance() -> retval
@spec getVotes(t(), Evision.Mat.maybe_mat_in(), integer()) :: Evision.Mat.t() | {:error, String.t()}
getVotes
Positional Arguments
self:
Evision.ML.RTrees.t()
samples:
Evision.Mat
.Array containing the samples for which votes will be calculated.
flags:
integer()
.Flags for defining the type of RTrees.
Return
results:
Evision.Mat.t()
.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 only):
getVotes(samples, flags[, results]) -> results
@spec getVotes( t(), Evision.Mat.maybe_mat_in(), integer(), [{atom(), term()}, ...] | nil ) :: Evision.Mat.t() | {:error, String.t()}
getVotes
Positional Arguments
self:
Evision.ML.RTrees.t()
samples:
Evision.Mat
.Array containing the samples for which votes will be calculated.
flags:
integer()
.Flags for defining the type of RTrees.
Return
results:
Evision.Mat.t()
.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 only):
getVotes(samples, flags[, results]) -> results
@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.RTrees.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.RTrees.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 RTree from a file
Positional Arguments
filepath:
String
.path to serialized RTree
Keyword Arguments
nodeName:
String
.name of node containing the classifier
Return
- retval:
Evision.ML.RTrees.t()
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 only):
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
Return
- retval:
Evision.ML.RTrees.t()
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 only):
load(filepath[, nodeName]) -> retval
@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.RTrees.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 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.RTrees.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(t(), Evision.FileNode.t()) :: t() | {:error, String.t()}
Reads algorithm parameters from a file storage
Positional Arguments
- self:
Evision.ML.RTrees.t()
- func:
Evision.FileNode
Python prototype (for reference only):
read(fn) -> None
save
Positional Arguments
- self:
Evision.ML.RTrees.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
setActiveVarCount
Positional Arguments
- self:
Evision.ML.RTrees.t()
- val:
integer()
@see getActiveVarCount/1
Python prototype (for reference only):
setActiveVarCount(val) -> None
setCalculateVarImportance
Positional Arguments
- self:
Evision.ML.RTrees.t()
- val:
bool
@see getCalculateVarImportance/1
Python prototype (for reference only):
setCalculateVarImportance(val) -> None
setCVFolds
Positional Arguments
- self:
Evision.ML.RTrees.t()
- val:
integer()
@see getCVFolds/1
Python prototype (for reference only):
setCVFolds(val) -> None
setMaxCategories
Positional Arguments
- self:
Evision.ML.RTrees.t()
- val:
integer()
@see getMaxCategories/1
Python prototype (for reference only):
setMaxCategories(val) -> None
setMaxDepth
Positional Arguments
- self:
Evision.ML.RTrees.t()
- val:
integer()
@see getMaxDepth/1
Python prototype (for reference only):
setMaxDepth(val) -> None
setMinSampleCount
Positional Arguments
- self:
Evision.ML.RTrees.t()
- val:
integer()
@see getMinSampleCount/1
Python prototype (for reference only):
setMinSampleCount(val) -> None
@spec setPriors(t(), Evision.Mat.maybe_mat_in()) :: t() | {:error, String.t()}
setPriors
Positional Arguments
- self:
Evision.ML.RTrees.t()
- val:
Evision.Mat
@see getPriors/1
Python prototype (for reference only):
setPriors(val) -> None
setRegressionAccuracy
Positional Arguments
- self:
Evision.ML.RTrees.t()
- val:
float
Python prototype (for reference only):
setRegressionAccuracy(val) -> None
setTermCriteria
Positional Arguments
- self:
Evision.ML.RTrees.t()
- val:
TermCriteria
@see getTermCriteria/1
Python prototype (for reference only):
setTermCriteria(val) -> None
setTruncatePrunedTree
Positional Arguments
- self:
Evision.ML.RTrees.t()
- val:
bool
Python prototype (for reference only):
setTruncatePrunedTree(val) -> None
setUse1SERule
Positional Arguments
- self:
Evision.ML.RTrees.t()
- val:
bool
@see getUse1SERule/1
Python prototype (for reference only):
setUse1SERule(val) -> None
setUseSurrogates
Positional Arguments
- self:
Evision.ML.RTrees.t()
- val:
bool
@see getUseSurrogates/1
Python prototype (for reference only):
setUseSurrogates(val) -> None
@spec train(t(), Evision.ML.TrainData.t()) :: boolean() | {:error, String.t()}
Trains the statistical model
Positional Arguments
self:
Evision.ML.RTrees.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
@spec train(t(), Evision.ML.TrainData.t(), [{:flags, term()}] | nil) :: boolean() | {:error, String.t()}
Trains the statistical model
Positional Arguments
self:
Evision.ML.RTrees.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
@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.RTrees.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(t(), Evision.FileStorage.t()) :: t() | {:error, String.t()}
Stores algorithm parameters in a file storage
Positional Arguments
- self:
Evision.ML.RTrees.t()
- fs:
Evision.FileStorage
Python prototype (for reference only):
write(fs) -> None
@spec write(t(), Evision.FileStorage.t(), binary()) :: t() | {:error, String.t()}
write
Positional Arguments
- self:
Evision.ML.RTrees.t()
- fs:
Evision.FileStorage
- name:
String
Has overloading in C++
Python prototype (for reference only):
write(fs, name) -> None