F_VN_CreateKmppModel
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.
Syntax
Definition:
FUNCTION F_VN_CreateKmppModel : HRESULT
VAR_INPUT
ipMlModel : Reference To ITcVnMlModel;
eKmppType : ETcVnPrototypeClusterer;
nK : UDINT;
hrPrev : HRESULT;
END_VAR
Inputs
Name |
Type |
Description |
---|---|---|
ipMlModel |
Reference To ITcVnMlModel |
Returns the created model (Non-zero interface pointers are reused.) |
eKmppType |
k-means++ model type | |
nK |
UDINT |
Parameter k (number of clusters) |
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
Further information
The function F_VN_CreateKmppModel
creates a K-Means++ (KMPP) model.
K-Means++ models
K-Means++ can be used for clustering or anomaly detection. It finds clusters of data points. All samples are required for training at the same time (batch training) and post-training is not possible.
The assignment of cluster designations (as DINT
s) may differ from training to training. If this assignment is to be deterministic, a fixed random seed must be set beforehand using F_VN_SetRngSeed.
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.
Expert parameters
The expert variant F_VN_CreateKmppModelExp contains additional parameters.
Application
For example, a K-Means++ model for clustering with 5 clusters can be created like this:
hr := F_VN_CreateKmppModel(
ipMlModel := ipMlModel,
eKmppType := TCVN_PC_CLUSTERER,
nK := 5,
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 |