OpenCV
3.1.0-dev
Open Source Computer Vision
|
Stochastic Gradient Descent SVM classifier. More...
#include "ml.hpp"
Public Types | |
enum | MarginType { SOFT_MARGIN, HARD_MARGIN } |
enum | SvmsgdType { SGD, ASGD } |
Public Types inherited from cv::ml::StatModel | |
enum | Flags { UPDATE_MODEL = 1, RAW_OUTPUT =1, COMPRESSED_INPUT =2, PREPROCESSED_INPUT =4 } |
Public Member Functions | |
virtual float | getInitialStepSize () const =0 |
Parameter initialStepSize of a SVMSGD optimization problem. More... | |
virtual float | getMarginRegularization () const =0 |
Parameter marginRegularization of a SVMSGD optimization problem. More... | |
virtual int | getMarginType () const =0 |
Margin type, one of SVMSGD::MarginType. More... | |
virtual float | getShift ()=0 |
virtual float | getStepDecreasingPower () const =0 |
Parameter stepDecreasingPower of a SVMSGD optimization problem. More... | |
virtual int | getSvmsgdType () const =0 |
Algorithm type, one of SVMSGD::SvmsgdType. More... | |
virtual TermCriteria | getTermCriteria () const =0 |
Termination criteria of the training algorithm. You can specify the maximum number of iterations (maxCount) and/or how much the error could change between the iterations to make the algorithm continue (epsilon). More... | |
virtual Mat | getWeights ()=0 |
virtual void | setInitialStepSize (float InitialStepSize)=0 |
Parameter initialStepSize of a SVMSGD optimization problem. More... | |
virtual void | setMarginRegularization (float marginRegularization)=0 |
Parameter marginRegularization of a SVMSGD optimization problem. More... | |
virtual void | setMarginType (int marginType)=0 |
Margin type, one of SVMSGD::MarginType. More... | |
virtual void | setOptimalParameters (int svmsgdType=SVMSGD::ASGD, int marginType=SVMSGD::SOFT_MARGIN)=0 |
Function sets optimal parameters values for chosen SVM SGD model. More... | |
virtual void | setStepDecreasingPower (float stepDecreasingPower)=0 |
Parameter stepDecreasingPower of a SVMSGD optimization problem. More... | |
virtual void | setSvmsgdType (int svmsgdType)=0 |
Algorithm type, one of SVMSGD::SvmsgdType. More... | |
virtual void | setTermCriteria (const cv::TermCriteria &val)=0 |
Termination criteria of the training algorithm. You can specify the maximum number of iterations (maxCount) and/or how much the error could change between the iterations to make the algorithm continue (epsilon). More... | |
Public Member Functions inherited from cv::ml::StatModel | |
virtual float | calcError (const Ptr< cv::ml::TrainData > &data, bool test, OutputArray resp) const |
Computes error on the training or test dataset. More... | |
virtual bool | empty () const |
Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read. More... | |
virtual int | getVarCount () const =0 |
Returns the number of variables in training samples. More... | |
virtual bool | isClassifier () const =0 |
Returns true if the model is classifier. More... | |
virtual bool | isTrained () const =0 |
Returns true if the model is trained. More... | |
virtual float | predict (InputArray samples, OutputArray results=noArray(), int flags=0) const =0 |
Predicts response(s) for the provided sample(s) More... | |
virtual bool | train (const Ptr< cv::ml::TrainData > &trainData, int flags=0) |
Trains the statistical model. More... | |
virtual bool | train (InputArray samples, int layout, InputArray responses) |
Trains the statistical model. More... | |
Public Member Functions inherited from cv::Algorithm | |
Algorithm () | |
virtual | ~Algorithm () |
virtual void | clear () |
Clears the algorithm state. More... | |
virtual String | getDefaultName () const |
virtual void | read (const FileNode &fn) |
Reads algorithm parameters from a file storage. More... | |
virtual void | save (const String &filename) const |
virtual void | write (FileStorage &fs) const |
Stores algorithm parameters in a file storage. More... | |
Static Public Member Functions | |
static Ptr< SVMSGD > | create () |
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. More... | |
Static Public Member Functions inherited from cv::ml::StatModel | |
template<typename _Tp > | |
static Ptr< _Tp > | train (const Ptr< cv::ml::TrainData > &data, int flags=0) |
Create and train model with default parameters. More... | |
Static Public Member Functions inherited from cv::Algorithm | |
template<typename _Tp > | |
static Ptr< _Tp > | load (const String &filename, const String &objname=String()) |
Loads algorithm from the file. More... | |
template<typename _Tp > | |
static Ptr< _Tp > | loadFromString (const String &strModel, const String &objname=String()) |
Loads algorithm from a String. More... | |
template<typename _Tp > | |
static Ptr< _Tp > | read (const FileNode &fn) |
Reads algorithm from the file node. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from cv::Algorithm | |
void | writeFormat (FileStorage &fs) const |
Stochastic Gradient Descent SVM classifier.
SVMSGD provides a fast and easy-to-use implementation of the SVM classifier using the Stochastic Gradient Descent approach, as presented in [15].
The classifier has following parameters:
The model type may have one of the following values: SGD and ASGD.
\[w_{t+1} = w_t - \gamma(t) \frac{dQ_i}{dw} |_{w = w_t}\]
whereThe recommended model type is ASGD (following [15]).
The margin type may have one of the following values: SOFT_MARGIN or HARD_MARGIN.
The other parameters may be described as follows:
Note that the parameters margin regularization, initial step size, and step decreasing power should be positive.
To use SVMSGD algorithm do as follows:
SVMSGD type. ASGD is often the preferable choice.
Enumerator | |
---|---|
SGD |
Stochastic Gradient Descent. |
ASGD |
Average Stochastic Gradient Descent. |
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.
|
pure virtual |
Parameter initialStepSize of a SVMSGD optimization problem.
|
pure virtual |
Parameter marginRegularization of a SVMSGD optimization problem.
|
pure virtual |
Margin type, one of SVMSGD::MarginType.
|
pure virtual |
|
pure virtual |
Parameter stepDecreasingPower of a SVMSGD optimization problem.
|
pure virtual |
Algorithm type, one of SVMSGD::SvmsgdType.
|
pure virtual |
Termination criteria of the training algorithm. You can specify the maximum number of iterations (maxCount) and/or how much the error could change between the iterations to make the algorithm continue (epsilon).
|
pure virtual |
|
pure virtual |
Parameter initialStepSize of a SVMSGD optimization problem.
|
pure virtual |
Parameter marginRegularization of a SVMSGD optimization problem.
|
pure virtual |
Margin type, one of SVMSGD::MarginType.
|
pure virtual |
|
pure virtual |
Parameter stepDecreasingPower of a SVMSGD optimization problem.
|
pure virtual |
Algorithm type, one of SVMSGD::SvmsgdType.
|
pure virtual |
Termination criteria of the training algorithm. You can specify the maximum number of iterations (maxCount) and/or how much the error could change between the iterations to make the algorithm continue (epsilon).