From cdfa78a3b95f7f28a22bdf39c9511fa3b61f213f Mon Sep 17 00:00:00 2001 From: pommedeterresautee Date: Sun, 15 Mar 2015 23:51:26 +0100 Subject: [PATCH 1/5] small changes in doc --- R-package/R/getinfo.xgb.DMatrix.R | 13 ++++++++++++- R-package/R/setinfo.xgb.DMatrix.R | 9 +++++++++ R-package/R/xgboost.R | 2 +- R-package/man/getinfo.Rd | 12 +++++++++++- R-package/man/setinfo.Rd | 10 ++++++++++ R-package/man/xgboost.Rd | 2 +- 6 files changed, 44 insertions(+), 4 deletions(-) diff --git a/R-package/R/getinfo.xgb.DMatrix.R b/R-package/R/getinfo.xgb.DMatrix.R index 6e291fe62..518cf10c5 100644 --- a/R-package/R/getinfo.xgb.DMatrix.R +++ b/R-package/R/getinfo.xgb.DMatrix.R @@ -4,6 +4,15 @@ setClass('xgb.DMatrix') #' #' Get information of an xgb.DMatrix object #' +#' The information can be one of the following: +#' +#' \itemize{ +#' \item \code{label} +#' \item \code{weight} +#' \item \code{base_margin} +#' \item \code{nrow} +#' } +#' #' @examples #' data(agaricus.train, package='xgboost') #' train <- agaricus.train @@ -19,7 +28,9 @@ getinfo <- function(object, ...){ UseMethod("getinfo") } -#' @param object Object of class "xgb.DMatrix" + + +#' @param object Object of class \code{xgb.DMatrix} #' @param name the name of the field to get #' @param ... other parameters #' @rdname getinfo diff --git a/R-package/R/setinfo.xgb.DMatrix.R b/R-package/R/setinfo.xgb.DMatrix.R index 579d9fbcf..3ed2fbecc 100644 --- a/R-package/R/setinfo.xgb.DMatrix.R +++ b/R-package/R/setinfo.xgb.DMatrix.R @@ -2,6 +2,15 @@ #' #' Set information of an xgb.DMatrix object #' +#' It can be one of the following: +#' +#' \itemize{ +#' \item \code{label} +#' \item \code{weight} +#' \item \code{base_margin} +#' \item \code{group} +#' } +#' #' @examples #' data(agaricus.train, package='xgboost') #' train <- agaricus.train diff --git a/R-package/R/xgboost.R b/R-package/R/xgboost.R index f20b260c9..1007cb91d 100644 --- a/R-package/R/xgboost.R +++ b/R-package/R/xgboost.R @@ -45,7 +45,7 @@ #' 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") +#' eta = 1, nthread = 2, nround = 2, objective = "binary:logistic") #' pred <- predict(bst, test$data) #' #' @export diff --git a/R-package/man/getinfo.Rd b/R-package/man/getinfo.Rd index 37e0ad0be..4f5fd71bc 100644 --- a/R-package/man/getinfo.Rd +++ b/R-package/man/getinfo.Rd @@ -11,7 +11,7 @@ getinfo(object, ...) \S4method{getinfo}{xgb.DMatrix}(object, name) } \arguments{ -\item{object}{Object of class "xgb.DMatrix"} +\item{object}{Object of class \code{xgb.DMatrix}} \item{...}{other parameters} @@ -20,6 +20,16 @@ getinfo(object, ...) \description{ Get information of an xgb.DMatrix object } +\details{ +The information can be one of the following: + +\itemize{ + \item \code{label} + \item \code{weight} + \item \code{base_margin} + \item \code{nrow} +} +} \examples{ data(agaricus.train, package='xgboost') train <- agaricus.train diff --git a/R-package/man/setinfo.Rd b/R-package/man/setinfo.Rd index 4ed262b46..334a67b27 100644 --- a/R-package/man/setinfo.Rd +++ b/R-package/man/setinfo.Rd @@ -22,6 +22,16 @@ setinfo(object, ...) \description{ Set information of an xgb.DMatrix object } +\details{ +It can be one of the following: + +\itemize{ + \item \code{label} + \item \code{weight} + \item \code{base_margin} + \item \code{group} +} +} \examples{ data(agaricus.train, package='xgboost') train <- agaricus.train diff --git a/R-package/man/xgboost.Rd b/R-package/man/xgboost.Rd index cb9da74f7..a0ec42a9b 100644 --- a/R-package/man/xgboost.Rd +++ b/R-package/man/xgboost.Rd @@ -59,7 +59,7 @@ 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") + eta = 1, nthread = 2, nround = 2, objective = "binary:logistic") pred <- predict(bst, test$data) } From 81caba5dce165c2df4ddc75059447c9296914041 Mon Sep 17 00:00:00 2001 From: pommedeterresautee Date: Sun, 15 Mar 2015 23:52:00 +0100 Subject: [PATCH 2/5] new nrow function for xgb.DMatrix --- R-package/NAMESPACE | 2 +- R-package/R/nrow.xgb.DMatrix.R | 18 ++++++++++++++++++ R-package/man/nrow.Rd | 22 ++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 R-package/R/nrow.xgb.DMatrix.R create mode 100644 R-package/man/nrow.Rd diff --git a/R-package/NAMESPACE b/R-package/NAMESPACE index ac74b8434..a1d296d80 100644 --- a/R-package/NAMESPACE +++ b/R-package/NAMESPACE @@ -16,6 +16,7 @@ export(xgb.save) export(xgb.save.raw) export(xgb.train) export(xgboost) +exportMethods(nrow) exportMethods(predict) import(methods) importClassesFrom(Matrix,dgCMatrix) @@ -52,4 +53,3 @@ importFrom(stringr,str_match) importFrom(stringr,str_replace) importFrom(stringr,str_split) importFrom(stringr,str_trim) -import(vcd) diff --git a/R-package/R/nrow.xgb.DMatrix.R b/R-package/R/nrow.xgb.DMatrix.R new file mode 100644 index 000000000..16e4098c2 --- /dev/null +++ b/R-package/R/nrow.xgb.DMatrix.R @@ -0,0 +1,18 @@ +setGeneric("nrow") + +#' @param x Object of class \code{xgb.DMatrix} +#' @title \code{nrow} return the number of rows present in x. +#' @rdname nrow +#' @examples +#' data(agaricus.train, package='xgboost') +#' train <- agaricus.train +#' dtrain <- xgb.DMatrix(train$data, label=train$label) +#' stopifnot(nrow(dtrain) == nrow(train$data)) +#' +#' @export +setMethod("nrow", + signature = "xgb.DMatrix", + definition = function(x) { + xgb.numrow(x) + } +) diff --git a/R-package/man/nrow.Rd b/R-package/man/nrow.Rd new file mode 100644 index 000000000..8187df3e0 --- /dev/null +++ b/R-package/man/nrow.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2 (4.1.0): do not edit by hand +% Please edit documentation in R/nrow.xgb.DMatrix.R +\docType{methods} +\name{nrow,xgb.DMatrix-method} +\alias{nrow,xgb.DMatrix-method} +\title{\code{nrow} return the number of rows present in x.} +\usage{ +\S4method{nrow}{xgb.DMatrix}(x) +} +\arguments{ +\item{x}{Object of class \code{xgb.DMatrix}} +} +\description{ +\code{nrow} return the number of rows present in x. +} +\examples{ +data(agaricus.train, package='xgboost') +train <- agaricus.train +dtrain <- xgb.DMatrix(train$data, label=train$label) +stopifnot(nrow(dtrain) == nrow(train$data)) +} + From 6ca76fe784b42283281ce9fd80c73b62e7c527e5 Mon Sep 17 00:00:00 2001 From: pommedeterresautee Date: Sun, 15 Mar 2015 23:59:28 +0100 Subject: [PATCH 3/5] doc --- R-package/R/getinfo.xgb.DMatrix.R | 8 ++++---- R-package/R/setinfo.xgb.DMatrix.R | 8 ++++---- R-package/man/getinfo.Rd | 8 ++++---- R-package/man/setinfo.Rd | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/R-package/R/getinfo.xgb.DMatrix.R b/R-package/R/getinfo.xgb.DMatrix.R index 518cf10c5..26523699a 100644 --- a/R-package/R/getinfo.xgb.DMatrix.R +++ b/R-package/R/getinfo.xgb.DMatrix.R @@ -7,10 +7,10 @@ setClass('xgb.DMatrix') #' The information can be one of the following: #' #' \itemize{ -#' \item \code{label} -#' \item \code{weight} -#' \item \code{base_margin} -#' \item \code{nrow} +#' \item \code{label}: label Xgboost learn from ; +#' \item \code{weight}: to do a weight rescale ; +#' \item \code{base_margin}: base margin is the base prediction Xgboost will boost from ; +#' \item \code{nrow}: number of rows of the \code{xgb.DMatrix}. #' } #' #' @examples diff --git a/R-package/R/setinfo.xgb.DMatrix.R b/R-package/R/setinfo.xgb.DMatrix.R index 3ed2fbecc..61019d8e2 100644 --- a/R-package/R/setinfo.xgb.DMatrix.R +++ b/R-package/R/setinfo.xgb.DMatrix.R @@ -5,10 +5,10 @@ #' It can be one of the following: #' #' \itemize{ -#' \item \code{label} -#' \item \code{weight} -#' \item \code{base_margin} -#' \item \code{group} +#' \item \code{label}: label Xgboost learn from ; +#' \item \code{weight}: to do a weight rescale ; +#' \item \code{base_margin}: base margin is the base prediction Xgboost will boost from ; +#' \item \code{group}. #' } #' #' @examples diff --git a/R-package/man/getinfo.Rd b/R-package/man/getinfo.Rd index 4f5fd71bc..618d0d44b 100644 --- a/R-package/man/getinfo.Rd +++ b/R-package/man/getinfo.Rd @@ -24,10 +24,10 @@ Get information of an xgb.DMatrix object The information can be one of the following: \itemize{ - \item \code{label} - \item \code{weight} - \item \code{base_margin} - \item \code{nrow} + \item \code{label}: label Xgboost learn from ; + \item \code{weight}: to do a weight rescale ; + \item \code{base_margin}: base margin is the base prediction Xgboost will boost from ; + \item \code{nrow}: number of rows of the \code{xgb.DMatrix}. } } \examples{ diff --git a/R-package/man/setinfo.Rd b/R-package/man/setinfo.Rd index 334a67b27..9512f1dfb 100644 --- a/R-package/man/setinfo.Rd +++ b/R-package/man/setinfo.Rd @@ -26,10 +26,10 @@ Set information of an xgb.DMatrix object It can be one of the following: \itemize{ - \item \code{label} - \item \code{weight} - \item \code{base_margin} - \item \code{group} + \item \code{label}: label Xgboost learn from ; + \item \code{weight}: to do a weight rescale ; + \item \code{base_margin}: base margin is the base prediction Xgboost will boost from ; + \item \code{group}. } } \examples{ From 9d1d76532da59be5d3ff2b612a7279143f6d94b0 Mon Sep 17 00:00:00 2001 From: pommedeterresautee Date: Mon, 16 Mar 2015 00:10:18 +0100 Subject: [PATCH 4/5] documentation --- R-package/R/nrow.xgb.DMatrix.R | 4 ++-- R-package/man/{nrow.Rd => nrow-xgb.DMatrix-method.Rd} | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename R-package/man/{nrow.Rd => nrow-xgb.DMatrix-method.Rd} (81%) diff --git a/R-package/R/nrow.xgb.DMatrix.R b/R-package/R/nrow.xgb.DMatrix.R index 16e4098c2..37d0fa811 100644 --- a/R-package/R/nrow.xgb.DMatrix.R +++ b/R-package/R/nrow.xgb.DMatrix.R @@ -1,8 +1,8 @@ setGeneric("nrow") #' @param x Object of class \code{xgb.DMatrix} -#' @title \code{nrow} return the number of rows present in x. -#' @rdname nrow +#' @title Number of xgb.DMatrix rows +#' @description \code{nrow} return the number of rows present in the \code{xgb.DMatrix}. #' @examples #' data(agaricus.train, package='xgboost') #' train <- agaricus.train diff --git a/R-package/man/nrow.Rd b/R-package/man/nrow-xgb.DMatrix-method.Rd similarity index 81% rename from R-package/man/nrow.Rd rename to R-package/man/nrow-xgb.DMatrix-method.Rd index 8187df3e0..953e620bf 100644 --- a/R-package/man/nrow.Rd +++ b/R-package/man/nrow-xgb.DMatrix-method.Rd @@ -3,7 +3,7 @@ \docType{methods} \name{nrow,xgb.DMatrix-method} \alias{nrow,xgb.DMatrix-method} -\title{\code{nrow} return the number of rows present in x.} +\title{Number of xgb.DMatrix rows} \usage{ \S4method{nrow}{xgb.DMatrix}(x) } @@ -11,7 +11,7 @@ \item{x}{Object of class \code{xgb.DMatrix}} } \description{ -\code{nrow} return the number of rows present in x. +\code{nrow} return the number of rows present in the \code{xgb.DMatrix}. } \examples{ data(agaricus.train, package='xgboost') From 240c314ac053a639e535ba7f562a3af486a4a214 Mon Sep 17 00:00:00 2001 From: pommedeterresautee Date: Mon, 16 Mar 2015 00:12:23 +0100 Subject: [PATCH 5/5] doc --- R-package/R/nrow.xgb.DMatrix.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R-package/R/nrow.xgb.DMatrix.R b/R-package/R/nrow.xgb.DMatrix.R index 37d0fa811..9ea039764 100644 --- a/R-package/R/nrow.xgb.DMatrix.R +++ b/R-package/R/nrow.xgb.DMatrix.R @@ -1,8 +1,9 @@ setGeneric("nrow") -#' @param x Object of class \code{xgb.DMatrix} #' @title Number of xgb.DMatrix rows #' @description \code{nrow} return the number of rows present in the \code{xgb.DMatrix}. +#' @param x Object of class \code{xgb.DMatrix} +#' #' @examples #' data(agaricus.train, package='xgboost') #' train <- agaricus.train