F_VN_GetFeatureScales
Calculate the scaling parameters for each feature in the input samples based on the scaling type.
Syntax
Definition:
FUNCTION F_VN_GetFeatureScales : HRESULT
VAR_INPUT
ipSamples : ITcVnContainer;
ipScales : Reference To ITcVnContainer;
eFeatureScalingType : ETcVnFeatureScalingType;
hrPrev : HRESULT;
END_VAR
Inputs
Name |
Type |
Description |
---|---|---|
ipSamples |
Container holding input sample(s) (ContainerType_Vector_REAL, ContainerType_Vector_LREAL, ContainerType_Vector_Vector_REAL or ContainerType_Vector_Vector_LREAL) | |
ipScales |
Reference To ITcVnContainer |
Returns a container with the scaling parameters for each feature (Vector_REAL or Vector_LREAL depending on the type of ipSamples). |
eFeatureScalingType |
Feature scaling type | |
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
Further information
The function F_VN_GetFeatureScales
calculates scaling parameters for each feature value of the samples transferred. The corresponding scaling can then be applied using the F_VN_FeatureScaling function for feature normalization. The same scaling can also be used with F_VN_InverseFeatureScaling to invert the scaling of the prediction results of a regression.
Parameter
Samples
The samples used to calculate the scaling parameters are transferred as containers to ipSamples
. The number of feature values must be the same for each sample.
Scaling
The calculated scaling parameters are returned as a container via the reference ipScales
. The number and order of the elements in the container depend on the scaling type, which is always found in the first element. With MAXABS
there is always one scaling value per feature. For the other types, there are always two scaling values per feature.
Scaling type
The desired scaling type is transferred to eFeatureScalingType
as the enum ETcVnFeatureScalingType. The options are:
TCVN_FST1_MAXABS:
Uses the maximum of the absolute feature values to obtain a normalization in the range from -1 to 1. If all values are positive, normalization is performed from 0 to 1.TCVN_FST1_MINMAX:
Uses the minimum and maximum values of the feature values to obtain a normalization in the range from 0 to 1.TCVN_FST1_STANDARDIZATION:
Uses the mean value and the standard deviation of the feature values to obtain a normalization of the vector mean values equal to 0 and the vector standard deviation equal to 1.
Application
For example, the calculation of scaling parameters using the MINMAX
method looks like this:
hr := F_VN_GetFeatureScales(
ipSamples := ipSamples,
ipScales := ipScales,
eFeatureScalingType := TCVN_FST1
_MINMAX,
hrPrev := hr);
If the number of feature values per sample in ipSamples
is 12
, for example, ipScales
will have exactly 1 + 2 * 12 = 25
elements for this scaling type.
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 |