Machine Learning - Save Variable(s) - Predicted Values

From Q
Jump to navigation Jump to search

Creates a new variable containing predicted values for each case in the data from a model (e.g., from Machine Learning - Random Forestrandom forest). Observations with missing values in the predictors are predicted as NA.

Example

A table of categorical predictions.

Technical details

Uses the predict method from R. Unlike the defaults in most R packages, this implementation assigns predicted values for observations not in the estimation sample. Categorical variables are predicted as discrete.

Code

includeWeb('QScript R Output Functions');

saveVariables('Predicted values', 'Machine Learning, MachineLearningEnsemble or Regression',
              'predict(', ')', null, null, 'pred.val', ['MachineLearning', 'MachineLearningEnsemble', 'Regression']);