tRandomForestModel properties in Spark Batch Jobs - 6.1

Talend Components Reference Guide

Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for Big Data
Talend Open Studio for Data Integration
Talend Open Studio for Data Quality
Talend Open Studio for ESB
Talend Open Studio for MDM
Talend Real-Time Big Data Platform
Talend Studio
Data Governance
Data Quality and Preparation
Design and Development

Component family

Machine Learning / Classification


Basic settings

Label column

Select the input column used to provide classification labels. The records of this column are used as the class names (Target in terms of classification) of the elements to be classified.


Feature column

Select the input column used to provide features. Very often, this column is the output of the Vector assembler computations performed by tModelEncoder.


Save the model on file system

Select this check box to store the model in a given file system.


Number of trees in the forest

Enter the number of decision trees you want tRandomForestModel to build.

Each decision tree is trained independently using a random sample of features.

Increasing this number can improve the accuracy by decreasing the variance in predictions, but will increase the training time.

Maximum depth of each tree in the forest

Enter the decision tree depth at which the training should stop adding new nodes. New nodes represent further tests on features on internal nodes and possible class labels held by leaf nodes.

For example, depth 1 means 1 internal node plus 2 leaf nodes.

Generally speaking, a deeper decision tree is more expressive and thus potentially more accurate in predictions, but it is also more resource consuming and prone to overfitting.

Advanced settings

Subsampling rate

Enter the numeric value to indicate the fraction of the input dataset used for training each tree in the forest. The default value 1.0 is recommended, meaning to take the whole dataset for test.


Subset strategy

Select the strategy about how many features should be considered on each internal node in order to appropriately split this internal node (actually the training set or subset of a feature on this node) into smaller subsets. These subsets are used to build child nodes.

Each strategy takes a different number of features into account to find the optimal point among these features for split. This point could be, for example, the age 35 of the categorical feature age.

  • auto: this strategy is based on the number of trees you have set in the Number of trees in the forest field in the Basic settings view. This is the default strategy to be used.

    If the number of trees is 1, the strategy is actually all; if this number is greater than 1, the strategy is sqrt.

  • all: the total number of features is considered for split.

  • sqrt: the number of features to be considered is the square root of the total number of features.

  • log2: the number of features to be considered is the result of log2(M), in which M is the total number of features.


Max bins

Enter the numeric value to indicate the maximum number of bins used for splitting features.

The continuous features are automatically transformed to ordered discrete features.


Min info gain

Enter the minimum number of information gain to be expected from a parent node to its child nodes. When the number of information gain is less than this minimum number, node split is stopped.

The default value of the minimum number of information gain is 0.0, meaning that no further information is obtained by splitting a given node. As a result, the splitting could be stopped.

For further information about how the information gain is calculated, see Impurity and Information gain from the Spark documentation.


Min instances per node

Enter the minimum number of training instances a node should have to make it valid for further splitting.

The default value is 1, which means when a node has only 1 row of training data, it stops splitting.



Select the measure used to select the best split from each set of splits.

  • gini: it is about how often an element could be incorrectly labelled in a split.

  • entropy: it is about how unpredictable the information in each split is.

For further information about how each of the measures is calculated, see Impurity measures from the Spark documentation.


Set a random seed

Enter the random seed number to be used for bootstrapping and choosing feature subsets.

Usage in Spark Batch Jobs

In a Talend Spark Batch Job, it is used as an end component and requires an input link. The other components used along with it must be Spark Batch components, too. They generate native Spark code that can be executed directly in a Spark cluster.

You can accelerate the training process by adjusting the stopping conditions such as the maximum depth of each decision tree, the maximum number of bins of splitting or the minimum number of information gain, but note that the training that stops too early could impact its performance.

Model evaluation

The parameters you need to set are free parameters and so their values may be provided by previous experiments, empirical guesses or the like. They do not have any optimal values applicable for all datasets.

Therefore, you need to train the classifier model you are generating with different sets of parameter values until you can obtain the best confusion matrix.

You need to select the scores to be used depending on the algorithm you want to use to train your classifier model. This allows you to build the most relevant confusion matrix.

For examples about how the confusion matrix is used in a Talend Job for classification, see Creating a classification model to filter spam.

For a general explanation about confusion matrix, see from Wikipedia.

Spark Connection

You need to use the Spark Configuration tab in the Run view to define the connection to a given Spark cluster for the whole Job. In addition, since the Job expects its dependent jar files for execution, one and only one file system related component from the Storage family is required in the same Job so that Spark can use this component to connect to the file system to which the jar files dependent on the Job are transferred:

This connection is effective on a per-Job basis.


If you are using a subscription-based version of the Studio, the activity of this component can be logged using the log4j feature. For more information on this feature, see Talend Studio User Guide.

For more information on the log4j logging levels, see the Apache documentation at