View Source Evision.ML.StatModel (Evision v0.1.9)
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
- filename:
String
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
Python prototype (for reference):
Returns the number of variables in training samples
Returns true if the model is classifier
Returns true if the model is trained
Predicts response(s) for the provided sample(s)
Predicts response(s) for the provided sample(s)
Trains the statistical model
Trains the statistical model
Trains the statistical model
Functions
Raising version of calcError/3
.
Raising version of calcError/4
.
Raising version of clear/1
.
Raising version of empty/1
.
Raising version of getDefaultName/1
.
Raising version of getVarCount/1
.
Raising version of isClassifier/1
.
Raising version of isTrained/1
.
Raising version of predict/2
.
Raising version of predict/3
.
Raising version of read/2
.
Raising version of save/2
.
Raising version of train/2
.
Raising version of train/3
.
Raising version of train/4
.
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
- 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):
save(filename) -> None
simplified API for language bindings
Positional Arguments
- fs:
Ptr<FileStorage>
Keyword Arguments
- name:
String
.
Has overloading in C++
Python prototype (for reference):
write(fs[, name]) -> None
simplified API for language bindings
Positional Arguments
- fs:
Ptr<FileStorage>
Keyword Arguments
- name:
String
.
Has overloading in C++
Python prototype (for reference):
write(fs[, name]) -> None
Link to this section cv.ml
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
resp:
Evision.Mat
.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):
calcError(data, test[, resp]) -> retval, resp
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
resp:
Evision.Mat
.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):
calcError(data, test[, resp]) -> retval, resp
Python prototype (for reference):
empty() -> retval
Returns the number of variables in training samples
Python prototype (for reference):
getVarCount() -> retval
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
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
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
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
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
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
Raising version of calcError/3
.
Raising version of calcError/4
.
Raising version of clear/1
.
Raising version of empty/1
.
Raising version of getDefaultName/1
.
Raising version of getVarCount/1
.
Raising version of isClassifier/1
.
Raising version of isTrained/1
.
Raising version of predict/2
.
Raising version of predict/3
.
Raising version of read/2
.
Raising version of save/2
.
Raising version of train/2
.
Raising version of train/3
.
Raising version of train/4
.
Raising version of write/2
.
Raising version of write/3
.