REGRESS_RF: Random Forest Regression

How to:

REGRESS_RF creates a random forest, which is an ensemble of decision trees. Each decision tree produces an independent regression prediction, and the prediction of the forest is the average of the individual predictions.

Syntax: How to Calculate a Random Forest Regression

REGRESS_RF('options',  
         predictor_field1[, predictor_field2, ...] target_field)

where:

'options'

Is a dictionary of advanced parameters that control the model attributes, enclosed in single quotation marks. Most of these parameters have a default value, so you can omit them from the request, if you want to use the default values. Even with no advanced parameters, the single quotation marks are required. The format of the advanced parameter dictionary is:

'{"parm_name1": "parm_value1", ... ,"parm_namei": "parm_valuei"}'

The following advanced parameters are supported:

"trees"

Is the number of decision trees in the forest. Allowed values are integers greater than 10. The default value is "100".

"feature_importances"

Specifies whether to compute feature importances. Valid values are "yes" and "no". The default value is "yes".

"train_ratio"

Is a value between 0 and 1 that specifies the fraction of data used for training the model. The default value is "0.8".

"test_ratio"

Is a value between 0 and 1 that specifies the fraction of data used for testing the model. The default value is "0.2".

"min_values_leaf_grid"

Is a grid of the minimum number of samples required in a node in order to split the node, or a single value. The optimal value is chosen by cross-validation. The default value is "1,3,5".

predictor_field1[, predictor_field2, ...]

Numeric or Alphanumeric

Are one or more predictor field names.

target_field

Numeric

Is the target field.

Example: Predicting Price Using REGRESS_RF

The following procedure uses REGRESS_RF to predict price, using a random forest with default values for all of the advanced parameters, and with predictors number of doors, body style, height, horsepower, peak RPM, city MPG, and highway MPG.

TABLE FILE imports85
PRINT price 
COMPUTE predictedPrice/I5 = REGRESS_RF('',
                 numOfDoors, bodyStyle, height, horsepower, 
                 peakRpm, cityMpg, highwayMpg, price);
WHERE price LT 30000
ON TABLE SET PAGE NOLEAD
ON TABLE SET STYLE *
GRID=OFF,$
ENDSTYLE
END

Partial output is shown in the following image.