F_VN_CreateSvmSgdClassifierExp

F_VN_CreateSvmSgdClassifierExp 1:

Create a linear SVM classifier using stochastic gradient descent for training. The initial reference count is set to one if a new model is created and kept, otherwise. This SVM classifier is only applicable to binary classification problems. It learns a separating hyperplane between a class with label -1 and a class with label 1. These class labels are predefined. For training, any positive class labels are mapped to 1 and any negative class labels are mapped to -1. Models of this type neither support on-line training (sample by sample) nor retraining. (expert function)

Syntax

Definition:

FUNCTION F_VN_CreateSvmSgdClassifierExp : HRESULT
VAR_INPUT
    ipMlModel             : Reference To ITcVnMlModel;
    eType                 : ETcVnSvmSgdClassifierType;
    eMarginType           : ETcVnSvmSgdClassifierMarginType;
    fMarginRegularization : REAL;
    fInitialStepSize      : REAL;
    fStepDecreasingPower  : REAL;
    nMaxIterations        : UDINT;
    fEpsilon              : LREAL;
    hrPrev                : HRESULT;
END_VAR

F_VN_CreateSvmSgdClassifierExp 2: Inputs

Name

Type

Description

ipMlModel

Reference To ITcVnMlModel

Returns the created model (Non-zero interface pointers are reused.)

eType

ETcVnSvmSgdClassifierType

Learning algorithm type (default: TCVN_SSCT_ASGD)

eMarginType

ETcVnSvmSgdClassifierMarginType

Margin type (default: TCVN_SSCMT_SOFT_MARGIN)

fMarginRegularization

REAL

Margin regularization parameter (default: 0.00001)

fInitialStepSize

REAL

Initial step size (default: 0.05)

fStepDecreasingPower

REAL

Power parameter (default: 0.75)

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

HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.)

F_VN_CreateSvmSgdClassifierExp 3: Return value

HRESULT

Further information

The function F_VN_CreateSvmSgdClassifierExp is an expert variant of F_VN_CreateSvmSgdClassifier. It contains additional parameters.

Parameter

Model

The created model is returned in the interface pointer ipMlModel.

Algorithm

eType specifies which optimization method is used in the training:

Delimitation of the classes

eMarginType specifies whether the delimitation of the classes is to be carried out strictly (TCVN_SSCMT_HARD_MARGIN) or with outliers (TCVN_SSCMT_SOFT_MARGIN).

Regularization

fMarginRegularization is responsible for the weights decreasing at each step and controls the extent to which the influence of outliers is limited. The smaller the parameter, the lower the probability that an outlier will be ignored.

Step size

fInitialStepSize indicates the step size at the beginning of the training.

Decrease in step size

fStepDecreasingPower specifies the exponent for reducing the step size.

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-SGD model for classification can be created like this:

hr := F_VN_CreateSvmSgdClassifierExp(
    ipMlModel               := ipMlModel,
    eType                   := TCVN_SSCT_ASGD,
    eMarginType             := TCVN_SSCMT_SOFT_MARGIN,
    fMarginRegularization   := 0.00001,
    fInitialStepSize        := 0.05,
    fStepDecreasingPower    := 0.75,
    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