F_VN_CreateLbgModel

F_VN_CreateLbgModel 1:

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.

Syntax

Definition:

FUNCTION F_VN_CreateLbgModel : HRESULT
VAR_INPUT
    ipMlModel         : Reference To ITcVnMlModel;
    eLbgType          : ETcVnPrototypeClusterer;
    nMaxClusters      : UDINT;
    fMaxClusterRadius : LREAL;
    bSingleSplitSteps : BOOL;
    hrPrev            : HRESULT;
END_VAR

F_VN_CreateLbgModel 2: Inputs

Name

Type

Description

ipMlModel

Reference To ITcVnMlModel

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

eLbgType

ETcVnPrototypeClusterer

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.

hrPrev

HRESULT

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

F_VN_CreateLbgModel 3: Return value

HRESULT

Weiterführende Informationen

Die Funktion F_VN_CreateLbgModel erstellt ein Linde-Buzo-Gray (LBG) Modell.

Linde-Buzo-Gray-Modelle

LBG-Modelle funktionieren ähnlich wie K-Means++ Modelle, indem sie iterativ die Cluster an die Samples angleichen. Die wesentliche Besonderheit von LBG ist, dass im Iterationsprozess neue Cluster angelegt werden, sobald diese größer als fMaxClusterRadius sind (bis die Maximalanzahl nMaxClusters errreicht wird). Bei K-Means++ hingegen wird die Anzahl der Cluster initial festgelegt.

Parameter

Modell

In dem Interface Pointer ipMlModel wird das erstellte Modell zurückgegeben.

Modell-Typ

eLbgType legt fest, ob LBG zum Clustering (TCVN_PC_CLUSTERER) oder zur Anomalie-Detektion (TCVN_PC_NOVELTY_DETECTOR) genutzt wird.

Maximale Cluster-Anzahl

Wenn durch das Aufteilen von zu großen Clustern insgesamt nMaxClusters existieren, werden keine neuen Cluster mehr angelegt.

Maximale Cluster-Radius

Wenn im Training der Radius eines Clusters größer als fMaxClusterRadius wird, wird dieser Cluster in zwei kleinere Cluster aufgeteilt.

Optimierungsqualität

Teil des iterativen Trainingsprozesses ist ein globaler Optimierungsschritt. Wenn bSingleSplitSteps = TRUE ist, wird diese Optimierung nach jeder einzelnen Cluster-Aufteilung ausgeführt. Dies führt zu einer höheren Qualität der Cluster, aber auch zu einer längeren Trainingszeit. Wenn bSingleSplitSteps = FALSE ist, wird die Optimierung erst ausgeführt, nachdem mehrere Cluster aufgeteilt wurden.

Expert-Parameter

Die Expert-Variante F_VN_CreateLbgModelExp enthält zusätzliche Parameter.

Anwendung

Ein LBG-Modell für Clustering mit 5 Clustern, einer maximalen Cluster-Größe von 3.6 und hoher Optimierungsqualität kann z.B. so erstellt werden:

hr := F_VN_CreateLbgModel(
    ipMlModel           := ipMlModel,
    eLbgType            := TCVN_PC_CLUSTERER,
    nMaxClusters        := 5,
    fMaxClusterRadius   := 3.6,
    bSingleSplitSteps   := TRUE,
    hrPrev              := hr);

Required License

TC3 Vision Machine Learning

System Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT V3.1. 4024.44 or later

PC or CX (x64) with PL50, e.g. Intel 4-core Atom CPU

Tc3_Vision