From b67902ebddc5078df8209666920492608d06aa24 Mon Sep 17 00:00:00 2001 From: pommedeterresautee Date: Mon, 30 Nov 2015 16:33:33 +0100 Subject: [PATCH] fix example --- R-package/R/xgb.importance.R | 6 +++--- R-package/R/xgb.plot.importance.R | 7 +++---- R-package/man/xgb.importance.Rd | 6 +++--- R-package/man/xgb.plot.importance.Rd | 7 +++---- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/R-package/R/xgb.importance.R b/R-package/R/xgb.importance.R index 78fcaf3ac..55f680c42 100644 --- a/R-package/R/xgb.importance.R +++ b/R-package/R/xgb.importance.R @@ -52,11 +52,11 @@ #' bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max.depth = 2, #' eta = 1, nthread = 2, nround = 2,objective = "binary:logistic") #' -#' # train$data@@Dimnames[[2]] represents the column names of the sparse matrix. -#' xgb.importance(train$data@@Dimnames[[2]], model = bst) +#' # agaricus.train$data@@Dimnames[[2]] represents the column names of the sparse matrix. +#' xgb.importance(agaricus.train$data@@Dimnames[[2]], model = bst) #' #' # Same thing with co-occurence computation this time -#' xgb.importance(train$data@@Dimnames[[2]], model = bst, data = train$data, label = train$label) +#' xgb.importance(agaricus.train$data@@Dimnames[[2]], model = bst, data = agaricus.train$data, label = agaricus.train$label) #' #' @export xgb.importance <- function(feature_names = NULL, model = NULL, data = NULL, label = NULL, target = function(x) ( (x + label) == 2)){ diff --git a/R-package/R/xgb.plot.importance.R b/R-package/R/xgb.plot.importance.R index ea3e17892..96b576ee3 100644 --- a/R-package/R/xgb.plot.importance.R +++ b/R-package/R/xgb.plot.importance.R @@ -19,13 +19,12 @@ #' #Both dataset are list with two items, a sparse matrix and labels #' #(labels = outcome column which will be learned). #' #Each column of the sparse Matrix is a feature in one hot encoding format. -#' train <- agaricus.train #' -#' bst <- xgboost(data = train$data, label = train$label, max.depth = 2, +#' bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max.depth = 2, #' eta = 1, nthread = 2, nround = 2,objective = "binary:logistic") #' -#' #train$data@@Dimnames[[2]] represents the column names of the sparse matrix. -#' importance_matrix <- xgb.importance(train$data@@Dimnames[[2]], model = bst) +#' #agaricus.train$data@@Dimnames[[2]] represents the column names of the sparse matrix. +#' importance_matrix <- xgb.importance(agaricus.train$data@@Dimnames[[2]], model = bst) #' xgb.plot.importance(importance_matrix) #' #' @export diff --git a/R-package/man/xgb.importance.Rd b/R-package/man/xgb.importance.Rd index 14604312e..c144bb85f 100644 --- a/R-package/man/xgb.importance.Rd +++ b/R-package/man/xgb.importance.Rd @@ -58,11 +58,11 @@ data(agaricus.train, package='xgboost') bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max.depth = 2, eta = 1, nthread = 2, nround = 2,objective = "binary:logistic") -# train$data@Dimnames[[2]] represents the column names of the sparse matrix. -xgb.importance(train$data@Dimnames[[2]], model = bst) +# agaricus.train$data@Dimnames[[2]] represents the column names of the sparse matrix. +xgb.importance(agaricus.train$data@Dimnames[[2]], model = bst) # Same thing with co-occurence computation this time -xgb.importance(train$data@Dimnames[[2]], model = bst, data = train$data, label = train$label) +xgb.importance(agaricus.train$data@Dimnames[[2]], model = bst, data = agaricus.train$data, label = agaricus.train$label) } diff --git a/R-package/man/xgb.plot.importance.Rd b/R-package/man/xgb.plot.importance.Rd index 4ade2cda3..f49f57027 100644 --- a/R-package/man/xgb.plot.importance.Rd +++ b/R-package/man/xgb.plot.importance.Rd @@ -28,13 +28,12 @@ data(agaricus.train, package='xgboost') #Both dataset are list with two items, a sparse matrix and labels #(labels = outcome column which will be learned). #Each column of the sparse Matrix is a feature in one hot encoding format. -train <- agaricus.train -bst <- xgboost(data = train$data, label = train$label, max.depth = 2, +bst <- xgboost(data = agaricus.train$data, label = agaricus.train$label, max.depth = 2, eta = 1, nthread = 2, nround = 2,objective = "binary:logistic") -#train$data@Dimnames[[2]] represents the column names of the sparse matrix. -importance_matrix <- xgb.importance(train$data@Dimnames[[2]], model = bst) +#agaricus.train$data@Dimnames[[2]] represents the column names of the sparse matrix. +importance_matrix <- xgb.importance(agaricus.train$data@Dimnames[[2]], model = bst) xgb.plot.importance(importance_matrix) }