This function predicts fitted values of given dataset from a fitted "DecisionTreeRegressor" object, compares them with the true values, and returns the corresponding r2 score.

# S3 method for DecisionTreeRegressor
score(model, data, key, features = NULL, label = NULL, ...)

Format

S3 methods

Arguments

model

R6Class object
A "DecisionTreeRegressor" object for scoring.

data

DataFrame
DataFrame containting the data.

key

character
Name of the ID column.

features

character of list of characters, optional
Name of feature columns.
If not provided, it defaults all non-key, non-label columns of data.

label

character, optional
Name of the column which specifies the dependent variable.
Defaults to the last column of data if not provided.

...

Reserved parameters.

Value

numeric
The r2 score for data, no greater than 1.

Examples

Call the function and obtain the result:


> scr <- score(dtr, data=data2, key="ID")
[1] 0.53