F_VN_CreateSvmModelExp2
Create an SVM model of the specified type. The initial reference count is set to one if a new model is created and kept, otherwise. Models of this type neither support on-line training (sample by sample) nor retraining. Predictions can only be scalar. (additional expert function for C support vector classifiers)
Syntax
Definition:
FUNCTION F_VN_CreateSvmModelExp2 : HRESULT
VAR_INPUT
ipMlModel : Reference To ITcVnMlModel;
eSvmType : ETcVnSvm;
fC : LREAL;
fNu : LREAL;
fP : LREAL;
eKernelType : ETcVnSvmKernelType;
fGamma : LREAL;
fCoef0 : LREAL;
fDegree : LREAL;
nMaxIterations : UDINT;
fEpsilon : LREAL;
ipClassWeights : ITcVnContainer;
hrPrev : HRESULT;
END_VAR
Inputs
|
Name |
Type |
Description |
|---|---|---|
|
ipMlModel |
Reference To ITcVnMlModel |
Returns the created model (Non-zero interface pointers are reused.) |
|
eSvmType |
SVM model type | |
|
fC |
LREAL |
Parameter C (required for TCVN_SVM_C_CLASSIFIER, TCVN_SVM_EPS_REGRESSOR, and TCVN_SVM_NU_REGRESSOR; ignored otherwise) |
|
fNu |
LREAL |
Parameter nu (required for TCVN_SVM_NU_CLASSIFIER, TCVN_SVM_NOVELTY_DETECTOR, and TCVN_SVM_NU_REGRESSOR; ignored otherwise) |
|
fP |
LREAL |
Parameter p (required for TCVN_SVM_EPS_REGRESSOR; ignored otherwise) |
|
eKernelType |
Kernel type | |
|
fGamma |
LREAL |
Parameter gamma (used by polynomial, RBF, sigmoid, and chi-squared kernels; ignored otherwise) |
|
fCoef0 |
LREAL |
Parameter coef0 (used by polynomial and sigmoid kernels; ignored otherwise) |
|
fDegree |
LREAL |
Degree (used by polynomial kernels; ignored otherwise) |
|
nMaxIterations |
UDINT |
Maximum number of iterations (disabled if it equals 0 and fEpsilon is different from 0.0; triggers the usage of the default value of 100000 if nMaxIterations and fEpsilon equal 0) |
|
fEpsilon |
LREAL |
Maximum allowed difference of the error between two successive iterations (disabled if it equals 0.0 and nMaxIterations is different from 0; triggers the usage of the default value of 0.00001 if nMaxIterations and fEpsilon equal 0) |
|
ipClassWeights |
Class weights (ContainerType_Vector_REAL or ContainerType_Vector_LREAL; only valid if eSvmType equals TCVN_SVM_C_CLASSIFIER; optional, set to 0 if not required or not allowed; default: 0) | |
|
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
Further information
The function F_VN_CreateSvmModelExp2 is an expert variant of F_VN_CreateSvmModel. It contains additional parameters that are only relevant for models of type TCVN_SVM_C_CLASSIFIER.
Parameter
Model
The created model is returned in the interface pointer ipMlModel.
Model type
eSvmType specifies whether the SVM model is used for classification, regression or anomaly detection:
- TCVN_SVM_C_CLASSIFIER
- TCVN_SVM_NU_CLASSIFIER
- TCVN_SVM_NOVELTY_DETECTOR
- TCVN_SVM_EPS_REGRESSOR
- TCVN_SVM_NU_REGRESSOR
Model parameters
The use and meaning of the parameters fC, fNu and fP depends on the selected eSvmType.
Kernel type
The kernel type used for the calculation is defined with eKernelType. The kernel type depends on the task / data distribution and must be adapted accordingly.
Kernel parameters
The use and meaning of the parameters fGamma, fCoef0 and fDegree depends on the selected eKernelType.
Maximum iterations
A maximum of as many iterations as specified in nMaxIterations are used for the optimization. If the value is 0, the respective default value is used.
Termination limit
The optimization is aborted as soon as the error between two iterations does not change more than specified in fEpsilon. If the value is 0, the respective default value is used.
Class-Weights
ipClassWeights is a container that can be used to specify the weighting of the individual classes.
Application
For example, an SVM model for classification parameterized with Nu can be created like this:
hr := F_VN_CreateSvmModelExp2(
ipMlModel := ipMlModel,
eSvmType := TCVN_SVM_C_CLASSIFIER,
fC := 100,
fNu := 0,
fP := 0,
eKernelType := TCVN_SKT_RBF,
fGamma := 1,
fCoef0 := 0,
fDegree := 0,
nMaxIterations := 0,
fEpsilon := 0,
ipClassWeights := ipClassWeights,
hrPrev := hr);Required License
TC3 Machine Learning Realtime Inference
Return value