fix additional files note (#4699)
* fix additional files note * Trigger CI * Trigger CI
This commit is contained in:
parent
59bc1ef330
commit
7b74b1b64d
@ -2,7 +2,7 @@ Package: xgboost
|
|||||||
Type: Package
|
Type: Package
|
||||||
Title: Extreme Gradient Boosting
|
Title: Extreme Gradient Boosting
|
||||||
Version: 1.0.0.1
|
Version: 1.0.0.1
|
||||||
Date: 2019-07-17
|
Date: 2019-07-23
|
||||||
Authors@R: c(
|
Authors@R: c(
|
||||||
person("Tianqi", "Chen", role = c("aut"),
|
person("Tianqi", "Chen", role = c("aut"),
|
||||||
email = "tianqi.tchen@gmail.com"),
|
email = "tianqi.tchen@gmail.com"),
|
||||||
|
|||||||
@ -95,6 +95,7 @@ xgb.get.handle <- function(object) {
|
|||||||
#' saveRDS(bst, "xgb.model.rds")
|
#' saveRDS(bst, "xgb.model.rds")
|
||||||
#'
|
#'
|
||||||
#' bst1 <- readRDS("xgb.model.rds")
|
#' bst1 <- readRDS("xgb.model.rds")
|
||||||
|
#' if (file.exists("xgb.model.rds")) file.remove("xgb.model.rds")
|
||||||
#' # the handle is invalid:
|
#' # the handle is invalid:
|
||||||
#' print(bst1$handle)
|
#' print(bst1$handle)
|
||||||
#'
|
#'
|
||||||
@ -418,6 +419,7 @@ predict.xgb.Booster.handle <- function(object, ...) {
|
|||||||
#'
|
#'
|
||||||
#' xgb.save(bst, 'xgb.model')
|
#' xgb.save(bst, 'xgb.model')
|
||||||
#' bst1 <- xgb.load('xgb.model')
|
#' bst1 <- xgb.load('xgb.model')
|
||||||
|
#' if (file.exists('xgb.model')) file.remove('xgb.model')
|
||||||
#' print(xgb.attr(bst1, "my_attribute"))
|
#' print(xgb.attr(bst1, "my_attribute"))
|
||||||
#' print(xgb.attributes(bst1))
|
#' print(xgb.attributes(bst1))
|
||||||
#'
|
#'
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
#' dtrain <- xgb.DMatrix(train$data, label=train$label)
|
#' dtrain <- xgb.DMatrix(train$data, label=train$label)
|
||||||
#' xgb.DMatrix.save(dtrain, 'xgb.DMatrix.data')
|
#' xgb.DMatrix.save(dtrain, 'xgb.DMatrix.data')
|
||||||
#' dtrain <- xgb.DMatrix('xgb.DMatrix.data')
|
#' dtrain <- xgb.DMatrix('xgb.DMatrix.data')
|
||||||
|
#' if (file.exists('xgb.DMatrix.data')) file.remove('xgb.DMatrix.data')
|
||||||
#' @export
|
#' @export
|
||||||
xgb.DMatrix <- function(data, info = list(), missing = NA, silent = FALSE, ...) {
|
xgb.DMatrix <- function(data, info = list(), missing = NA, silent = FALSE, ...) {
|
||||||
cnames <- NULL
|
cnames <- NULL
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
#' dtrain <- xgb.DMatrix(train$data, label=train$label)
|
#' dtrain <- xgb.DMatrix(train$data, label=train$label)
|
||||||
#' xgb.DMatrix.save(dtrain, 'xgb.DMatrix.data')
|
#' xgb.DMatrix.save(dtrain, 'xgb.DMatrix.data')
|
||||||
#' dtrain <- xgb.DMatrix('xgb.DMatrix.data')
|
#' dtrain <- xgb.DMatrix('xgb.DMatrix.data')
|
||||||
|
#' if (file.exists('xgb.DMatrix.data')) file.remove('xgb.DMatrix.data')
|
||||||
#' @export
|
#' @export
|
||||||
xgb.DMatrix.save <- function(dmatrix, fname) {
|
xgb.DMatrix.save <- function(dmatrix, fname) {
|
||||||
if (typeof(fname) != "character")
|
if (typeof(fname) != "character")
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
#' eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
|
#' eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
|
||||||
#' xgb.save(bst, 'xgb.model')
|
#' xgb.save(bst, 'xgb.model')
|
||||||
#' bst <- xgb.load('xgb.model')
|
#' bst <- xgb.load('xgb.model')
|
||||||
|
#' if (file.exists('xgb.model')) file.remove('xgb.model')
|
||||||
#' pred <- predict(bst, test$data)
|
#' pred <- predict(bst, test$data)
|
||||||
#' @export
|
#' @export
|
||||||
xgb.load <- function(modelfile) {
|
xgb.load <- function(modelfile) {
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
#' eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
|
#' eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
|
||||||
#' xgb.save(bst, 'xgb.model')
|
#' xgb.save(bst, 'xgb.model')
|
||||||
#' bst <- xgb.load('xgb.model')
|
#' bst <- xgb.load('xgb.model')
|
||||||
|
#' if (file.exists('xgb.model')) file.remove('xgb.model')
|
||||||
#' pred <- predict(bst, test$data)
|
#' pred <- predict(bst, test$data)
|
||||||
#' @export
|
#' @export
|
||||||
xgb.save <- function(model, fname) {
|
xgb.save <- function(model, fname) {
|
||||||
|
|||||||
@ -7,8 +7,8 @@
|
|||||||
\usage{
|
\usage{
|
||||||
\method{predict}{xgb.Booster}(object, newdata, missing = NA,
|
\method{predict}{xgb.Booster}(object, newdata, missing = NA,
|
||||||
outputmargin = FALSE, ntreelimit = NULL, predleaf = FALSE,
|
outputmargin = FALSE, ntreelimit = NULL, predleaf = FALSE,
|
||||||
predcontrib = FALSE, approxcontrib = FALSE,
|
predcontrib = FALSE, approxcontrib = FALSE, predinteraction = FALSE,
|
||||||
predinteraction = FALSE, reshape = FALSE, ...)
|
reshape = FALSE, ...)
|
||||||
|
|
||||||
\method{predict}{xgb.Booster.handle}(object, ...)
|
\method{predict}{xgb.Booster.handle}(object, ...)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,7 @@ bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max_dep
|
|||||||
saveRDS(bst, "xgb.model.rds")
|
saveRDS(bst, "xgb.model.rds")
|
||||||
|
|
||||||
bst1 <- readRDS("xgb.model.rds")
|
bst1 <- readRDS("xgb.model.rds")
|
||||||
|
if (file.exists("xgb.model.rds")) file.remove("xgb.model.rds")
|
||||||
# the handle is invalid:
|
# the handle is invalid:
|
||||||
print(bst1$handle)
|
print(bst1$handle)
|
||||||
|
|
||||||
|
|||||||
@ -31,4 +31,5 @@ train <- agaricus.train
|
|||||||
dtrain <- xgb.DMatrix(train$data, label=train$label)
|
dtrain <- xgb.DMatrix(train$data, label=train$label)
|
||||||
xgb.DMatrix.save(dtrain, 'xgb.DMatrix.data')
|
xgb.DMatrix.save(dtrain, 'xgb.DMatrix.data')
|
||||||
dtrain <- xgb.DMatrix('xgb.DMatrix.data')
|
dtrain <- xgb.DMatrix('xgb.DMatrix.data')
|
||||||
|
if (file.exists('xgb.DMatrix.data')) file.remove('xgb.DMatrix.data')
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,4 +20,5 @@ train <- agaricus.train
|
|||||||
dtrain <- xgb.DMatrix(train$data, label=train$label)
|
dtrain <- xgb.DMatrix(train$data, label=train$label)
|
||||||
xgb.DMatrix.save(dtrain, 'xgb.DMatrix.data')
|
xgb.DMatrix.save(dtrain, 'xgb.DMatrix.data')
|
||||||
dtrain <- xgb.DMatrix('xgb.DMatrix.data')
|
dtrain <- xgb.DMatrix('xgb.DMatrix.data')
|
||||||
|
if (file.exists('xgb.DMatrix.data')) file.remove('xgb.DMatrix.data')
|
||||||
}
|
}
|
||||||
|
|||||||
@ -73,6 +73,7 @@ xgb.attributes(bst) <- list(a = 123, b = "abc")
|
|||||||
|
|
||||||
xgb.save(bst, 'xgb.model')
|
xgb.save(bst, 'xgb.model')
|
||||||
bst1 <- xgb.load('xgb.model')
|
bst1 <- xgb.load('xgb.model')
|
||||||
|
if (file.exists('xgb.model')) file.remove('xgb.model')
|
||||||
print(xgb.attr(bst1, "my_attribute"))
|
print(xgb.attr(bst1, "my_attribute"))
|
||||||
print(xgb.attributes(bst1))
|
print(xgb.attributes(bst1))
|
||||||
|
|
||||||
|
|||||||
@ -4,12 +4,11 @@
|
|||||||
\alias{xgb.cv}
|
\alias{xgb.cv}
|
||||||
\title{Cross Validation}
|
\title{Cross Validation}
|
||||||
\usage{
|
\usage{
|
||||||
xgb.cv(params = list(), data, nrounds, nfold, label = NULL,
|
xgb.cv(params = list(), data, nrounds, nfold, label = NULL, missing = NA,
|
||||||
missing = NA, prediction = FALSE, showsd = TRUE,
|
prediction = FALSE, showsd = TRUE, metrics = list(), obj = NULL,
|
||||||
metrics = list(), obj = NULL, feval = NULL, stratified = TRUE,
|
feval = NULL, stratified = TRUE, folds = NULL, verbose = TRUE,
|
||||||
folds = NULL, verbose = TRUE, print_every_n = 1L,
|
print_every_n = 1L, early_stopping_rounds = NULL, maximize = NULL,
|
||||||
early_stopping_rounds = NULL, maximize = NULL, callbacks = list(),
|
callbacks = list(), ...)
|
||||||
...)
|
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{params}{the list of parameters. Commonly used ones are:
|
\item{params}{the list of parameters. Commonly used ones are:
|
||||||
|
|||||||
@ -33,6 +33,7 @@ bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
|
|||||||
eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
|
eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
|
||||||
xgb.save(bst, 'xgb.model')
|
xgb.save(bst, 'xgb.model')
|
||||||
bst <- xgb.load('xgb.model')
|
bst <- xgb.load('xgb.model')
|
||||||
|
if (file.exists('xgb.model')) file.remove('xgb.model')
|
||||||
pred <- predict(bst, test$data)
|
pred <- predict(bst, test$data)
|
||||||
}
|
}
|
||||||
\seealso{
|
\seealso{
|
||||||
|
|||||||
@ -5,11 +5,11 @@
|
|||||||
\alias{xgb.plot.deepness}
|
\alias{xgb.plot.deepness}
|
||||||
\title{Plot model trees deepness}
|
\title{Plot model trees deepness}
|
||||||
\usage{
|
\usage{
|
||||||
xgb.ggplot.deepness(model = NULL, which = c("2x1", "max.depth",
|
xgb.ggplot.deepness(model = NULL, which = c("2x1", "max.depth", "med.depth",
|
||||||
"med.depth", "med.weight"))
|
"med.weight"))
|
||||||
|
|
||||||
xgb.plot.deepness(model = NULL, which = c("2x1", "max.depth",
|
xgb.plot.deepness(model = NULL, which = c("2x1", "max.depth", "med.depth",
|
||||||
"med.depth", "med.weight"), plot = TRUE, ...)
|
"med.weight"), plot = TRUE, ...)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{model}{either an \code{xgb.Booster} model generated by the \code{xgb.train} function
|
\item{model}{either an \code{xgb.Booster} model generated by the \code{xgb.train} function
|
||||||
|
|||||||
@ -9,8 +9,8 @@ xgb.ggplot.importance(importance_matrix = NULL, top_n = NULL,
|
|||||||
measure = NULL, rel_to_first = FALSE, n_clusters = c(1:10), ...)
|
measure = NULL, rel_to_first = FALSE, n_clusters = c(1:10), ...)
|
||||||
|
|
||||||
xgb.plot.importance(importance_matrix = NULL, top_n = NULL,
|
xgb.plot.importance(importance_matrix = NULL, top_n = NULL,
|
||||||
measure = NULL, rel_to_first = FALSE, left_margin = 10,
|
measure = NULL, rel_to_first = FALSE, left_margin = 10, cex = NULL,
|
||||||
cex = NULL, plot = TRUE, ...)
|
plot = TRUE, ...)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{importance_matrix}{a \code{data.table} returned by \code{\link{xgb.importance}}.}
|
\item{importance_matrix}{a \code{data.table} returned by \code{\link{xgb.importance}}.}
|
||||||
|
|||||||
@ -6,8 +6,8 @@
|
|||||||
\usage{
|
\usage{
|
||||||
xgb.plot.shap(data, shap_contrib = NULL, features = NULL, top_n = 1,
|
xgb.plot.shap(data, shap_contrib = NULL, features = NULL, top_n = 1,
|
||||||
model = NULL, trees = NULL, target_class = NULL,
|
model = NULL, trees = NULL, target_class = NULL,
|
||||||
approxcontrib = FALSE, subsample = NULL, n_col = 1, col = rgb(0,
|
approxcontrib = FALSE, subsample = NULL, n_col = 1, col = rgb(0, 0, 1,
|
||||||
0, 1, 0.2), pch = ".", discrete_n_uniq = 5, discrete_jitter = 0.01,
|
0.2), pch = ".", discrete_n_uniq = 5, discrete_jitter = 0.01,
|
||||||
ylab = "SHAP", plot_NA = TRUE, col_NA = rgb(0.7, 0, 1, 0.6),
|
ylab = "SHAP", plot_NA = TRUE, col_NA = rgb(0.7, 0, 1, 0.6),
|
||||||
pch_NA = ".", pos_NA = 1.07, plot_loess = TRUE, col_loess = 2,
|
pch_NA = ".", pos_NA = 1.07, plot_loess = TRUE, col_loess = 2,
|
||||||
span_loess = 0.5, which = c("1d", "2d"), plot = TRUE, ...)
|
span_loess = 0.5, which = c("1d", "2d"), plot = TRUE, ...)
|
||||||
|
|||||||
@ -33,6 +33,7 @@ bst <- xgboost(data = train$data, label = train$label, max_depth = 2,
|
|||||||
eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
|
eta = 1, nthread = 2, nrounds = 2,objective = "binary:logistic")
|
||||||
xgb.save(bst, 'xgb.model')
|
xgb.save(bst, 'xgb.model')
|
||||||
bst <- xgb.load('xgb.model')
|
bst <- xgb.load('xgb.model')
|
||||||
|
if (file.exists('xgb.model')) file.remove('xgb.model')
|
||||||
pred <- predict(bst, test$data)
|
pred <- predict(bst, test$data)
|
||||||
}
|
}
|
||||||
\seealso{
|
\seealso{
|
||||||
|
|||||||
@ -5,17 +5,15 @@
|
|||||||
\alias{xgboost}
|
\alias{xgboost}
|
||||||
\title{eXtreme Gradient Boosting Training}
|
\title{eXtreme Gradient Boosting Training}
|
||||||
\usage{
|
\usage{
|
||||||
xgb.train(params = list(), data, nrounds, watchlist = list(),
|
xgb.train(params = list(), data, nrounds, watchlist = list(), obj = NULL,
|
||||||
obj = NULL, feval = NULL, verbose = 1, print_every_n = 1L,
|
feval = NULL, verbose = 1, print_every_n = 1L,
|
||||||
early_stopping_rounds = NULL, maximize = NULL, save_period = NULL,
|
early_stopping_rounds = NULL, maximize = NULL, save_period = NULL,
|
||||||
save_name = "xgboost.model", xgb_model = NULL, callbacks = list(),
|
save_name = "xgboost.model", xgb_model = NULL, callbacks = list(), ...)
|
||||||
...)
|
|
||||||
|
|
||||||
xgboost(data = NULL, label = NULL, missing = NA, weight = NULL,
|
xgboost(data = NULL, label = NULL, missing = NA, weight = NULL,
|
||||||
params = list(), nrounds, verbose = 1, print_every_n = 1L,
|
params = list(), nrounds, verbose = 1, print_every_n = 1L,
|
||||||
early_stopping_rounds = NULL, maximize = NULL, save_period = NULL,
|
early_stopping_rounds = NULL, maximize = NULL, save_period = NULL,
|
||||||
save_name = "xgboost.model", xgb_model = NULL, callbacks = list(),
|
save_name = "xgboost.model", xgb_model = NULL, callbacks = list(), ...)
|
||||||
...)
|
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{params}{the list of parameters.
|
\item{params}{the list of parameters.
|
||||||
|
|||||||
@ -163,6 +163,7 @@ test_that("xgb-attribute functionality", {
|
|||||||
# serializing:
|
# serializing:
|
||||||
xgb.save(bst.Tree, 'xgb.model')
|
xgb.save(bst.Tree, 'xgb.model')
|
||||||
bst <- xgb.load('xgb.model')
|
bst <- xgb.load('xgb.model')
|
||||||
|
if (file.exists('xgb.model')) file.remove('xgb.model')
|
||||||
expect_equal(xgb.attr(bst, "my_attr"), val)
|
expect_equal(xgb.attr(bst, "my_attr"), val)
|
||||||
expect_equal(xgb.attributes(bst), list.ch)
|
expect_equal(xgb.attributes(bst), list.ch)
|
||||||
# deletion:
|
# deletion:
|
||||||
@ -199,10 +200,12 @@ if (grepl('Windows', Sys.info()[['sysname']]) ||
|
|||||||
test_that("xgb.Booster serializing as R object works", {
|
test_that("xgb.Booster serializing as R object works", {
|
||||||
saveRDS(bst.Tree, 'xgb.model.rds')
|
saveRDS(bst.Tree, 'xgb.model.rds')
|
||||||
bst <- readRDS('xgb.model.rds')
|
bst <- readRDS('xgb.model.rds')
|
||||||
|
if (file.exists('xgb.model.rds')) file.remove('xgb.model.rds')
|
||||||
dtrain <- xgb.DMatrix(sparse_matrix, label = label)
|
dtrain <- xgb.DMatrix(sparse_matrix, label = label)
|
||||||
expect_equal(predict(bst.Tree, dtrain), predict(bst, dtrain), tolerance = float_tolerance)
|
expect_equal(predict(bst.Tree, dtrain), predict(bst, dtrain), tolerance = float_tolerance)
|
||||||
expect_equal(xgb.dump(bst.Tree), xgb.dump(bst))
|
expect_equal(xgb.dump(bst.Tree), xgb.dump(bst))
|
||||||
xgb.save(bst, 'xgb.model')
|
xgb.save(bst, 'xgb.model')
|
||||||
|
if (file.exists('xgb.model')) file.remove('xgb.model')
|
||||||
nil_ptr <- new("externalptr")
|
nil_ptr <- new("externalptr")
|
||||||
class(nil_ptr) <- "xgb.Booster.handle"
|
class(nil_ptr) <- "xgb.Booster.handle"
|
||||||
expect_true(identical(bst$handle, nil_ptr))
|
expect_true(identical(bst$handle, nil_ptr))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user