F_VN_CreateLbgModelExp
Create a LBG 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_CreateLbgModelExp : HRESULT
VAR_INPUT
ipMlModel : Reference To ITcVnMlModel;
eLbgType : ETcVnPrototypeClusterer;
nMaxClusters : UDINT;
fMaxClusterRadius : LREAL;
bSingleSplitSteps : BOOL;
bDoublePrecision : BOOL;
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.) |
eLbgType |
LBG model type | |
nMaxClusters |
UDINT |
Maximum number of clusters |
fMaxClusterRadius |
LREAL |
Maximum allowed radius (L2 norm) of a single cluster, i.e. clusters with a higher radius will be split into smaller ones, until a global number of nMaxClusters is reached. |
bSingleSplitSteps |
BOOL |
If true, the global optimization is always run after a single cluster has been split. If false, several clusters are split within the same step before applying the global optimization. Applying the global optimization less often is faster, but can lead to less optimal results, especially having 2 nearby clusters that could be represented by 1. |
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 indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
Further information
The function F_VN_CreateLbgModelExp
is the expert variant of F_VN_CreateLbgModel. It contains additional parameters.
Parameter
Model
The created model is returned in the interface pointer ipMlModel
.
Model type
eLbgType
specifies whether LBG is used for clustering (TCVN_PC_CLUSTERER
) or for anomaly detection (TCVN_PC_NOVELTY_DETECTOR
).
Maximum number of clusters
If nMaxClusters
exist in total due to the splitting of clusters that are too large, no more new clusters are created.
Maximum cluster radius
If the radius of a cluster becomes larger than fMaxClusterRadius
during training, this cluster is split into two smaller clusters.
Optimization quality
Part of the iterative training process is a global optimization step. If bSingleSplitSteps = TRUE
, this optimization is executed after each individual cluster split. This leads to a higher quality of clusters, but also to a longer training time. If bSingleSplitSteps =
FALSE
, the optimization is only executed after several clusters have been split.
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, an LBG model for clustering with 5
clusters, a maximum cluster size of 3.6
and high optimization quality can be created in this way:
hr := F_VN_CreateLbgModelExp(
ipMlModel := ipMlModel,
eLbgType := TCVN_PC_CLUSTERER,
nMaxClusters := 5,
fMaxClusterRadius := 3.6,
bSingleSplitSteps := TRUE,
bDoublePrecision := TRUE,
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 |