Merge pull request #198 from pommedeterresautee/master
Add new nrow function for xgb.DMatrix + small function doc changes
This commit is contained in:
commit
adfa023822
@ -16,6 +16,7 @@ export(xgb.save)
|
|||||||
export(xgb.save.raw)
|
export(xgb.save.raw)
|
||||||
export(xgb.train)
|
export(xgb.train)
|
||||||
export(xgboost)
|
export(xgboost)
|
||||||
|
exportMethods(nrow)
|
||||||
exportMethods(predict)
|
exportMethods(predict)
|
||||||
import(methods)
|
import(methods)
|
||||||
importClassesFrom(Matrix,dgCMatrix)
|
importClassesFrom(Matrix,dgCMatrix)
|
||||||
@ -52,4 +53,3 @@ importFrom(stringr,str_match)
|
|||||||
importFrom(stringr,str_replace)
|
importFrom(stringr,str_replace)
|
||||||
importFrom(stringr,str_split)
|
importFrom(stringr,str_split)
|
||||||
importFrom(stringr,str_trim)
|
importFrom(stringr,str_trim)
|
||||||
import(vcd)
|
|
||||||
|
|||||||
@ -4,6 +4,15 @@ setClass('xgb.DMatrix')
|
|||||||
#'
|
#'
|
||||||
#' Get information of an xgb.DMatrix object
|
#' Get information of an xgb.DMatrix object
|
||||||
#'
|
#'
|
||||||
|
#' The information can be one of the following:
|
||||||
|
#'
|
||||||
|
#' \itemize{
|
||||||
|
#' \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
|
#' @examples
|
||||||
#' data(agaricus.train, package='xgboost')
|
#' data(agaricus.train, package='xgboost')
|
||||||
#' train <- agaricus.train
|
#' train <- agaricus.train
|
||||||
@ -19,7 +28,9 @@ getinfo <- function(object, ...){
|
|||||||
UseMethod("getinfo")
|
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 name the name of the field to get
|
||||||
#' @param ... other parameters
|
#' @param ... other parameters
|
||||||
#' @rdname getinfo
|
#' @rdname getinfo
|
||||||
|
|||||||
19
R-package/R/nrow.xgb.DMatrix.R
Normal file
19
R-package/R/nrow.xgb.DMatrix.R
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
setGeneric("nrow")
|
||||||
|
|
||||||
|
#' @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
|
||||||
|
#' 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)
|
||||||
|
}
|
||||||
|
)
|
||||||
@ -2,6 +2,15 @@
|
|||||||
#'
|
#'
|
||||||
#' Set information of an xgb.DMatrix object
|
#' Set information of an xgb.DMatrix object
|
||||||
#'
|
#'
|
||||||
|
#' It can be one of the following:
|
||||||
|
#'
|
||||||
|
#' \itemize{
|
||||||
|
#' \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
|
#' @examples
|
||||||
#' data(agaricus.train, package='xgboost')
|
#' data(agaricus.train, package='xgboost')
|
||||||
#' train <- agaricus.train
|
#' train <- agaricus.train
|
||||||
|
|||||||
@ -45,7 +45,7 @@
|
|||||||
#' train <- agaricus.train
|
#' train <- agaricus.train
|
||||||
#' test <- agaricus.test
|
#' test <- agaricus.test
|
||||||
#' bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
|
#' 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)
|
#' pred <- predict(bst, test$data)
|
||||||
#'
|
#'
|
||||||
#' @export
|
#' @export
|
||||||
|
|||||||
@ -11,7 +11,7 @@ getinfo(object, ...)
|
|||||||
\S4method{getinfo}{xgb.DMatrix}(object, name)
|
\S4method{getinfo}{xgb.DMatrix}(object, name)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
\item{object}{Object of class "xgb.DMatrix"}
|
\item{object}{Object of class \code{xgb.DMatrix}}
|
||||||
|
|
||||||
\item{...}{other parameters}
|
\item{...}{other parameters}
|
||||||
|
|
||||||
@ -20,6 +20,16 @@ getinfo(object, ...)
|
|||||||
\description{
|
\description{
|
||||||
Get information of an xgb.DMatrix object
|
Get information of an xgb.DMatrix object
|
||||||
}
|
}
|
||||||
|
\details{
|
||||||
|
The information can be one of the following:
|
||||||
|
|
||||||
|
\itemize{
|
||||||
|
\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{
|
\examples{
|
||||||
data(agaricus.train, package='xgboost')
|
data(agaricus.train, package='xgboost')
|
||||||
train <- agaricus.train
|
train <- agaricus.train
|
||||||
|
|||||||
22
R-package/man/nrow-xgb.DMatrix-method.Rd
Normal file
22
R-package/man/nrow-xgb.DMatrix-method.Rd
Normal file
@ -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{Number of xgb.DMatrix rows}
|
||||||
|
\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 the \code{xgb.DMatrix}.
|
||||||
|
}
|
||||||
|
\examples{
|
||||||
|
data(agaricus.train, package='xgboost')
|
||||||
|
train <- agaricus.train
|
||||||
|
dtrain <- xgb.DMatrix(train$data, label=train$label)
|
||||||
|
stopifnot(nrow(dtrain) == nrow(train$data))
|
||||||
|
}
|
||||||
|
|
||||||
@ -22,6 +22,16 @@ setinfo(object, ...)
|
|||||||
\description{
|
\description{
|
||||||
Set information of an xgb.DMatrix object
|
Set information of an xgb.DMatrix object
|
||||||
}
|
}
|
||||||
|
\details{
|
||||||
|
It can be one of the following:
|
||||||
|
|
||||||
|
\itemize{
|
||||||
|
\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{
|
\examples{
|
||||||
data(agaricus.train, package='xgboost')
|
data(agaricus.train, package='xgboost')
|
||||||
train <- agaricus.train
|
train <- agaricus.train
|
||||||
|
|||||||
@ -59,7 +59,7 @@ data(agaricus.test, package='xgboost')
|
|||||||
train <- agaricus.train
|
train <- agaricus.train
|
||||||
test <- agaricus.test
|
test <- agaricus.test
|
||||||
bst <- xgboost(data = train$data, label = train$label, max.depth = 2,
|
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)
|
pred <- predict(bst, test$data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user