OpenCV for Unity 2.6.5
Enox Software / Please refer to OpenCV official document ( http://docs.opencv.org/4.10.0/index.html ) for the details of the argument of the method.
|
Support Vector Machines. More...
Public Member Functions | |
double | getC () |
Mat | getClassWeights () |
double | getCoef0 () |
double | getDecisionFunction (int i, Mat alpha, Mat svidx) |
Retrieves the decision function. | |
double | getDegree () |
double | getGamma () |
int | getKernelType () |
double | getNu () |
double | getP () |
Mat | getSupportVectors () |
Retrieves all the support vectors. | |
TermCriteria | getTermCriteria () |
double double double epsilon | getTermCriteriaAsValueTuple () |
Vec3d | getTermCriteriaAsVec3d () |
int | getType () |
Mat | getUncompressedSupportVectors () |
Retrieves all the uncompressed support vectors of a linear SVM. | |
void | setC (double val) |
void | setClassWeights (Mat val) |
void | setCoef0 (double val) |
void | setDegree (double val) |
void | setGamma (double val) |
void | setKernel (int kernelType) |
void | setNu (double val) |
void | setP (double val) |
void | setTermCriteria (in Vec3d val) |
void | setTermCriteria (in(double type, double maxCount, double epsilon) val) |
void | setTermCriteria (TermCriteria val) |
void | setType (int val) |
bool | trainAuto (Mat samples, int layout, Mat responses) |
Trains an SVM with optimal parameters. | |
bool | trainAuto (Mat samples, int layout, Mat responses, int kFold) |
Trains an SVM with optimal parameters. | |
bool | trainAuto (Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid) |
Trains an SVM with optimal parameters. | |
bool | trainAuto (Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid) |
Trains an SVM with optimal parameters. | |
bool | trainAuto (Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid) |
Trains an SVM with optimal parameters. | |
bool | trainAuto (Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid, ParamGrid nuGrid) |
Trains an SVM with optimal parameters. | |
bool | trainAuto (Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid, ParamGrid nuGrid, ParamGrid coeffGrid) |
Trains an SVM with optimal parameters. | |
bool | trainAuto (Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid, ParamGrid nuGrid, ParamGrid coeffGrid, ParamGrid degreeGrid) |
Trains an SVM with optimal parameters. | |
bool | trainAuto (Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid, ParamGrid nuGrid, ParamGrid coeffGrid, ParamGrid degreeGrid, bool balanced) |
Trains an SVM with optimal parameters. | |
![]() | |
float | calcError (TrainData data, bool test, Mat resp) |
Computes error on the training or test dataset. | |
override bool | empty () |
Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read. | |
int | getVarCount () |
Returns the number of variables in training samples. | |
bool | isClassifier () |
Returns true if the model is classifier. | |
bool | isTrained () |
Returns true if the model is trained. | |
virtual float | predict (Mat samples) |
Predicts response(s) for the provided sample(s) | |
virtual float | predict (Mat samples, Mat results) |
Predicts response(s) for the provided sample(s) | |
virtual float | predict (Mat samples, Mat results, int flags) |
Predicts response(s) for the provided sample(s) | |
bool | train (Mat samples, int layout, Mat responses) |
Trains the statistical model. | |
bool | train (TrainData trainData) |
Trains the statistical model. | |
bool | train (TrainData trainData, int flags) |
Trains the statistical model. | |
![]() | |
virtual void | clear () |
Clears the algorithm state. | |
virtual string | getDefaultName () |
IntPtr | getNativeObjAddr () |
void | save (string filename) |
![]() | |
void | Dispose () |
void | ThrowIfDisposed () |
Static Public Member Functions | |
static new SVM | __fromPtr__ (IntPtr addr) |
static SVM | create () |
static ParamGrid | getDefaultGridPtr (int param_id) |
Generates a grid for SVM parameters. | |
static SVM | load (string filepath) |
Loads and creates a serialized svm from a file. | |
![]() | |
static new StatModel | __fromPtr__ (IntPtr addr) |
![]() | |
static Algorithm | __fromPtr__ (IntPtr addr) |
![]() | |
static IntPtr | ThrowIfNullIntPtr (IntPtr ptr) |
Public Attributes | |
double double | maxCount |
double | type |
Static Public Attributes | |
const int | C = 0 |
const int | C_SVC = 100 |
const int | CHI2 = 4 |
const int | COEF = 4 |
const int | CUSTOM = -1 |
const int | DEGREE = 5 |
const int | EPS_SVR = 103 |
const int | GAMMA = 1 |
const int | INTER = 5 |
const int | LINEAR = 0 |
const int | NU = 3 |
const int | NU_SVC = 101 |
const int | NU_SVR = 104 |
const int | ONE_CLASS = 102 |
const int | P = 2 |
const int | POLY = 1 |
const int | RBF = 2 |
const int | SIGMOID = 3 |
![]() | |
const int | COMPRESSED_INPUT = 2 |
const int | PREPROCESSED_INPUT = 4 |
const int | RAW_OUTPUT = 1 |
const int | UPDATE_MODEL = 1 |
Protected Member Functions | |
override void | Dispose (bool disposing) |
![]() | |
![]() | |
![]() | |
DisposableOpenCVObject () | |
DisposableOpenCVObject (bool isEnabledDispose) | |
DisposableOpenCVObject (IntPtr ptr) | |
DisposableOpenCVObject (IntPtr ptr, bool isEnabledDispose) | |
![]() | |
DisposableObject () | |
DisposableObject (bool isEnabledDispose) | |
Additional Inherited Members | |
![]() | |
![]() | |
![]() | |
![]() | |
bool | IsDisposed [get, protected set] |
bool | IsEnabledDispose [get, set] |
Support Vector Machines.
|
static |
|
static |
Creates empty model. Use StatModel.train to train the model. Since SVM has several parameters, you may want to find the best parameters for your problem, it can be done with SVM.trainAuto.
|
protectedvirtual |
Reimplemented from OpenCVForUnity.MlModule.StatModel.
double OpenCVForUnity.MlModule.SVM.getC | ( | ) |
Mat OpenCVForUnity.MlModule.SVM.getClassWeights | ( | ) |
double OpenCVForUnity.MlModule.SVM.getCoef0 | ( | ) |
Retrieves the decision function.
i | the index of the decision function. If the problem solved is regression, 1-class or 2-class classification, then there will be just one decision function and the index should always be 0. Otherwise, in the case of N-class classification, there will be |
alpha | the optional output vector for weights, corresponding to different support vectors. In the case of linear SVM all the alpha's will be 1's. |
svidx | the optional output vector of indices of support vectors within the matrix of support vectors (which can be retrieved by SVM.getSupportVectors). In the case of linear SVM each decision function consists of a single "compressed" support vector. |
The method returns rho parameter of the decision function, a scalar subtracted from the weighted sum of kernel responses.
|
static |
Generates a grid for SVM parameters.
param_id | SVM parameters IDs that must be one of the SVM::ParamTypes. The grid is generated for the parameter with this ID. |
The function generates a grid pointer for the specified parameter of the SVM algorithm. The grid may be passed to the function SVM.trainAuto.
double OpenCVForUnity.MlModule.SVM.getDegree | ( | ) |
double OpenCVForUnity.MlModule.SVM.getGamma | ( | ) |
int OpenCVForUnity.MlModule.SVM.getKernelType | ( | ) |
Type of a SVM kernel. See SVM::KernelTypes. Default value is SVM.RBF.
double OpenCVForUnity.MlModule.SVM.getNu | ( | ) |
double OpenCVForUnity.MlModule.SVM.getP | ( | ) |
Mat OpenCVForUnity.MlModule.SVM.getSupportVectors | ( | ) |
Retrieves all the support vectors.
The method returns all the support vectors as a floating-point matrix, where support vectors are stored as matrix rows.
TermCriteria OpenCVForUnity.MlModule.SVM.getTermCriteria | ( | ) |
double double double epsilon OpenCVForUnity.MlModule.SVM.getTermCriteriaAsValueTuple | ( | ) |
Vec3d OpenCVForUnity.MlModule.SVM.getTermCriteriaAsVec3d | ( | ) |
int OpenCVForUnity.MlModule.SVM.getType | ( | ) |
Mat OpenCVForUnity.MlModule.SVM.getUncompressedSupportVectors | ( | ) |
Retrieves all the uncompressed support vectors of a linear SVM.
The method returns all the uncompressed support vectors of a linear SVM that the compressed support vector, used for prediction, was derived from. They are returned in a floating-point matrix, where the support vectors are stored as matrix rows.
|
static |
void OpenCVForUnity.MlModule.SVM.setC | ( | double | val | ) |
void OpenCVForUnity.MlModule.SVM.setClassWeights | ( | Mat | val | ) |
void OpenCVForUnity.MlModule.SVM.setCoef0 | ( | double | val | ) |
void OpenCVForUnity.MlModule.SVM.setDegree | ( | double | val | ) |
void OpenCVForUnity.MlModule.SVM.setGamma | ( | double | val | ) |
void OpenCVForUnity.MlModule.SVM.setKernel | ( | int | kernelType | ) |
Initialize with one of predefined kernels. See SVM::KernelTypes.
void OpenCVForUnity.MlModule.SVM.setNu | ( | double | val | ) |
void OpenCVForUnity.MlModule.SVM.setP | ( | double | val | ) |
void OpenCVForUnity.MlModule.SVM.setTermCriteria | ( | in Vec3d | val | ) |
void OpenCVForUnity.MlModule.SVM.setTermCriteria | ( | in(double type, double maxCount, double epsilon) | val | ) |
void OpenCVForUnity.MlModule.SVM.setTermCriteria | ( | TermCriteria | val | ) |
void OpenCVForUnity.MlModule.SVM.setType | ( | int | val | ) |
Trains an SVM with optimal parameters.
samples | training samples |
layout | See ml::SampleTypes. |
responses | vector of responses associated with the training samples. |
kFold | Cross-validation parameter. The training set is divided into kFold subsets. One subset is used to test the model, the others form the train set. So, the SVM algorithm is |
Cgrid | grid for C |
gammaGrid | grid for gamma |
pGrid | grid for p |
nuGrid | grid for nu |
coeffGrid | grid for coeff |
degreeGrid | grid for degree |
balanced | If true and the problem is 2-class classification then the method creates more balanced cross-validation subsets that is proportions between classes in subsets are close to such proportion in the whole train dataset. |
The method trains the SVM model automatically by choosing the optimal parameters C, gamma, p, nu, coef0, degree. Parameters are considered optimal when the cross-validation estimate of the test set error is minimal.
This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only offers rudimentary parameter options.
This function works for the classification (SVM.C_SVC or SVM.NU_SVC) as well as for the regression (SVM.EPS_SVR or SVM.NU_SVR). If it is SVM.ONE_CLASS, no optimization is made and the usual SVM with parameters specified in params is executed.
Trains an SVM with optimal parameters.
samples | training samples |
layout | See ml::SampleTypes. |
responses | vector of responses associated with the training samples. |
kFold | Cross-validation parameter. The training set is divided into kFold subsets. One subset is used to test the model, the others form the train set. So, the SVM algorithm is |
Cgrid | grid for C |
gammaGrid | grid for gamma |
pGrid | grid for p |
nuGrid | grid for nu |
coeffGrid | grid for coeff |
degreeGrid | grid for degree |
balanced | If true and the problem is 2-class classification then the method creates more balanced cross-validation subsets that is proportions between classes in subsets are close to such proportion in the whole train dataset. |
The method trains the SVM model automatically by choosing the optimal parameters C, gamma, p, nu, coef0, degree. Parameters are considered optimal when the cross-validation estimate of the test set error is minimal.
This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only offers rudimentary parameter options.
This function works for the classification (SVM.C_SVC or SVM.NU_SVC) as well as for the regression (SVM.EPS_SVR or SVM.NU_SVR). If it is SVM.ONE_CLASS, no optimization is made and the usual SVM with parameters specified in params is executed.
bool OpenCVForUnity.MlModule.SVM.trainAuto | ( | Mat | samples, |
int | layout, | ||
Mat | responses, | ||
int | kFold, | ||
ParamGrid | Cgrid ) |
Trains an SVM with optimal parameters.
samples | training samples |
layout | See ml::SampleTypes. |
responses | vector of responses associated with the training samples. |
kFold | Cross-validation parameter. The training set is divided into kFold subsets. One subset is used to test the model, the others form the train set. So, the SVM algorithm is |
Cgrid | grid for C |
gammaGrid | grid for gamma |
pGrid | grid for p |
nuGrid | grid for nu |
coeffGrid | grid for coeff |
degreeGrid | grid for degree |
balanced | If true and the problem is 2-class classification then the method creates more balanced cross-validation subsets that is proportions between classes in subsets are close to such proportion in the whole train dataset. |
The method trains the SVM model automatically by choosing the optimal parameters C, gamma, p, nu, coef0, degree. Parameters are considered optimal when the cross-validation estimate of the test set error is minimal.
This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only offers rudimentary parameter options.
This function works for the classification (SVM.C_SVC or SVM.NU_SVC) as well as for the regression (SVM.EPS_SVR or SVM.NU_SVR). If it is SVM.ONE_CLASS, no optimization is made and the usual SVM with parameters specified in params is executed.
bool OpenCVForUnity.MlModule.SVM.trainAuto | ( | Mat | samples, |
int | layout, | ||
Mat | responses, | ||
int | kFold, | ||
ParamGrid | Cgrid, | ||
ParamGrid | gammaGrid ) |
Trains an SVM with optimal parameters.
samples | training samples |
layout | See ml::SampleTypes. |
responses | vector of responses associated with the training samples. |
kFold | Cross-validation parameter. The training set is divided into kFold subsets. One subset is used to test the model, the others form the train set. So, the SVM algorithm is |
Cgrid | grid for C |
gammaGrid | grid for gamma |
pGrid | grid for p |
nuGrid | grid for nu |
coeffGrid | grid for coeff |
degreeGrid | grid for degree |
balanced | If true and the problem is 2-class classification then the method creates more balanced cross-validation subsets that is proportions between classes in subsets are close to such proportion in the whole train dataset. |
The method trains the SVM model automatically by choosing the optimal parameters C, gamma, p, nu, coef0, degree. Parameters are considered optimal when the cross-validation estimate of the test set error is minimal.
This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only offers rudimentary parameter options.
This function works for the classification (SVM.C_SVC or SVM.NU_SVC) as well as for the regression (SVM.EPS_SVR or SVM.NU_SVR). If it is SVM.ONE_CLASS, no optimization is made and the usual SVM with parameters specified in params is executed.
bool OpenCVForUnity.MlModule.SVM.trainAuto | ( | Mat | samples, |
int | layout, | ||
Mat | responses, | ||
int | kFold, | ||
ParamGrid | Cgrid, | ||
ParamGrid | gammaGrid, | ||
ParamGrid | pGrid ) |
Trains an SVM with optimal parameters.
samples | training samples |
layout | See ml::SampleTypes. |
responses | vector of responses associated with the training samples. |
kFold | Cross-validation parameter. The training set is divided into kFold subsets. One subset is used to test the model, the others form the train set. So, the SVM algorithm is |
Cgrid | grid for C |
gammaGrid | grid for gamma |
pGrid | grid for p |
nuGrid | grid for nu |
coeffGrid | grid for coeff |
degreeGrid | grid for degree |
balanced | If true and the problem is 2-class classification then the method creates more balanced cross-validation subsets that is proportions between classes in subsets are close to such proportion in the whole train dataset. |
The method trains the SVM model automatically by choosing the optimal parameters C, gamma, p, nu, coef0, degree. Parameters are considered optimal when the cross-validation estimate of the test set error is minimal.
This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only offers rudimentary parameter options.
This function works for the classification (SVM.C_SVC or SVM.NU_SVC) as well as for the regression (SVM.EPS_SVR or SVM.NU_SVR). If it is SVM.ONE_CLASS, no optimization is made and the usual SVM with parameters specified in params is executed.
bool OpenCVForUnity.MlModule.SVM.trainAuto | ( | Mat | samples, |
int | layout, | ||
Mat | responses, | ||
int | kFold, | ||
ParamGrid | Cgrid, | ||
ParamGrid | gammaGrid, | ||
ParamGrid | pGrid, | ||
ParamGrid | nuGrid ) |
Trains an SVM with optimal parameters.
samples | training samples |
layout | See ml::SampleTypes. |
responses | vector of responses associated with the training samples. |
kFold | Cross-validation parameter. The training set is divided into kFold subsets. One subset is used to test the model, the others form the train set. So, the SVM algorithm is |
Cgrid | grid for C |
gammaGrid | grid for gamma |
pGrid | grid for p |
nuGrid | grid for nu |
coeffGrid | grid for coeff |
degreeGrid | grid for degree |
balanced | If true and the problem is 2-class classification then the method creates more balanced cross-validation subsets that is proportions between classes in subsets are close to such proportion in the whole train dataset. |
The method trains the SVM model automatically by choosing the optimal parameters C, gamma, p, nu, coef0, degree. Parameters are considered optimal when the cross-validation estimate of the test set error is minimal.
This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only offers rudimentary parameter options.
This function works for the classification (SVM.C_SVC or SVM.NU_SVC) as well as for the regression (SVM.EPS_SVR or SVM.NU_SVR). If it is SVM.ONE_CLASS, no optimization is made and the usual SVM with parameters specified in params is executed.
bool OpenCVForUnity.MlModule.SVM.trainAuto | ( | Mat | samples, |
int | layout, | ||
Mat | responses, | ||
int | kFold, | ||
ParamGrid | Cgrid, | ||
ParamGrid | gammaGrid, | ||
ParamGrid | pGrid, | ||
ParamGrid | nuGrid, | ||
ParamGrid | coeffGrid ) |
Trains an SVM with optimal parameters.
samples | training samples |
layout | See ml::SampleTypes. |
responses | vector of responses associated with the training samples. |
kFold | Cross-validation parameter. The training set is divided into kFold subsets. One subset is used to test the model, the others form the train set. So, the SVM algorithm is |
Cgrid | grid for C |
gammaGrid | grid for gamma |
pGrid | grid for p |
nuGrid | grid for nu |
coeffGrid | grid for coeff |
degreeGrid | grid for degree |
balanced | If true and the problem is 2-class classification then the method creates more balanced cross-validation subsets that is proportions between classes in subsets are close to such proportion in the whole train dataset. |
The method trains the SVM model automatically by choosing the optimal parameters C, gamma, p, nu, coef0, degree. Parameters are considered optimal when the cross-validation estimate of the test set error is minimal.
This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only offers rudimentary parameter options.
This function works for the classification (SVM.C_SVC or SVM.NU_SVC) as well as for the regression (SVM.EPS_SVR or SVM.NU_SVR). If it is SVM.ONE_CLASS, no optimization is made and the usual SVM with parameters specified in params is executed.
bool OpenCVForUnity.MlModule.SVM.trainAuto | ( | Mat | samples, |
int | layout, | ||
Mat | responses, | ||
int | kFold, | ||
ParamGrid | Cgrid, | ||
ParamGrid | gammaGrid, | ||
ParamGrid | pGrid, | ||
ParamGrid | nuGrid, | ||
ParamGrid | coeffGrid, | ||
ParamGrid | degreeGrid ) |
Trains an SVM with optimal parameters.
samples | training samples |
layout | See ml::SampleTypes. |
responses | vector of responses associated with the training samples. |
kFold | Cross-validation parameter. The training set is divided into kFold subsets. One subset is used to test the model, the others form the train set. So, the SVM algorithm is |
Cgrid | grid for C |
gammaGrid | grid for gamma |
pGrid | grid for p |
nuGrid | grid for nu |
coeffGrid | grid for coeff |
degreeGrid | grid for degree |
balanced | If true and the problem is 2-class classification then the method creates more balanced cross-validation subsets that is proportions between classes in subsets are close to such proportion in the whole train dataset. |
The method trains the SVM model automatically by choosing the optimal parameters C, gamma, p, nu, coef0, degree. Parameters are considered optimal when the cross-validation estimate of the test set error is minimal.
This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only offers rudimentary parameter options.
This function works for the classification (SVM.C_SVC or SVM.NU_SVC) as well as for the regression (SVM.EPS_SVR or SVM.NU_SVR). If it is SVM.ONE_CLASS, no optimization is made and the usual SVM with parameters specified in params is executed.
bool OpenCVForUnity.MlModule.SVM.trainAuto | ( | Mat | samples, |
int | layout, | ||
Mat | responses, | ||
int | kFold, | ||
ParamGrid | Cgrid, | ||
ParamGrid | gammaGrid, | ||
ParamGrid | pGrid, | ||
ParamGrid | nuGrid, | ||
ParamGrid | coeffGrid, | ||
ParamGrid | degreeGrid, | ||
bool | balanced ) |
Trains an SVM with optimal parameters.
samples | training samples |
layout | See ml::SampleTypes. |
responses | vector of responses associated with the training samples. |
kFold | Cross-validation parameter. The training set is divided into kFold subsets. One subset is used to test the model, the others form the train set. So, the SVM algorithm is |
Cgrid | grid for C |
gammaGrid | grid for gamma |
pGrid | grid for p |
nuGrid | grid for nu |
coeffGrid | grid for coeff |
degreeGrid | grid for degree |
balanced | If true and the problem is 2-class classification then the method creates more balanced cross-validation subsets that is proportions between classes in subsets are close to such proportion in the whole train dataset. |
The method trains the SVM model automatically by choosing the optimal parameters C, gamma, p, nu, coef0, degree. Parameters are considered optimal when the cross-validation estimate of the test set error is minimal.
This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only offers rudimentary parameter options.
This function works for the classification (SVM.C_SVC or SVM.NU_SVC) as well as for the regression (SVM.EPS_SVR or SVM.NU_SVR). If it is SVM.ONE_CLASS, no optimization is made and the usual SVM with parameters specified in params is executed.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
double double OpenCVForUnity.MlModule.SVM.maxCount |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
double OpenCVForUnity.MlModule.SVM.type |