| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/xgb.DMatrix.R |
| 3 |
\name{xgb.DataIter} |
| 4 |
\alias{xgb.DataIter} |
| 5 |
\title{XGBoost Data Iterator} |
| 6 |
\usage{ |
| 7 |
xgb.DataIter(env = new.env(), f_next, f_reset) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{env}{An R environment to pass to the callback functions supplied here, which can be |
| 11 |
used to keep track of variables to determine how to handle the batches. |
| 12 |
|
| 13 |
For example, one might want to keep track of an iteration number in this environment in order |
| 14 |
to know which part of the data to pass next.} |
| 15 |
|
| 16 |
\item{f_next}{\verb{function(env)} which is responsible for: |
| 17 |
\itemize{ |
| 18 |
\item Accessing or retrieving the next batch of data in the iterator. |
| 19 |
\item Supplying this data by calling function \code{\link[=xgb.DataBatch]{xgb.DataBatch()}} on it and returning the result. |
| 20 |
\item Keeping track of where in the iterator batch it is or will go next, which can for example |
| 21 |
be done by modifiying variables in the \code{env} variable that is passed here. |
| 22 |
\item Signaling whether there are more batches to be consumed or not, by returning \code{NULL} |
| 23 |
when the stream of data ends (all batches in the iterator have been consumed), or the result from |
| 24 |
calling \code{\link[=xgb.DataBatch]{xgb.DataBatch()}} when there are more batches in the line to be consumed. |
| 25 |
}} |
| 26 |
|
| 27 |
\item{f_reset}{\verb{function(env)} which is responsible for reseting the data iterator |
| 28 |
(i.e. taking it back to the first batch, called before and after the sequence of batches |
| 29 |
has been consumed). |
| 30 |
|
| 31 |
Note that, after resetting the iterator, the batches will be accessed again, so the same data |
| 32 |
(and in the same order) must be passed in subsequent iterations.} |
| 33 |
} |
| 34 |
\value{ |
| 35 |
An \code{xgb.DataIter} object, containing the same inputs supplied here, which can then |
| 36 |
be passed to \code{\link[=xgb.ExtMemDMatrix]{xgb.ExtMemDMatrix()}}. |
| 37 |
} |
| 38 |
\description{ |
| 39 |
Interface to create a custom data iterator in order to construct a DMatrix |
| 40 |
from external memory. |
| 41 |
|
| 42 |
This function is responsible for generating an R object structure containing callback |
| 43 |
functions and an environment shared with them. |
| 44 |
|
| 45 |
The output structure from this function is then meant to be passed to \code{\link[=xgb.ExtMemDMatrix]{xgb.ExtMemDMatrix()}}, |
| 46 |
which will consume the data and create a DMatrix from it by executing the callback functions. |
| 47 |
|
| 48 |
For more information, and for a usage example, see the documentation for \code{\link[=xgb.ExtMemDMatrix]{xgb.ExtMemDMatrix()}}. |
| 49 |
} |
| 50 |
\seealso{ |
| 51 |
\code{\link[=xgb.ExtMemDMatrix]{xgb.ExtMemDMatrix()}}, \code{\link[=xgb.DataBatch]{xgb.DataBatch()}}. |
| 52 |
} |