F_VN_CreateKmppModelExp

F_VN_CreateKmppModelExp 1:

Create a k-means++ 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. (expert function)

Syntax

Definition:

FUNCTION F_VN_CreateKmppModelExp : HRESULT
VAR_INPUT
    ipMlModel        : Reference To ITcVnMlModel;
    eKmppType        : ETcVnPrototypeClusterer;
    nK               : UDINT;
    bDoublePrecision : BOOL;
    nMaxIterations   : UDINT;
    fEpsilon         : LREAL;
    hrPrev           : HRESULT;
END_VAR

F_VN_CreateKmppModelExp 2: Inputs

Name

Type

Description

ipMlModel

Reference To ITcVnMlModel

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

eKmppType

ETcVnPrototypeClusterer

k-means++ model type

nK

UDINT

Parameter k (number of clusters)

bDoublePrecision

BOOL

If true, the model is generated with double precision (LREAL) instead of single precision (REAL). (default: FALSE)

nMaxIterations

UDINT

Maximum number of iterations (triggers the usage of the default value of 10 if it equals 0)

fEpsilon

LREAL

Maximum allowed difference of the error between two successive iterations (triggers the usage of the default value of 0.001 if it equals 0)

hrPrev

HRESULT

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

F_VN_CreateKmppModelExp 3: Return value

HRESULT

Further information

The function F_VN_CreateKmppModelExp is the expert variant of F_VN_CreateKmppModel. It contains additional parameters.

Parameter

Model

The created model is returned in the interface pointer ipMlModel.

Model type

eKmppType specifies whether K-Means++ is used for clustering (TCVN_PC_CLUSTERER) or for anomaly detection (TCVN_PC_NOVELTY_DETECTOR).

Number of clusters

The number of clusters in the K-Means++ model is specified by nK and cannot be changed once it has been created. During training, the number of samples must be greater than or equal to the number of clusters.

Higher accuracy

If bDoublePrecision is TRUE, LREAL is used as the data type for the internal calculations of the model; if it is FALSE, REAL is used.

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, a K-Means++ model for clustering with 5 clusters can be created like this:

hr := F_VN_CreateKmppModelExp(
    ipMlModel           := ipMlModel,
    eKmppType           := TCVN_PC_CLUSTERER,
    nK                  := 5,
    bDoublePrecision    := FALSE,
    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