F_VN_PredictBatch

F_VN_PredictBatch 1:

Compute predictions for a batch of samples.
Can use available TwinCAT Job Tasks for executing parallel code regions.

Syntax

Definition:

FUNCTION F_VN_PredictBatch : HRESULT
VAR_INPUT
    ipMlModel     : ITcVnMlModel;
    ipSamples     : ITcUnknown;
    ipPredictions : Reference To ITcVnContainer;
    hrPrev        : HRESULT;
END_VAR

F_VN_PredictBatch 2: Inputs

Name

Type

Description

ipMlModel

ITcVnMlModel

Classifier or regressor to be used

ipSamples

ITcUnknown

Container holding a batch of input samples (ContainerType_Vector_Vector_REAL or ContainerType_Vector_Vector_LREAL)

ipPredictions

Reference To ITcVnContainer

Returns the predicted outputs (depending on ipSamples; class labels (for classification, ContainerType_Vector_DINT) or real-valued predictions (for regression with scalar output, ContainerType_Vector_REAL or ContainerType_Vector_LREAL))

hrPrev

HRESULT

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

F_VN_PredictBatch 3: Return value

HRESULT

Weiterführende Informationen

Die Funktion F_VN_PredictBatch berechnet die Prädiktion eines Modells für mehrere Samples. Abhängig von der Art des Models haben die Prädiktionen einen unterschiedlichen Datentyp (siehe ipPredictions).

Parameter

Modell

Zur Prädiktion muss das zuvor trainierte Modell an ipMlModel übergeben werden.

Samples

Die Samples werden in einem Container an ipSamples übergeben. Der Typ des Containers muss ContainerType_Vector_Vector_REAL oder ContainerType_Vector_Vector_LREAL sein.

Prädiktionen

Die Prädiktionen werden in einem Container über die Referenz ipPredictions zurückgegeben. Je nach Typ des Modells hat der Container einen unterschiedlichen Typ:

  • Klassen-Label bei einer Klassifikation: ContainerType_Vector_DINT
  • Numerische Prädiktionswerte bei einer skalaren Regression: ContainerType_Vector_REAL oder ContainerType_Vector_LREAL, abhängig von ipSamples
  • Numerische Prädiktionswerte bei einer vektoriellen Regression: ContainerType_Vector_Vector_REAL oder ContainerType_Vector_Vector_LREAL, abhängig von ipSamples

Expert-Parameter

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

Anwendung

Mehrere Samples können z.B. so gleichzeitig klassifiziert werden:

hr := F_VN_PredictBatch(
    ipMlModel       :=  ipMlModel,
    ipSamples       :=  ipSamples,
    ipPredictions   :=  ipPredictions,
    hrPrev          :=  hr);

hr := F_VN_GetAt_DINT(ipPredictions, nClassOfThirdSample, 2, hr);

Der Aufruf von F_VN_GetAt_DINT zeigt, wie aus den Prädiktionen das Klassenlabel des 3. Samples abgerufen werden kann.

Verwandte Funktionen

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