This interface provide functionalities of the machine learning model.
You should firstly create the model with specified type via Create(), then adjust its parameters via ILParameterized interface.
Currently, we support following models:
Model | Usage and Parameters |
KNN | K-Nearest Neighbors
Parameter Name | Usage | Type | Range | Default |
"number of neighbors" | Number of neighbors used for prediction | Integer | 1 ~ 64 | 5 |
"matching algorithm" | The algorithm for the nearest searching | Integer | see LPVKNNMatchAlgo | Brute-Force |
"similarity metric" | The distance calculation method for measuring the similarity between samples | Integer | see LPVKNNDistance | Euclidean |
"weight" | How neighbors are weighted in prediction voting | Integer | see LPVKNNWeight | By distance |
|
SVM | Support Vector Machine
Parameter Name | Usage | Type | Range | Default |
"svm type" | The type of the SVM model | Integer | see LPVSVMType | C-Support |
"cost" | The regularization parameter C, the strength of the regularization is inversely proportional to C. | Integer | > 0 | 0.01 |
"complexity bound" | The Nu parameter to control the number of support vectors and margin errors. It is and upper bound on the fraction of margin errors and a lower bound of the fraction of support vectors | Double | 0 ~ 1 | 0.5 |
"kernel" | The kernel function | Integer | see LPVSVMKernel | Linear |
"g" | g parameter in the kernel function | Double | > 0, 0 for auto-estimated | 0.1 |
"c" | c parameter in the kernel function | Double | ≥ 0 | 0.1 |
"n" | n parameter in the kernel function | Double | > 0 | 3 |
|
Example Code
C++
ILModelPtr svm = LModel);
svm->Type = LPVModelType::LPVModelSVM;
svm->PutParamI(L"svm type", LPVSVMType::LPVSVMTypeCSupport);
svm->PutParamF(L"cost", 512);
svm->PutParamI(L"kernel", LPVSVMKernel::LPVSVMKernelPolynomial);
svm->PutParamF(L"c", 0.4);
llc->AddModel(svm);
C#
LModel svm = new LModel();
svm.ParamI[
"svm type"] =
LPVSVMType.LPVSVMTypeCSupport;
svm.ParamF["cost"] = 512;
svm.ParamF["c"] = 0.4;
llc.AddModel(svm);
LPVModelType
This enumeration represents the type of machine learning model.
Definition: LPVML.idl:118
LPVSVMKernel
This enumeration represents the type of the kernel used in the SVM model.
Definition: LPVML.idl:311
LPVSVMType
This enumeration represents the type of the SVM model.
Definition: LPVML.idl:288
COM
ILModelPtr svm = LModel::Create();
svm->Type = LPVModelType::LPVModelSVM;
svm->ParamI[L"svm type"] = LPVSVMType::LPVSVMTypeCSupport;
svm->ParamF[L"cost"] = 512;
svm->ParamI[L"kernel"] = LPVSVMKernel::LPVSVMKernelPolynomial;
svm->ParamF[L"c"] = 0.4;
llc->AddModel(svm);