Learn R Programming

policytree (version 1.0.1)

predict.policy_tree: Predict method for policy_tree

Description

Predict values based on fitted policy_tree object.

Usage

# S3 method for policy_tree
predict(object, newdata, ...)

Arguments

object

policy_tree object

newdata

A data frame with features

...

Additional arguments (currently ignored).

Value

A vector of predictions. Each element is an integer from 1 to d where d is the number of columns in the reward matrix.

Examples

Run this code
# NOT RUN {
n <- 50
p <- 10
d <- 3
features <- matrix(rnorm(n * p), n, p)
rewards <- matrix(rnorm(n * d), n, d)
tree <- policy_tree(features, rewards, depth = 2)
print(tree)
predict(tree, features)
# }

Run the code above in your browser using DataLab