Description Usage Arguments Value Examples
View source: R/hhcartr_export_predict.R
This function creates a generic S3method predict which is used to call predict.hhcartr when an object of type hhcartr passed to the predict function, i.e. an object that is returned from the fit() function. The object created from the predict function supports the accuracy and predictions methods. The accuracy method returns the accuracy achieved on the test_data and the method predictions returns the actual predictions made on the test_data.
1 2 |
object |
Unused parameter. |
... |
Unused parameter. |
test_data |
The test dataset the user wants to make predictions on. |
exposes the accuracy() and predictions() methods.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # source: /man/examples/predict.R
# Basic usage of predict().
# Note: we need to have a model to modify first.
# load our data.
X <- iris[,1:4]
y <- iris[,5]
# instantiate our model.
clf = HHDecisionTree(n_folds=1,
n_trees=1,
pruning=FALSE,
min_node_impurity=0.0)
# describe what dataset our model is using.
setDataDescription("IRIS Dataset")
# train our model.
model_output <- clf$fit(X, y)
# make predictions on an unseen test set.
# As the IRIS dataset provides no separate test set,
# for the sake of this example we will predict on the original data
# and pretend it is previously unseen data.
preds <- predict(model_output, test_data = iris)
# The predict object 'preds' exposes the following methods
# that we can use to extract the results of interest
# (depending upon model options used):
# preds$accuracy and preds$predictions.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.