F_VN_CreateSvmModelExp
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. (expert function)
Syntax
Definition:
FUNCTION F_VN_CreateSvmModelExp : 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;
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) |
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
Further information
The function F_VN_CreateSvmModelExp
is an expert variant of F_VN_CreateSvmModel. It contains additional parameters.
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.
Application
For example, an SVM model for classification can be created like this:
hr := F_VN_CreateSvmModelExp(
ipMlModel := ipMlModel,
eSvmType := TCVN_SVM_NU_CLASSIFIER,
fC := 0,
fNu := 0.1,
fP := 0,
eKernelType := TCVN_SKT_RBF,
fGamma := 1,
fCoef0 := 0,
fDegree := 0,
nMaxIterations := 0,
fEpsilon := 0,
hrPrev := hr);
Required License
TC3 Vision Machine Learning
System Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT V3.1.4024.54 or later | PC or CX (x64) with PL50, e.g. Intel 4-core Atom CPU | Tc3_Vision |