F_VN_CreateRTreesModelExp2
Create a random trees 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. Predictions can only be scalar. (expert function)
Syntax
Definition:
FUNCTION F_VN_CreateRTreesModelExp2 : HRESULT
VAR_INPUT
ipMlModel : Reference To ITcVnMlModel;
eRTreesType : ETcVnRTrees;
nMaxDepth : UDINT;
nMinSamples : UDINT;
nActiveVariables : UDINT;
nMaxIterations : UDINT;
fEpsilon : LREAL;
fRegressionAccuracy : REAL;
ipClassPriors : ITcVnContainer;
hrPrev : HRESULT;
END_VAR
Inputs
Name |
Type |
Description |
---|---|---|
ipMlModel |
Reference To ITcVnMlModel |
Returns the created model (Non-zero interface pointers are reused.) |
eRTreesType |
Random trees model type | |
nMaxDepth |
UDINT |
Maximum tree depth (default: 5) |
nMinSamples |
UDINT |
Minimum number of samples within a node required for splitting (default: 10) |
nActiveVariables |
UDINT |
Number of variables considered for splitting (0 means sqrt(total number of variables); default: 0) |
nMaxIterations |
UDINT |
Maximum number of iterations (disabled if it equals 0 and fEpsilon is different from 0.0; triggers the usage of the default value of 50 if nMaxIterations and fEpsilon equal 0) |
fEpsilon |
LREAL |
Maximum allowed difference of the error between two successive iterations (disabled if it equals 0.0 and nMaxIterations is different from 0; triggers the usage of the default value of 0.1 if nMaxIterations and fEpsilon equal 0) |
fRegressionAccuracy |
REAL |
Termination criterion for regressors (only for regressors; set to default if not allowed; default: 0.0) |
ipClassPriors |
Class priors (ContainerType_Vector_REAL or ContainerType_Vector_LREAL; only for classifiers; optional, set to 0 if not required or not allowed; default: 0) | |
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
Further information
The function F_VN_CreateRTReesModelExp2
is an expert variant of F_VN_CreateRTreesModel. It contains additional parameters.
Parameter
Model
The created model is returned in the interface pointer ipMlModel
.
Model type
eRTreesType
specifies whether the Random Forest model is used for classification (TCVN_RT_CLASSIFIER
) or for regression (TCVN_RT_REGRESSOR
).
Maximum tree depth
nMaxDepth
indicates the maximum number of decision levels in a tree.
Minimum number of samples within a node
nMinSamples
is the minimum number of samples that must remain in a node during tree formation. Splits that would fall below this number are not carried out.
Splitting features
nActiveVariables
is the number of features used to split the tree. With 0
, sqrt(N)
features are used with the number N
of all available features.
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.
Regression accuracy
fRegressionAccuracy
is the abort criterion for regression optimization. For a classification, the value must be set to 0
.
Class-Priors
ipClassPriors
is a container that can be used to specify the a priori probabilities of the individual classes. For a regression, the value should be set to 0
.
Application
For example, an RTrees model for regression can be created like this:
hr := F_VN_CreateRTreesExp2(
ipMlModel := ipMlModel,
eRTreesType := TCVN_RT_REGRESSOR,
nMaxDepth := 8,
nMinSamples := 4,
nActiveVariables := 0,
nMaxIterations := 0,
fEpsilon := 0,
fRegressionAccuracy := 0.3,
ipClassPriors := 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 |