Repository navigation
Expand file tree
/
Copy pathpredict.bartMachine.Rd
More file actions
80 lines (69 loc) · 2.83 KB
/
Copy pathpredict.bartMachine.Rd
File metadata and controls
80 lines (69 loc) · 2.83 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bart_package_predicts.R
\name{predict.bartMachine}
\alias{predict.bartMachine}
\title{Make a prediction on data using a BART object}
\usage{
\method{predict}{bartMachine}(
object,
new_data,
type = "prob",
prob_rule_class = NULL,
verbose = TRUE,
...
)
}
\arguments{
\item{object}{An object of class ``bartMachine''.}
\item{new_data}{A data frame where each row is an observation to predict. The column names
should be the same as the column names of the training data.}
\item{type}{Only relevant if the bartMachine model is classification. The type can be ``prob'' which will
return the estimate of \eqn{P(Y = 1)}(the ``positive'' class) or ``class'' which will return the best guess as to the
class of the object, in the original label, based on if the probability estimate is greater
than \code{prob_rule_class}. Default is ``prob.''}
\item{prob_rule_class}{The rule to determine when the class estimate is \eqn{Y = 1} (the ``positive'' class) based on the probability estimate. This
defaults to what was originally specified in the \code{bart_machine} object.}
\item{verbose}{Prints out prediction-related messages. Currently in use only for probability predictions to let the user know which class
is being predicted. Default is \code{TRUE}.}
\item{...}{Parameters that are ignored.}
}
\value{
If regression, a numeric vector of \code{y_hat}, the best guess as to the response. If classification and \code{type = ``prob''},
a numeric vector of \code{p_hat}, the best guess as to the probability of the response class being the ''positive'' class. If classification and
\code{type = ''class''}, a character vector of the best guess of the response's class labels.
}
\description{
Makes a prediction on new data given a fitted BART model for regression or classification.
}
\examples{
#Regression example
\dontrun{
#generate Friedman data
set.seed(11)
n = 200
p = 5
X = data.frame(matrix(runif(n * p), ncol = p))
y = 10 * sin(pi* X[ ,1] * X[,2]) +20 * (X[,3] -.5)^2 + 10 * X[ ,4] + 5 * X[,5] + rnorm(n)
##build BART regression model
bart_machine = bartMachine(X, y)
##make predictions on the training data
y_hat = predict(bart_machine, X)
#Classification example
data(iris)
iris2 = iris[51 : 150, ] #do not include the third type of flower for this example
iris2$Species = factor(iris2$Species)
bart_machine = bartMachine(iris2[ ,1:4], iris2$Species)
##make probability predictions on the training data
p_hat = predict(bart_machine, X)
##make class predictions on test data
y_hat_class = predict(bart_machine, X, type = "class")
##make class predictions on test data conservatively for ''versicolor''
y_hat_class_conservative = predict(bart_machine, X, type = "class", prob_rule_class = 0.9)
}
}
\seealso{
\code{\link{bart_predict_for_test_data}}
}
\author{
Adam Kapelner and Justin Bleich
}