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.) |
Weiterführende Informationen
Die Funktion F_VN_CreateSvmModelExp2 ist eine Expert-Variante von F_VN_CreateSvmModel. Sie enthält zusätzliche Parameter die nur für Modelle vom Typ TCVN_SVM_C_CLASSIFIER relevant sind.
Parameter
Modell
In dem Interface Pointer ipMlModel wird das erstellte Modell zurückgegeben.
Modell-Typ
eSvmType legt fest, ob das SVM-Modell zur Klassifizierung, zur Regression oder zur Anomalie-Detektion genutzt wird:
- TCVN_SVM_C_CLASSIFIER
- TCVN_SVM_NU_CLASSIFIER
- TCVN_SVM_NOVELTY_DETECTOR
- TCVN_SVM_EPS_REGRESSOR
- TCVN_SVM_NU_REGRESSOR
Modell-Parameter
Die Verwendung und Bedeutung der Parameter fC, fNu und fP hängt vom ausgewähltem eSvmType ab.
Kernel-Typ
Mit eKernelType wird der verwendete Kernel-Typ zur Berechnung festgelegt. Der Kernel-Typ hängt von der Aufgabenstellung / Datenverteilung ab und muss daran angepasst werden.
Kernel-Parameter
Die Verwendung und Bedeutung der Parameter fGamma, fCoef0 und fDegree hängt vom ausgewähltem eKernelType ab.
Maximale Iterationen
Für die Optimierung werden maximal so viele Iterationen genutzt, wie in nMaxIterations angegeben sind. Wenn der Wert 0 ist, wird der jeweilige Default-Wert verwendet.
Abbruchgrenze
Die Optimierung wird abgebrochen, sobald sich der Fehler zwischen zwei Iterationen nicht stärker verändert, als in fEpsilon angegeben ist. Wenn der Wert 0 ist, wird der jeweilige Default-Wert verwendet.
Class-Weights
ipClassWeights ist ein Container, mit dem Wichtungen der einzelnen Klassen angegeben werden können.
Anwendung
Ein SVM-Modell zur Klassifikation parametrisiert mit Nu kann z.B. so erstellt werden:
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
System Requirements
Development environment | Target platform | PLC libraries to include |
|---|---|---|
TwinCAT V3.1.4024.59 or later | PC or CX (x64) with min. PL50, e.g. Intel 4-core Atom CPU | Tc3_Vision |
Return value