F_VN_PredictBatchExp

F_VN_PredictBatchExp 1:

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

Syntax

Definition:

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

F_VN_PredictBatchExp 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; for regression with vectorial output, ContainerType_Vector_Vector_REAL or ContainerType_Vector_Vector_LREAL))

ipNovelties

Reference To ITcVnContainer

Returns the degree of novelty (0.0 if a sample is completely known; > 0.0 otherwise) of each sample (ContainerType_Vector_REAL; optional, set to 0 if not required)

hrPrev

HRESULT

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

F_VN_PredictBatchExp 3: Return value

HRESULT

Further information

The function F_VN_PredictBatchExp is the expert variant of F_VN_PredictBatch. It contains additional parameters.

Parameter

Model

For prediction, the previously trained model must be transferred to ipMlModel.

Samples

The samples are transferred to ipSamples in a container. The type of container must be ContainerType_Vector_Vector_REAL or ContainerType_Vector_Vector_LREAL.

Predictions

The predictions are returned in a container via the reference ipPredictions. Depending on the type of model, the container has a different type:

  • Class label for a classification: ContainerType_Vector_DINT
  • Numerical prediction values in a scalar regression: ContainerType_Vector_REAL or ContainerType_Vector_LREAL, depending on ipSamples
  • Numerical prediction values in a vector regression: ContainerType_Vector_Vector_REAL or ContainerType_Vector_Vector_LREAL, depending on ipSamples

Degrees of novelty

The degrees of novelty of the samples are returned as containers via the reference ipNovelties.

Application

For example, several samples can be classified at the same time:

hr := F_VN_PredictBatchExp(
    ipMlModel       := ipMlModel,
    ipSamples       := ipSamples,
    ipPredictions   := ipPredictions,
    ipNovelties     := ipNovelties,
    hrPrev          := hr);

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

The call of F_VN_GetAt_DINT shows how the class label of the 3rd sample can be get from the predictions.

Related functions

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