score.DecisionTreeClassifier.Rd
This function predicts class labels of given dataset from a fitted "DecisionTreeClassifier" object, compares them with the original labels, and returns the accuracy score.
# S3 method for DecisionTreeClassifier
score(model, data, key, features = NULL, label = NULL, ...)
S3
methods
R6Class object
A "DecisionTreeClassifier" 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 accuracy score for data
, ranges from 0 to 1.
Input DataFrame data2:
> data2$Collect()
ID OUTLOOK HUMIDITY TEMP WINDY CLASS
1 0 Overcast 75.0 70 Yes Play
2 1 Rain 78.0 70 Yes Do not Play
3 2 Sunny 66.0 70 Yes Play
4 3 Sunny 69.0 70 Yes Play
5 4 Rain NA 70 Yes Do not Play
6 5 <NA> 70.0 70 Yes Play
7 6 *** 70.0 70 Yes Do not Play
Call the function and obtain the result:
> scr <- score(dtc, data=data2, key="ID")
0.857