59 lines
2.3 KiB
R
59 lines
2.3 KiB
R
% Generated by roxygen2: do not edit by hand
|
|
% Please edit documentation in R/xgb.Booster.R
|
|
\name{predict.xgb.Booster}
|
|
\alias{predict.xgb.Booster}
|
|
\alias{predict.xgb.Booster.handle}
|
|
\title{Predict method for eXtreme Gradient Boosting model}
|
|
\usage{
|
|
\method{predict}{xgb.Booster}(object, newdata, missing = NA,
|
|
outputmargin = FALSE, ntreelimit = NULL, predleaf = FALSE)
|
|
|
|
\method{predict}{xgb.Booster.handle}(object, ...)
|
|
}
|
|
\arguments{
|
|
\item{object}{Object of class \code{xgb.Booster} or \code{xgb.Booster.handle}}
|
|
|
|
\item{newdata}{takes \code{matrix}, \code{dgCMatrix}, local data file or
|
|
\code{xgb.DMatrix}.}
|
|
|
|
\item{missing}{Missing is only used when input is dense matrix, pick a float
|
|
value that represents missing value. Sometime a data use 0 or other extreme value to represents missing values.}
|
|
|
|
\item{outputmargin}{whether the prediction should be shown in the original
|
|
value of sum of functions, when outputmargin=TRUE, the prediction is
|
|
untransformed margin value. In logistic regression, outputmargin=T will
|
|
output value before logistic transformation.}
|
|
|
|
\item{ntreelimit}{limit number of trees used in prediction, this parameter is
|
|
only valid for gbtree, but not for gblinear. set it to be value bigger
|
|
than 0. It will use all trees by default.}
|
|
|
|
\item{predleaf}{whether predict leaf index instead. If set to TRUE, the output will be a matrix object.}
|
|
|
|
\item{...}{Parameters pass to \code{predict.xgb.Booster}}
|
|
}
|
|
\description{
|
|
Predicted values based on either xgboost model or model handle object.
|
|
}
|
|
\details{
|
|
The option \code{ntreelimit} purpose is to let the user train a model with lots
|
|
of trees but use only the first trees for prediction to avoid overfitting
|
|
(without having to train a new model with less trees).
|
|
|
|
The option \code{predleaf} purpose is inspired from §3.1 of the paper
|
|
\code{Practical Lessons from Predicting Clicks on Ads at Facebook}.
|
|
The idea is to use the model as a generator of new features which capture non linear link
|
|
from original features.
|
|
}
|
|
\examples{
|
|
data(agaricus.train, package='xgboost')
|
|
data(agaricus.test, package='xgboost')
|
|
train <- agaricus.train
|
|
test <- agaricus.test
|
|
|
|
bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
|
|
eta = 1, nthread = 2, nround = 2,objective = "binary:logistic")
|
|
pred <- predict(bst, test$data)
|
|
}
|
|
|