man/examples/predict.R

# 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.

Try the hhcartr package in your browser

Any scripts or data that you put into this service are public.

hhcartr documentation built on July 2, 2021, 9:06 a.m.