The forestScore action scores an input table using a previously trained forest model. It generates predicted values and can optionally produce misclassification rates (for classification) or mean squared errors (for regression). The action supports various scoring options including generating predicted probabilities for assessment, handling missing values, calculating variable interaction importance, and outputting the results to a new CAS table.
| Parameter | Description |
|---|---|
| applyRowOrder | Specifies whether to use a prespecified row ordering. This requires using the orderby and groupby parameters on a preliminary table.partition action call. Alias: reproducibleRowOrder. |
| assess | When set to True, predicted probabilities are added to the result table for the event levels, enabling use with the assess action. |
| assessOneRow | When set to True, predicted probabilities for all event levels are included as separate columns (named with prefix _DT_P_) in the result table. |
| casOut | Specifies the output table settings to store the scored results. If not specified, the action only computes statistics. |
| copyVars | Specifies the variables to copy from the input table to the output table. Alias: copyVar. |
| encodeName | Specifies whether to encode the variable names, such as using the prefix P_ instead of _DT_P_ for predicted probabilities. |
| impute | Specifies how to handle observations with non-missing values for the target. When True, observed values are assumed known without error and used as predicted values. |
| includeMissing | Specifies whether to include observations with missing values. When False, observations with missing values for model variables are ignored. |
| isolation | Specifies isolation forest scoring options. Default is FALSE. |
| modelId | Specifies the variable name for the model ID in the scored table. |
| modelTable | Specifies the table containing the trained forest model. This is a required parameter. Alias: model. |
| nTree | Specifies the number of trees to use during scoring. Alias: nTrees. |
| rbaImp | Specifies whether to calculate variable importance using the random branch assignments (RBA) method. |
| seed | Specifies the random number generator seed. Set to a positive value for reproducibility. |
| table | Specifies the input table to be scored. This is a required parameter. |
| target | Specifies the target variable name. Not required if the target name in the model matches the input table. |
| treeError | When set to True, computes the error for each tree. |
| treeVotes | Requests that the scored table be enhanced with information about the votes of individual trees. |
| varIntImp | Requests variable interaction importance and specifies the maximum degree of interaction (Range: 0-3). |
| vote | Specifies the voting strategy for classification: 'MAJORITY' (majority vote) or 'PROB' (average probability). |
Loads the HMEQ sample dataset and trains a forest model to be used in the scoring examples.
| 1 | PROC CAS; |
| 2 | SESSION casauto; |
| 3 | TABLE.loadTable RESULT=r STATUS=rc / caslib="samplibrary" path="hmeq.csv" casout={name="hmeq", replace=true}; |
| 4 | decisionTree.forestTrain / TABLE={name="hmeq", where="BAD is not null"} target="BAD" inputs={"LOAN", "MORTDUE", "VALUE", "REASON", "JOB", "YOJ", "DEROG", "DELINQ", "CLAGE", "NINQ", "CLNO", "DEBTINC"} nominals={"BAD", "REASON", "JOB"} modelTable={name="forest_model", replace=true}; |
| 5 | RUN; |
Scores the HMEQ table using the trained forest model and prints the misclassification rate.
| 1 | |
| 2 | PROC CAS; |
| 3 | |
| 4 | decisionTree.forestScore / TABLE="hmeq" modelTable="forest_model"; |
| 5 | |
| 6 | |
| 7 | RUN; |
| 8 |
Scores the table while generating an output table with probabilities, encoded names, and copied variables. It also computes variable interaction importance.
| 1 | PROC CAS; |
| 2 | decisionTree.forestScore / |
| 3 | TABLE="hmeq" |
| 4 | modelTable="forest_model" |
| 5 | casOut={name="hmeq_scored", replace=true} |
| 6 | copyVars={"LOAN", "BAD"} |
| 7 | assess=true |
| 8 | encodeName=true |
| 9 | vote="PROB" |
| 10 | varIntImp=1; |
| 11 | TABLE.fetch / TABLE="hmeq_scored" to=5; |
| 12 | RUN; |