score.DecisionTreeRegressor.Rd
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, ...)
S3
methods
R6Class object
A "DecisionTreeRegressor" object for scoring.
DataFrame
DataFrame containting the data.
character
Name of the ID column.
character of list of characters, optional
Name of feature columns.
If not provided, it defaults all non-key, non-label columns of data.
character, optional
Name of the column which specifies the dependent variable.
Defaults to the last column of data if not provided.
Reserved parameters.
numeric
The r2 score for data
, no greater than 1.
Call the function and obtain the result:
> scr <- score(dtr, data=data2, key="ID")
[1] 0.53