Commit 0eb99219 authored by Guolin Ke's avatar Guolin Ke
Browse files

remove some files.

parent dbfa16c3
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lgb.Booster.R
\name{lgb.save}
\alias{lgb.save}
\title{Save LightGBM model}
\usage{
lgb.save(booster, filename, num_iteration = NULL)
}
\arguments{
\item{booster}{Object of class \code{lgb.Booster}}
\item{filename}{saved filename}
\item{num_iteration}{number of iteration want to predict with, NULL or <= 0 means use best iteration}
}
\value{
booster
}
\description{
Save LightGBM model
}
\examples{
\dontrun{
library(lightgbm)
data(agaricus.train, package = "lightgbm")
train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label)
data(agaricus.test, package = "lightgbm")
test <- agaricus.test
dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)
params <- list(objective = "regression", metric = "l2")
valids <- list(test = dtest)
model <- lgb.train(params,
dtrain,
100,
valids,
min_data = 1,
learning_rate = 1,
early_stopping_rounds = 10)
lgb.save(model, "model.txt")
}
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lgb.cv.R, R/lgb.train.R, R/lightgbm.R
\name{lgb.cv}
\alias{lgb.cv}
\alias{lgb.train}
\alias{lightgbm}
\title{Main CV logic for LightGBM}
\usage{
lgb.cv(params = list(), data, nrounds = 10, nfold = 3, label = NULL,
weight = NULL, obj = NULL, eval = NULL, verbose = 1, record = TRUE,
eval_freq = 1L, showsd = TRUE, stratified = TRUE, folds = NULL,
init_model = NULL, colnames = NULL, categorical_feature = NULL,
early_stopping_rounds = NULL, callbacks = list(), ...)
lgb.train(params = list(), data, nrounds = 10, valids = list(),
obj = NULL, eval = NULL, verbose = 1, record = TRUE, eval_freq = 1L,
init_model = NULL, colnames = NULL, categorical_feature = NULL,
early_stopping_rounds = NULL, callbacks = list(), ...)
lightgbm(data, label = NULL, weight = NULL, params = list(),
nrounds = 10, verbose = 1, eval_freq = 1L,
early_stopping_rounds = NULL, save_name = "lightgbm.model",
init_model = NULL, callbacks = list(), ...)
}
\arguments{
\item{params}{List of parameters}
\item{data}{a \code{lgb.Dataset} object, used for CV}
\item{nrounds}{number of CV rounds}
\item{nfold}{the original dataset is randomly partitioned into \code{nfold} equal size subsamples.}
\item{label}{vector of response values. Should be provided only when data is an R-matrix.}
\item{weight}{vector of response values. If not NULL, will set to dataset}
\item{obj}{objective function, can be character or custom objective function. Examples include
\code{regression}, \code{regression_l1}, \code{huber},
\code{binary}, \code{lambdarank}, \code{multiclass}, \code{multiclass}}
\item{eval}{evaluation function, can be (list of) character or custom eval function}
\item{verbose}{verbosity for output, if <= 0, also will disable the print of evalutaion during training}
\item{record}{Boolean, TRUE will record iteration message to \code{booster$record_evals}}
\item{eval_freq}{evalutaion output frequence, only effect when verbose > 0}
\item{showsd}{\code{boolean}, whether to show standard deviation of cross validation}
\item{stratified}{a \code{boolean} indicating whether sampling of folds should be stratified
by the values of outcome labels.}
\item{folds}{\code{list} provides a possibility to use a list of pre-defined CV folds
(each element must be a vector of test fold's indices). When folds are supplied,
the \code{nfold} and \code{stratified} parameters are ignored.}
\item{init_model}{path of model file of \code{lgb.Booster} object, will continue train from this model}
\item{colnames}{feature names, if not null, will use this to overwrite the names in dataset}
\item{categorical_feature}{list of str or int
type int represents index,
type str represents feature names}
\item{early_stopping_rounds}{int
Activates early stopping.
Requires at least one validation data and one metric
If there's more than one, will check all of them
Returns the model with (best_iter + early_stopping_rounds)
If early stopping occurs, the model will have 'best_iter' field}
\item{callbacks}{list of callback functions
List of callback functions that are applied at each iteration.}
\item{...}{other parameters, see parameters.md for more informations}
\item{valids}{a list of \code{lgb.Dataset} objects, used for validation}
\item{boosting}{boosting type. \code{gbdt}, \code{dart}}
\item{num_leaves}{number of leaves in one tree. defaults to 127}
\item{max_depth}{Limit the max depth for tree model. This is used to deal with overfit when #data is small.
Tree still grow by leaf-wise.}
\item{num_threads}{Number of threads for LightGBM. For the best speed, set this to the number of real CPU cores, not the number of threads (most CPU using hyper-threading to generate 2 threads per CPU core).}
\item{params}{List of parameters}
\item{data}{a \code{lgb.Dataset} object, used for training}
\item{nrounds}{number of training rounds}
\item{obj}{objective function, can be character or custom objective function. Examples include
\code{regression}, \code{regression_l1}, \code{huber},
\code{binary}, \code{lambdarank}, \code{multiclass}, \code{multiclass}}
\item{boosting}{boosting type. \code{gbdt}, \code{dart}}
\item{num_leaves}{number of leaves in one tree. defaults to 127}
\item{max_depth}{Limit the max depth for tree model. This is used to deal with overfit when #data is small.
Tree still grow by leaf-wise.}
\item{num_threads}{Number of threads for LightGBM. For the best speed, set this to the number of real CPU cores, not the number of threads (most CPU using hyper-threading to generate 2 threads per CPU core).}
\item{eval}{evaluation function, can be (a list of) character or custom eval function}
\item{verbose}{verbosity for output, if <= 0, also will disable the print of evalutaion during training}
\item{record}{Boolean, TRUE will record iteration message to \code{booster$record_evals}}
\item{eval_freq}{evalutaion output frequency, only effect when verbose > 0}
\item{init_model}{path of model file of \code{lgb.Booster} object, will continue training from this model}
\item{colnames}{feature names, if not null, will use this to overwrite the names in dataset}
\item{categorical_feature}{list of str or int
type int represents index,
type str represents feature names}
\item{early_stopping_rounds}{int
Activates early stopping.
Requires at least one validation data and one metric
If there's more than one, will check all of them
Returns the model with (best_iter + early_stopping_rounds)
If early stopping occurs, the model will have 'best_iter' field}
\item{callbacks}{list of callback functions
List of callback functions that are applied at each iteration.}
\item{...}{other parameters, see parameters.md for more informations}
}
\value{
a trained model \code{lgb.CVBooster}.
a trained booster model \code{lgb.Booster}.
}
\description{
Main CV logic for LightGBM
Main training logic for LightGBM
Simple interface for training an lightgbm model.
Its documentation is combined with lgb.train.
}
\examples{
\dontrun{
library(lightgbm)
data(agaricus.train, package = "lightgbm")
train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label)
params <- list(objective = "regression", metric = "l2")
model <- lgb.cv(params,
dtrain,
10,
nfold = 5,
min_data = 1,
learning_rate = 1,
early_stopping_rounds = 10)
}
\dontrun{
library(lightgbm)
data(agaricus.train, package = "lightgbm")
train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label)
data(agaricus.test, package = "lightgbm")
test <- agaricus.test
dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)
params <- list(objective = "regression", metric = "l2")
valids <- list(test = dtest)
model <- lgb.train(params,
dtrain,
100,
valids,
min_data = 1,
learning_rate = 1,
early_stopping_rounds = 10)
}
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lgb.unloader.R
\name{lgb.unloader}
\alias{lgb.unloader}
\title{LightGBM unloading error fix}
\usage{
lgb.unloader(restore = TRUE, wipe = FALSE, envir = .GlobalEnv)
}
\arguments{
\item{wipe}{Whether to wipe all \code{lgb.Dataset} and \code{lgb.Booster} from the global environment. Defaults to \code{FALSE} which means to not remove them.}
\item{envir}{The environment to perform wiping on if \code{wipe == TRUE}. Defaults to \code{.GlobalEnv} which is the global environment.}
\item{restart}{Whether to reload \code{LightGBM} immediately after detaching from R. Defaults to \code{TRUE} which means automatically reload \code{LightGBM} once unloading is performed.}
}
\value{
NULL invisibly.
}
\description{
Attempts to unload LightGBM packages so you can remove objects cleanly without having to restart R. This is useful for instance if an object becomes stuck for no apparent reason and you do not want to restart R to fix the lost object.
}
\examples{
\dontrun{
library(lightgbm)
data(agaricus.train, package = "lightgbm")
train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label)
data(agaricus.test, package = "lightgbm")
test <- agaricus.test
dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)
params <- list(objective = "regression", metric = "l2")
valids <- list(test = dtest)
model <- lgb.train(params,
dtrain,
100,
valids,
min_data = 1,
learning_rate = 1,
early_stopping_rounds = 10)
lgb.unloader(restore = FALSE, wipe = FALSE, envir = .GlobalEnv)
rm(model, dtrain, dtest) # Not needed if wipe = TRUE
gc() # Not needed if wipe = TRUE
library(lightgbm)
# Do whatever you want again with LightGBM without object clashing
}
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lgb.Booster.R
\name{predict.lgb.Booster}
\alias{predict.lgb.Booster}
\title{Predict method for LightGBM model}
\usage{
\method{predict}{lgb.Booster}(object, data, num_iteration = NULL,
rawscore = FALSE, predleaf = FALSE, header = FALSE, reshape = FALSE)
}
\arguments{
\item{object}{Object of class \code{lgb.Booster}}
\item{data}{a \code{matrix} object, a \code{dgCMatrix} object or a character representing a filename}
\item{num_iteration}{number of iteration want to predict with, NULL or <= 0 means use best iteration}
\item{rawscore}{whether the prediction should be returned in the for of original untransformed
sum of predictions from boosting iterations' results. E.g., setting \code{rawscore=TRUE} for
logistic regression would result in predictions for log-odds instead of probabilities.}
\item{predleaf}{whether predict leaf index instead.}
\item{header}{only used for prediction for text file. True if text file has header}
\item{reshape}{whether to reshape the vector of predictions to a matrix form when there are several
prediction outputs per case.}
}
\value{
For regression or binary classification, it returns a vector of length \code{nrows(data)}.
For multiclass classification, either a \code{num_class * nrows(data)} vector or
a \code{(nrows(data), num_class)} dimension matrix is returned, depending on
the \code{reshape} value.
When \code{predleaf = TRUE}, the output is a matrix object with the
number of columns corresponding to the number of trees.
}
\description{
Predicted values based on class \code{lgb.Booster}
}
\examples{
\dontrun{
library(lightgbm)
data(agaricus.train, package = "lightgbm")
train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label)
data(agaricus.test, package = "lightgbm")
test <- agaricus.test
dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)
params <- list(objective = "regression", metric = "l2")
valids <- list(test = dtest)
model <- lgb.train(params,
dtrain,
100,
valids,
min_data = 1,
learning_rate = 1,
early_stopping_rounds = 10)
preds <- predict(model, test$data)
}
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/readRDS.lgb.Booster.R
\name{readRDS.lgb.Booster}
\alias{readRDS.lgb.Booster}
\title{readRDS for lgb.Booster models}
\usage{
readRDS.lgb.Booster(file = "", refhook = NULL)
}
\arguments{
\item{file}{a connection or the name of the file where the R object is saved to or read from.}
\item{refhook}{a hook function for handling reference objects.}
}
\value{
an R object.
}
\description{
Attemps to load a model using RDS.
}
\examples{
\dontrun{
library(lightgbm)
data(agaricus.train, package = "lightgbm")
train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label)
data(agaricus.test, package = "lightgbm")
test <- agaricus.test
dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)
params <- list(objective = "regression", metric = "l2")
valids <- list(test = dtest)
model <- lgb.train(params,
dtrain,
100,
valids,
min_data = 1,
learning_rate = 1,
early_stopping_rounds = 10)
saveRDS.lgb.Booster(model, "model.rds")
new_model <- readRDS.lgb.Booster("model.rds")
}
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/saveRDS.lgb.Booster.R
\name{saveRDS.lgb.Booster}
\alias{saveRDS.lgb.Booster}
\title{saveRDS for lgb.Booster models}
\usage{
saveRDS.lgb.Booster(object, file = "", ascii = FALSE, version = NULL,
compress = TRUE, refhook = NULL, raw = TRUE)
}
\arguments{
\item{object}{R object to serialize.}
\item{file}{a connection or the name of the file where the R object is saved to or read from.}
\item{ascii}{a logical. If TRUE or NA, an ASCII representation is written; otherwise (default), a binary one is used. See the comments in the help for save.}
\item{version}{the workspace format version to use. \code{NULL} specifies the current default version (2). Versions prior to 2 are not supported, so this will only be relevant when there are later versions.}
\item{compress}{a logical specifying whether saving to a named file is to use "gzip" compression, or one of \code{"gzip"}, \code{"bzip2"} or \code{"xz"} to indicate the type of compression to be used. Ignored if file is a connection.}
\item{refhook}{a hook function for handling reference objects.}
\item{raw}{whether to save the model in a raw variable or not, recommended to leave it to \code{TRUE}.}
}
\value{
NULL invisibly.
}
\description{
Attemps to save a model using RDS. Has an additional parameter (\code{raw}) which decides whether to save the raw model or not.
}
\examples{
\dontrun{
library(lightgbm)
data(agaricus.train, package = "lightgbm")
train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label)
data(agaricus.test, package = "lightgbm")
test <- agaricus.test
dtest <- lgb.Dataset.create.valid(dtrain, test$data, label = test$label)
params <- list(objective = "regression", metric = "l2")
valids <- list(test = dtest)
model <- lgb.train(params,
dtrain,
100,
valids,
min_data = 1,
learning_rate = 1,
early_stopping_rounds = 10)
saveRDS.lgb.Booster(model, "model.rds")
}
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lgb.Dataset.R
\name{setinfo}
\alias{setinfo}
\alias{setinfo.lgb.Dataset}
\title{Set information of an lgb.Dataset object}
\usage{
setinfo(dataset, ...)
\method{setinfo}{lgb.Dataset}(dataset, name, info, ...)
}
\arguments{
\item{dataset}{Object of class "lgb.Dataset"}
\item{...}{other parameters}
\item{name}{the name of the field to get}
\item{info}{the specific field of information to set}
}
\value{
passed object
}
\description{
Set information of an lgb.Dataset object
}
\details{
The \code{name} field can be one of the following:
\itemize{
\item \code{label}: label lightgbm learn from ;
\item \code{weight}: to do a weight rescale ;
\item \code{init_score}: initial score is the base prediction lightgbm will boost from ;
\item \code{group}.
}
}
\examples{
\dontrun{
library(lightgbm)
data(agaricus.train, package = "lightgbm")
train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label)
lgb.Dataset.construct(dtrain)
labels <- lightgbm::getinfo(dtrain, "label")
lightgbm::setinfo(dtrain, "label", 1 - labels)
labels2 <- lightgbm::getinfo(dtrain, "label")
stopifnot(all.equal(labels2, 1 - labels))
}
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lgb.Dataset.R
\name{slice}
\alias{slice}
\alias{slice.lgb.Dataset}
\title{Slice a dataset}
\usage{
slice(dataset, ...)
\method{slice}{lgb.Dataset}(dataset, idxset, ...)
}
\arguments{
\item{dataset}{Object of class "lgb.Dataset"}
\item{...}{other parameters (currently not used)}
\item{idxset}{a integer vector of indices of rows needed}
}
\value{
constructed sub dataset
}
\description{
Get a new \code{lgb.Dataset} containing the specified rows of
orginal lgb.Dataset object
}
\examples{
\dontrun{
library(lightgbm)
data(agaricus.train, package = "lightgbm")
train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label)
dsub <- lightgbm::slice(dtrain, 1:42)
labels <- lightgbm::getinfo(dsub, "label")
}
}
/*
* A simple wrapper for accessing data in R object.
* Due to license issue(GPLv2), we cannot include R's header file, so use this simple wrapper instead.
* Due to license issue, we cannot include R's header file, so use this simple wrapper instead.
* However, if R changes the way it defines objects, this file will need to be updated as well.
*/
#ifndef R_OBJECT_HELPER_H_
......@@ -9,7 +9,7 @@
#include <cstdint>
#define TYPE_BITS 5
struct sxpinfo_struct {
struct lgbm_sxpinfo {
unsigned int type : 5;
unsigned int obj : 1;
unsigned int named : 2;
......@@ -22,67 +22,67 @@ struct sxpinfo_struct {
unsigned int gccls : 3;
};
struct primsxp_struct {
struct lgbm_primsxp {
int offset;
};
struct symsxp_struct {
struct SEXPREC *pname;
struct SEXPREC *value;
struct SEXPREC *internal;
struct lgbm_symsxp {
struct LGBM_SER *pname;
struct LGBM_SER *value;
struct LGBM_SER *internal;
};
struct listsxp_struct {
struct SEXPREC *carval;
struct SEXPREC *cdrval;
struct SEXPREC *tagval;
struct lgbm_listsxp {
struct LGBM_SER *carval;
struct LGBM_SER *cdrval;
struct LGBM_SER *tagval;
};
struct envsxp_struct {
struct SEXPREC *frame;
struct SEXPREC *enclos;
struct SEXPREC *hashtab;
struct lgbm_envsxp {
struct LGBM_SER *frame;
struct LGBM_SER *enclos;
struct LGBM_SER *hashtab;
};
struct closxp_struct {
struct SEXPREC *formals;
struct SEXPREC *body;
struct SEXPREC *env;
struct lgbm_closxp {
struct LGBM_SER *formals;
struct LGBM_SER *body;
struct LGBM_SER *env;
};
struct promsxp_struct {
struct SEXPREC *value;
struct SEXPREC *expr;
struct SEXPREC *env;
struct lgbm_promsxp {
struct LGBM_SER *value;
struct LGBM_SER *expr;
struct LGBM_SER *env;
};
typedef struct SEXPREC {
struct sxpinfo_struct sxpinfo;
struct SEXPREC* attrib;
struct SEXPREC* gengc_next_node, *gengc_prev_node;
typedef struct LGBM_SER {
struct lgbm_sxpinfo sxpinfo;
struct LGBM_SER* attrib;
struct LGBM_SER* gengc_next_node, *gengc_prev_node;
union {
struct primsxp_struct primsxp;
struct symsxp_struct symsxp;
struct listsxp_struct listsxp;
struct envsxp_struct envsxp;
struct closxp_struct closxp;
struct promsxp_struct promsxp;
struct lgbm_primsxp primsxp;
struct lgbm_symsxp symsxp;
struct lgbm_listsxp listsxp;
struct lgbm_envsxp envsxp;
struct lgbm_closxp closxp;
struct lgbm_promsxp promsxp;
} u;
} SEXPREC, *SEXP;
} LGBM_SER, *LGBM_SE;
struct vecsxp_struct {
struct lgbm_vecsxp {
int length;
int truelength;
};
typedef struct VECTOR_SEXPREC {
struct sxpinfo_struct sxpinfo;
struct SEXPREC* attrib;
struct SEXPREC* gengc_next_node, *gengc_prev_node;
struct vecsxp_struct vecsxp;
} VECTOR_SEXPREC, *VECSEXP;
typedef struct VECTOR_SER {
struct lgbm_sxpinfo sxpinfo;
struct LGBM_SER* attrib;
struct LGBM_SER* gengc_next_node, *gengc_prev_node;
struct lgbm_vecsxp vecsxp;
} VECTOR_SER, *VECSE;
typedef union { VECTOR_SEXPREC s; double align; } SEXPREC_ALIGN;
typedef union { VECTOR_SER s; double align; } SEXPREC_ALIGN;
#define DATAPTR(x) (((SEXPREC_ALIGN *) (x)) + 1)
......@@ -94,7 +94,7 @@ typedef union { VECTOR_SEXPREC s; double align; } SEXPREC_ALIGN;
#define R_AS_INT(x) (*((int *) DATAPTR(x)))
#define R_IS_NULL(x) ((*(SEXP)(x)).sxpinfo.type == 0)
#define R_IS_NULL(x) ((*(LGBM_SE)(x)).sxpinfo.type == 0)
// 64bit pointer
......@@ -102,7 +102,7 @@ typedef union { VECTOR_SEXPREC s; double align; } SEXPREC_ALIGN;
#define R_ADDR(x) ((int64_t *) DATAPTR(x))
inline void R_SET_PTR(SEXP x, void* ptr) {
inline void R_SET_PTR(LGBM_SE x, void* ptr) {
if (ptr == nullptr) {
R_ADDR(x)[0] = (int64_t)(NULL);
} else {
......@@ -110,7 +110,7 @@ inline void R_SET_PTR(SEXP x, void* ptr) {
}
}
inline void* R_GET_PTR(SEXP x) {
inline void* R_GET_PTR(LGBM_SE x) {
if (R_IS_NULL(x)) {
return nullptr;
} else {
......@@ -126,7 +126,7 @@ inline void* R_GET_PTR(SEXP x) {
#define R_ADDR(x) ((int32_t *) DATAPTR(x))
inline void R_SET_PTR(SEXP x, void* ptr) {
inline void R_SET_PTR(LGBM_SE x, void* ptr) {
if (ptr == nullptr) {
R_ADDR(x)[0] = (int32_t)(NULL);
} else {
......@@ -134,7 +134,7 @@ inline void R_SET_PTR(SEXP x, void* ptr) {
}
}
inline void* R_GET_PTR(SEXP x) {
inline void* R_GET_PTR(LGBM_SE x) {
if (R_IS_NULL(x)) {
return nullptr;
} else {
......
......@@ -32,7 +32,7 @@
using namespace LightGBM;
SEXP EncodeChar(SEXP dest, const char* src, SEXP buf_len, SEXP actual_len) {
LGBM_SE EncodeChar(LGBM_SE dest, const char* src, LGBM_SE buf_len, LGBM_SE actual_len) {
int str_len = static_cast<int>(std::strlen(src));
R_INT_PTR(actual_len)[0] = str_len;
if (R_AS_INT(buf_len) < str_len) { return dest; }
......@@ -45,15 +45,15 @@ SEXP EncodeChar(SEXP dest, const char* src, SEXP buf_len, SEXP actual_len) {
return dest;
}
SEXP LGBM_GetLastError_R(SEXP buf_len, SEXP actual_len, SEXP err_msg) {
LGBM_SE LGBM_GetLastError_R(LGBM_SE buf_len, LGBM_SE actual_len, LGBM_SE err_msg) {
return EncodeChar(err_msg, LGBM_GetLastError(), buf_len, actual_len);
}
SEXP LGBM_DatasetCreateFromFile_R(SEXP filename,
SEXP parameters,
SEXP reference,
SEXP out,
SEXP call_state) {
LGBM_SE LGBM_DatasetCreateFromFile_R(LGBM_SE filename,
LGBM_SE parameters,
LGBM_SE reference,
LGBM_SE out,
LGBM_SE call_state) {
R_API_BEGIN();
DatasetHandle handle;
......@@ -63,16 +63,16 @@ SEXP LGBM_DatasetCreateFromFile_R(SEXP filename,
R_API_END();
}
SEXP LGBM_DatasetCreateFromCSC_R(SEXP indptr,
SEXP indices,
SEXP data,
SEXP num_indptr,
SEXP nelem,
SEXP num_row,
SEXP parameters,
SEXP reference,
SEXP out,
SEXP call_state) {
LGBM_SE LGBM_DatasetCreateFromCSC_R(LGBM_SE indptr,
LGBM_SE indices,
LGBM_SE data,
LGBM_SE num_indptr,
LGBM_SE nelem,
LGBM_SE num_row,
LGBM_SE parameters,
LGBM_SE reference,
LGBM_SE out,
LGBM_SE call_state) {
R_API_BEGIN();
const int* p_indptr = R_INT_PTR(indptr);
const int* p_indices = R_INT_PTR(indices);
......@@ -89,13 +89,13 @@ SEXP LGBM_DatasetCreateFromCSC_R(SEXP indptr,
R_API_END();
}
SEXP LGBM_DatasetCreateFromMat_R(SEXP data,
SEXP num_row,
SEXP num_col,
SEXP parameters,
SEXP reference,
SEXP out,
SEXP call_state) {
LGBM_SE LGBM_DatasetCreateFromMat_R(LGBM_SE data,
LGBM_SE num_row,
LGBM_SE num_col,
LGBM_SE parameters,
LGBM_SE reference,
LGBM_SE out,
LGBM_SE call_state) {
R_API_BEGIN();
int32_t nrow = static_cast<int32_t>(R_AS_INT(num_row));
......@@ -108,12 +108,12 @@ SEXP LGBM_DatasetCreateFromMat_R(SEXP data,
R_API_END();
}
SEXP LGBM_DatasetGetSubset_R(SEXP handle,
SEXP used_row_indices,
SEXP len_used_row_indices,
SEXP parameters,
SEXP out,
SEXP call_state) {
LGBM_SE LGBM_DatasetGetSubset_R(LGBM_SE handle,
LGBM_SE used_row_indices,
LGBM_SE len_used_row_indices,
LGBM_SE parameters,
LGBM_SE out,
LGBM_SE call_state) {
R_API_BEGIN();
int len = R_AS_INT(len_used_row_indices);
......@@ -131,9 +131,9 @@ SEXP LGBM_DatasetGetSubset_R(SEXP handle,
R_API_END();
}
SEXP LGBM_DatasetSetFeatureNames_R(SEXP handle,
SEXP feature_names,
SEXP call_state) {
LGBM_SE LGBM_DatasetSetFeatureNames_R(LGBM_SE handle,
LGBM_SE feature_names,
LGBM_SE call_state) {
R_API_BEGIN();
auto vec_names = Common::Split(R_CHAR_PTR(feature_names), "\t");
std::vector<const char*> vec_sptr;
......@@ -146,11 +146,11 @@ SEXP LGBM_DatasetSetFeatureNames_R(SEXP handle,
R_API_END();
}
SEXP LGBM_DatasetGetFeatureNames_R(SEXP handle,
SEXP buf_len,
SEXP actual_len,
SEXP feature_names,
SEXP call_state) {
LGBM_SE LGBM_DatasetGetFeatureNames_R(LGBM_SE handle,
LGBM_SE buf_len,
LGBM_SE actual_len,
LGBM_SE feature_names,
LGBM_SE call_state) {
R_API_BEGIN();
int len = 0;
......@@ -170,17 +170,17 @@ SEXP LGBM_DatasetGetFeatureNames_R(SEXP handle,
R_API_END();
}
SEXP LGBM_DatasetSaveBinary_R(SEXP handle,
SEXP filename,
SEXP call_state) {
LGBM_SE LGBM_DatasetSaveBinary_R(LGBM_SE handle,
LGBM_SE filename,
LGBM_SE call_state) {
R_API_BEGIN();
CHECK_CALL(LGBM_DatasetSaveBinary(R_GET_PTR(handle),
R_CHAR_PTR(filename)));
R_API_END();
}
SEXP LGBM_DatasetFree_R(SEXP handle,
SEXP call_state) {
LGBM_SE LGBM_DatasetFree_R(LGBM_SE handle,
LGBM_SE call_state) {
R_API_BEGIN();
if (R_GET_PTR(handle) != nullptr) {
CHECK_CALL(LGBM_DatasetFree(R_GET_PTR(handle)));
......@@ -189,11 +189,11 @@ SEXP LGBM_DatasetFree_R(SEXP handle,
R_API_END();
}
SEXP LGBM_DatasetSetField_R(SEXP handle,
SEXP field_name,
SEXP field_data,
SEXP num_element,
SEXP call_state) {
LGBM_SE LGBM_DatasetSetField_R(LGBM_SE handle,
LGBM_SE field_name,
LGBM_SE field_data,
LGBM_SE num_element,
LGBM_SE call_state) {
R_API_BEGIN();
int len = static_cast<int>(R_AS_INT(num_element));
const char* name = R_CHAR_PTR(field_name);
......@@ -217,10 +217,10 @@ SEXP LGBM_DatasetSetField_R(SEXP handle,
R_API_END();
}
SEXP LGBM_DatasetGetField_R(SEXP handle,
SEXP field_name,
SEXP field_data,
SEXP call_state) {
LGBM_SE LGBM_DatasetGetField_R(LGBM_SE handle,
LGBM_SE field_name,
LGBM_SE field_data,
LGBM_SE call_state) {
R_API_BEGIN();
const char* name = R_CHAR_PTR(field_name);
......@@ -252,10 +252,10 @@ SEXP LGBM_DatasetGetField_R(SEXP handle,
R_API_END();
}
SEXP LGBM_DatasetGetFieldSize_R(SEXP handle,
SEXP field_name,
SEXP out,
SEXP call_state) {
LGBM_SE LGBM_DatasetGetFieldSize_R(LGBM_SE handle,
LGBM_SE field_name,
LGBM_SE out,
LGBM_SE call_state) {
R_API_BEGIN();
const char* name = R_CHAR_PTR(field_name);
......@@ -270,8 +270,8 @@ SEXP LGBM_DatasetGetFieldSize_R(SEXP handle,
R_API_END();
}
SEXP LGBM_DatasetGetNumData_R(SEXP handle, SEXP out,
SEXP call_state) {
LGBM_SE LGBM_DatasetGetNumData_R(LGBM_SE handle, LGBM_SE out,
LGBM_SE call_state) {
int nrow;
R_API_BEGIN();
CHECK_CALL(LGBM_DatasetGetNumData(R_GET_PTR(handle), &nrow));
......@@ -279,9 +279,9 @@ SEXP LGBM_DatasetGetNumData_R(SEXP handle, SEXP out,
R_API_END();
}
SEXP LGBM_DatasetGetNumFeature_R(SEXP handle,
SEXP out,
SEXP call_state) {
LGBM_SE LGBM_DatasetGetNumFeature_R(LGBM_SE handle,
LGBM_SE out,
LGBM_SE call_state) {
int nfeature;
R_API_BEGIN();
CHECK_CALL(LGBM_DatasetGetNumFeature(R_GET_PTR(handle), &nfeature));
......@@ -291,8 +291,8 @@ SEXP LGBM_DatasetGetNumFeature_R(SEXP handle,
// --- start Booster interfaces
SEXP LGBM_BoosterFree_R(SEXP handle,
SEXP call_state) {
LGBM_SE LGBM_BoosterFree_R(LGBM_SE handle,
LGBM_SE call_state) {
R_API_BEGIN();
if (R_GET_PTR(handle) != nullptr) {
CHECK_CALL(LGBM_BoosterFree(R_GET_PTR(handle)));
......@@ -301,10 +301,10 @@ SEXP LGBM_BoosterFree_R(SEXP handle,
R_API_END();
}
SEXP LGBM_BoosterCreate_R(SEXP train_data,
SEXP parameters,
SEXP out,
SEXP call_state) {
LGBM_SE LGBM_BoosterCreate_R(LGBM_SE train_data,
LGBM_SE parameters,
LGBM_SE out,
LGBM_SE call_state) {
R_API_BEGIN();
BoosterHandle handle;
CHECK_CALL(LGBM_BoosterCreate(R_GET_PTR(train_data), R_CHAR_PTR(parameters), &handle));
......@@ -312,9 +312,9 @@ SEXP LGBM_BoosterCreate_R(SEXP train_data,
R_API_END();
}
SEXP LGBM_BoosterCreateFromModelfile_R(SEXP filename,
SEXP out,
SEXP call_state) {
LGBM_SE LGBM_BoosterCreateFromModelfile_R(LGBM_SE filename,
LGBM_SE out,
LGBM_SE call_state) {
R_API_BEGIN();
int out_num_iterations = 0;
......@@ -324,41 +324,41 @@ SEXP LGBM_BoosterCreateFromModelfile_R(SEXP filename,
R_API_END();
}
SEXP LGBM_BoosterMerge_R(SEXP handle,
SEXP other_handle,
SEXP call_state) {
LGBM_SE LGBM_BoosterMerge_R(LGBM_SE handle,
LGBM_SE other_handle,
LGBM_SE call_state) {
R_API_BEGIN();
CHECK_CALL(LGBM_BoosterMerge(R_GET_PTR(handle), R_GET_PTR(other_handle)));
R_API_END();
}
SEXP LGBM_BoosterAddValidData_R(SEXP handle,
SEXP valid_data,
SEXP call_state) {
LGBM_SE LGBM_BoosterAddValidData_R(LGBM_SE handle,
LGBM_SE valid_data,
LGBM_SE call_state) {
R_API_BEGIN();
CHECK_CALL(LGBM_BoosterAddValidData(R_GET_PTR(handle), R_GET_PTR(valid_data)));
R_API_END();
}
SEXP LGBM_BoosterResetTrainingData_R(SEXP handle,
SEXP train_data,
SEXP call_state) {
LGBM_SE LGBM_BoosterResetTrainingData_R(LGBM_SE handle,
LGBM_SE train_data,
LGBM_SE call_state) {
R_API_BEGIN();
CHECK_CALL(LGBM_BoosterResetTrainingData(R_GET_PTR(handle), R_GET_PTR(train_data)));
R_API_END();
}
SEXP LGBM_BoosterResetParameter_R(SEXP handle,
SEXP parameters,
SEXP call_state) {
LGBM_SE LGBM_BoosterResetParameter_R(LGBM_SE handle,
LGBM_SE parameters,
LGBM_SE call_state) {
R_API_BEGIN();
CHECK_CALL(LGBM_BoosterResetParameter(R_GET_PTR(handle), R_CHAR_PTR(parameters)));
R_API_END();
}
SEXP LGBM_BoosterGetNumClasses_R(SEXP handle,
SEXP out,
SEXP call_state) {
LGBM_SE LGBM_BoosterGetNumClasses_R(LGBM_SE handle,
LGBM_SE out,
LGBM_SE call_state) {
int num_class;
R_API_BEGIN();
CHECK_CALL(LGBM_BoosterGetNumClasses(R_GET_PTR(handle), &num_class));
......@@ -366,19 +366,19 @@ SEXP LGBM_BoosterGetNumClasses_R(SEXP handle,
R_API_END();
}
SEXP LGBM_BoosterUpdateOneIter_R(SEXP handle,
SEXP call_state) {
LGBM_SE LGBM_BoosterUpdateOneIter_R(LGBM_SE handle,
LGBM_SE call_state) {
int is_finished = 0;
R_API_BEGIN();
CHECK_CALL(LGBM_BoosterUpdateOneIter(R_GET_PTR(handle), &is_finished));
R_API_END();
}
SEXP LGBM_BoosterUpdateOneIterCustom_R(SEXP handle,
SEXP grad,
SEXP hess,
SEXP len,
SEXP call_state) {
LGBM_SE LGBM_BoosterUpdateOneIterCustom_R(LGBM_SE handle,
LGBM_SE grad,
LGBM_SE hess,
LGBM_SE len,
LGBM_SE call_state) {
int is_finished = 0;
R_API_BEGIN();
int int_len = R_AS_INT(len);
......@@ -392,16 +392,16 @@ SEXP LGBM_BoosterUpdateOneIterCustom_R(SEXP handle,
R_API_END();
}
SEXP LGBM_BoosterRollbackOneIter_R(SEXP handle,
SEXP call_state) {
LGBM_SE LGBM_BoosterRollbackOneIter_R(LGBM_SE handle,
LGBM_SE call_state) {
R_API_BEGIN();
CHECK_CALL(LGBM_BoosterRollbackOneIter(R_GET_PTR(handle)));
R_API_END();
}
SEXP LGBM_BoosterGetCurrentIteration_R(SEXP handle,
SEXP out,
SEXP call_state) {
LGBM_SE LGBM_BoosterGetCurrentIteration_R(LGBM_SE handle,
LGBM_SE out,
LGBM_SE call_state) {
int out_iteration;
R_API_BEGIN();
......@@ -410,11 +410,11 @@ SEXP LGBM_BoosterGetCurrentIteration_R(SEXP handle,
R_API_END();
}
SEXP LGBM_BoosterGetEvalNames_R(SEXP handle,
SEXP buf_len,
SEXP actual_len,
SEXP eval_names,
SEXP call_state) {
LGBM_SE LGBM_BoosterGetEvalNames_R(LGBM_SE handle,
LGBM_SE buf_len,
LGBM_SE actual_len,
LGBM_SE eval_names,
LGBM_SE call_state) {
R_API_BEGIN();
int len;
......@@ -433,10 +433,10 @@ SEXP LGBM_BoosterGetEvalNames_R(SEXP handle,
R_API_END();
}
SEXP LGBM_BoosterGetEval_R(SEXP handle,
SEXP data_idx,
SEXP out_result,
SEXP call_state) {
LGBM_SE LGBM_BoosterGetEval_R(LGBM_SE handle,
LGBM_SE data_idx,
LGBM_SE out_result,
LGBM_SE call_state) {
R_API_BEGIN();
int len;
CHECK_CALL(LGBM_BoosterGetEvalCounts(R_GET_PTR(handle), &len));
......@@ -447,10 +447,10 @@ SEXP LGBM_BoosterGetEval_R(SEXP handle,
R_API_END();
}
SEXP LGBM_BoosterGetNumPredict_R(SEXP handle,
SEXP data_idx,
SEXP out,
SEXP call_state) {
LGBM_SE LGBM_BoosterGetNumPredict_R(LGBM_SE handle,
LGBM_SE data_idx,
LGBM_SE out,
LGBM_SE call_state) {
R_API_BEGIN();
int64_t len;
CHECK_CALL(LGBM_BoosterGetNumPredict(R_GET_PTR(handle), R_AS_INT(data_idx), &len));
......@@ -458,10 +458,10 @@ SEXP LGBM_BoosterGetNumPredict_R(SEXP handle,
R_API_END();
}
SEXP LGBM_BoosterGetPredict_R(SEXP handle,
SEXP data_idx,
SEXP out_result,
SEXP call_state) {
LGBM_SE LGBM_BoosterGetPredict_R(LGBM_SE handle,
LGBM_SE data_idx,
LGBM_SE out_result,
LGBM_SE call_state) {
R_API_BEGIN();
double* ptr_ret = R_REAL_PTR(out_result);
int64_t out_len;
......@@ -469,7 +469,7 @@ SEXP LGBM_BoosterGetPredict_R(SEXP handle,
R_API_END();
}
int GetPredictType(SEXP is_rawscore, SEXP is_leafidx) {
int GetPredictType(LGBM_SE is_rawscore, LGBM_SE is_leafidx) {
int pred_type = C_API_PREDICT_NORMAL;
if (R_AS_INT(is_rawscore)) {
pred_type = C_API_PREDICT_RAW_SCORE;
......@@ -480,14 +480,14 @@ int GetPredictType(SEXP is_rawscore, SEXP is_leafidx) {
return pred_type;
}
SEXP LGBM_BoosterPredictForFile_R(SEXP handle,
SEXP data_filename,
SEXP data_has_header,
SEXP is_rawscore,
SEXP is_leafidx,
SEXP num_iteration,
SEXP result_filename,
SEXP call_state) {
LGBM_SE LGBM_BoosterPredictForFile_R(LGBM_SE handle,
LGBM_SE data_filename,
LGBM_SE data_has_header,
LGBM_SE is_rawscore,
LGBM_SE is_leafidx,
LGBM_SE num_iteration,
LGBM_SE result_filename,
LGBM_SE call_state) {
R_API_BEGIN();
int pred_type = GetPredictType(is_rawscore, is_leafidx);
CHECK_CALL(LGBM_BoosterPredictForFile(R_GET_PTR(handle), R_CHAR_PTR(data_filename),
......@@ -496,13 +496,13 @@ SEXP LGBM_BoosterPredictForFile_R(SEXP handle,
R_API_END();
}
SEXP LGBM_BoosterCalcNumPredict_R(SEXP handle,
SEXP num_row,
SEXP is_rawscore,
SEXP is_leafidx,
SEXP num_iteration,
SEXP out_len,
SEXP call_state) {
LGBM_SE LGBM_BoosterCalcNumPredict_R(LGBM_SE handle,
LGBM_SE num_row,
LGBM_SE is_rawscore,
LGBM_SE is_leafidx,
LGBM_SE num_iteration,
LGBM_SE out_len,
LGBM_SE call_state) {
R_API_BEGIN();
int pred_type = GetPredictType(is_rawscore, is_leafidx);
int64_t len = 0;
......@@ -512,18 +512,18 @@ SEXP LGBM_BoosterCalcNumPredict_R(SEXP handle,
R_API_END();
}
SEXP LGBM_BoosterPredictForCSC_R(SEXP handle,
SEXP indptr,
SEXP indices,
SEXP data,
SEXP num_indptr,
SEXP nelem,
SEXP num_row,
SEXP is_rawscore,
SEXP is_leafidx,
SEXP num_iteration,
SEXP out_result,
SEXP call_state) {
LGBM_SE LGBM_BoosterPredictForCSC_R(LGBM_SE handle,
LGBM_SE indptr,
LGBM_SE indices,
LGBM_SE data,
LGBM_SE num_indptr,
LGBM_SE nelem,
LGBM_SE num_row,
LGBM_SE is_rawscore,
LGBM_SE is_leafidx,
LGBM_SE num_iteration,
LGBM_SE out_result,
LGBM_SE call_state) {
R_API_BEGIN();
int pred_type = GetPredictType(is_rawscore, is_leafidx);
......@@ -544,15 +544,15 @@ SEXP LGBM_BoosterPredictForCSC_R(SEXP handle,
R_API_END();
}
SEXP LGBM_BoosterPredictForMat_R(SEXP handle,
SEXP data,
SEXP num_row,
SEXP num_col,
SEXP is_rawscore,
SEXP is_leafidx,
SEXP num_iteration,
SEXP out_result,
SEXP call_state) {
LGBM_SE LGBM_BoosterPredictForMat_R(LGBM_SE handle,
LGBM_SE data,
LGBM_SE num_row,
LGBM_SE num_col,
LGBM_SE is_rawscore,
LGBM_SE is_leafidx,
LGBM_SE num_iteration,
LGBM_SE out_result,
LGBM_SE call_state) {
R_API_BEGIN();
int pred_type = GetPredictType(is_rawscore, is_leafidx);
......@@ -570,21 +570,21 @@ SEXP LGBM_BoosterPredictForMat_R(SEXP handle,
R_API_END();
}
SEXP LGBM_BoosterSaveModel_R(SEXP handle,
SEXP num_iteration,
SEXP filename,
SEXP call_state) {
LGBM_SE LGBM_BoosterSaveModel_R(LGBM_SE handle,
LGBM_SE num_iteration,
LGBM_SE filename,
LGBM_SE call_state) {
R_API_BEGIN();
CHECK_CALL(LGBM_BoosterSaveModel(R_GET_PTR(handle), R_AS_INT(num_iteration), R_CHAR_PTR(filename)));
R_API_END();
}
SEXP LGBM_BoosterDumpModel_R(SEXP handle,
SEXP num_iteration,
SEXP buffer_len,
SEXP actual_len,
SEXP out_str,
SEXP call_state) {
LGBM_SE LGBM_BoosterDumpModel_R(LGBM_SE handle,
LGBM_SE num_iteration,
LGBM_SE buffer_len,
LGBM_SE actual_len,
LGBM_SE out_str,
LGBM_SE call_state) {
R_API_BEGIN();
int out_len = 0;
std::vector<char> inner_char_buf(R_AS_INT(buffer_len));
......
......@@ -15,7 +15,7 @@
* \return err_msg error inforomation
* \return error inforomation
*/
LIGHTGBM_C_EXPORT SEXP LGBM_GetLastError_R(SEXP buf_len, SEXP actual_len, SEXP err_msg);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_GetLastError_R(LGBM_SE buf_len, LGBM_SE actual_len, LGBM_SE err_msg);
// --- start Dataset interface
......@@ -27,11 +27,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_GetLastError_R(SEXP buf_len, SEXP actual_len, SEXP e
* \param out created dataset
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromFile_R(SEXP filename,
SEXP parameters,
SEXP reference,
SEXP out,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetCreateFromFile_R(LGBM_SE filename,
LGBM_SE parameters,
LGBM_SE reference,
LGBM_SE out,
LGBM_SE call_state);
/*!
* \brief create a dataset from CSC format
......@@ -46,16 +46,16 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromFile_R(SEXP filename,
* \param out created dataset
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromCSC_R(SEXP indptr,
SEXP indices,
SEXP data,
SEXP nindptr,
SEXP nelem,
SEXP num_row,
SEXP parameters,
SEXP reference,
SEXP out,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetCreateFromCSC_R(LGBM_SE indptr,
LGBM_SE indices,
LGBM_SE data,
LGBM_SE nindptr,
LGBM_SE nelem,
LGBM_SE num_row,
LGBM_SE parameters,
LGBM_SE reference,
LGBM_SE out,
LGBM_SE call_state);
/*!
......@@ -68,13 +68,13 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromCSC_R(SEXP indptr,
* \param out created dataset
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromMat_R(SEXP data,
SEXP nrow,
SEXP ncol,
SEXP parameters,
SEXP reference,
SEXP out,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetCreateFromMat_R(LGBM_SE data,
LGBM_SE nrow,
LGBM_SE ncol,
LGBM_SE parameters,
LGBM_SE reference,
LGBM_SE out,
LGBM_SE call_state);
/*!
* \brief Create subset of a data
......@@ -85,12 +85,12 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromMat_R(SEXP data,
* \param out created dataset
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetSubset_R(SEXP handle,
SEXP used_row_indices,
SEXP len_used_row_indices,
SEXP parameters,
SEXP out,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetGetSubset_R(LGBM_SE handle,
LGBM_SE used_row_indices,
LGBM_SE len_used_row_indices,
LGBM_SE parameters,
LGBM_SE out,
LGBM_SE call_state);
/*!
* \brief save feature names to Dataset
......@@ -98,9 +98,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetSubset_R(SEXP handle,
* \param feature_names feature names
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetFeatureNames_R(SEXP handle,
SEXP feature_names,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetSetFeatureNames_R(LGBM_SE handle,
LGBM_SE feature_names,
LGBM_SE call_state);
/*!
* \brief save feature names to Dataset
......@@ -108,11 +108,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetFeatureNames_R(SEXP handle,
* \param feature_names feature names
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFeatureNames_R(SEXP handle,
SEXP buf_len,
SEXP actual_len,
SEXP feature_names,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetGetFeatureNames_R(LGBM_SE handle,
LGBM_SE buf_len,
LGBM_SE actual_len,
LGBM_SE feature_names,
LGBM_SE call_state);
/*!
* \brief save dateset to binary file
......@@ -120,17 +120,17 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFeatureNames_R(SEXP handle,
* \param filename file name
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSaveBinary_R(SEXP handle,
SEXP filename,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetSaveBinary_R(LGBM_SE handle,
LGBM_SE filename,
LGBM_SE call_state);
/*!
* \brief free dataset
* \param handle an instance of dataset
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetFree_R(SEXP handle,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetFree_R(LGBM_SE handle,
LGBM_SE call_state);
/*!
* \brief set vector to a content in info
......@@ -142,11 +142,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetFree_R(SEXP handle,
* \param num_element number of element in field_data
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetField_R(SEXP handle,
SEXP field_name,
SEXP field_data,
SEXP num_element,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetSetField_R(LGBM_SE handle,
LGBM_SE field_name,
LGBM_SE field_data,
LGBM_SE num_element,
LGBM_SE call_state);
/*!
* \brief get size of info vector from dataset
......@@ -155,10 +155,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetField_R(SEXP handle,
* \param out size of info vector from dataset
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFieldSize_R(SEXP handle,
SEXP field_name,
SEXP out,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetGetFieldSize_R(LGBM_SE handle,
LGBM_SE field_name,
LGBM_SE out,
LGBM_SE call_state);
/*!
* \brief get info vector from dataset
......@@ -167,10 +167,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFieldSize_R(SEXP handle,
* \param field_data pointer to vector
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetField_R(SEXP handle,
SEXP field_name,
SEXP field_data,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetGetField_R(LGBM_SE handle,
LGBM_SE field_name,
LGBM_SE field_data,
LGBM_SE call_state);
/*!
* \brief get number of data.
......@@ -178,9 +178,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetField_R(SEXP handle,
* \param out The address to hold number of data
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumData_R(SEXP handle,
SEXP out,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetGetNumData_R(LGBM_SE handle,
LGBM_SE out,
LGBM_SE call_state);
/*!
* \brief get number of features
......@@ -188,9 +188,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumData_R(SEXP handle,
* \param out The output of number of features
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumFeature_R(SEXP handle,
SEXP out,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetGetNumFeature_R(LGBM_SE handle,
LGBM_SE out,
LGBM_SE call_state);
// --- start Booster interfaces
......@@ -201,18 +201,18 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumFeature_R(SEXP handle,
* \prama out handle of created Booster
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreate_R(SEXP train_data,
SEXP parameters,
SEXP out,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterCreate_R(LGBM_SE train_data,
LGBM_SE parameters,
LGBM_SE out,
LGBM_SE call_state);
/*!
* \brief free obj in handle
* \param handle handle to be freed
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterFree_R(SEXP handle,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterFree_R(LGBM_SE handle,
LGBM_SE call_state);
/*!
* \brief load an existing boosting from model file
......@@ -220,9 +220,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterFree_R(SEXP handle,
* \prama out handle of created Booster
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreateFromModelfile_R(SEXP filename,
SEXP out,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterCreateFromModelfile_R(LGBM_SE filename,
LGBM_SE out,
LGBM_SE call_state);
/*!
* \brief Merge model in two boosters to first handle
......@@ -230,9 +230,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreateFromModelfile_R(SEXP filename,
* \param other_handle
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterMerge_R(SEXP handle,
SEXP other_handle,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterMerge_R(LGBM_SE handle,
LGBM_SE other_handle,
LGBM_SE call_state);
/*!
* \brief Add new validation to booster
......@@ -240,9 +240,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterMerge_R(SEXP handle,
* \param valid_data validation data set
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterAddValidData_R(SEXP handle,
SEXP valid_data,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterAddValidData_R(LGBM_SE handle,
LGBM_SE valid_data,
LGBM_SE call_state);
/*!
* \brief Reset training data for booster
......@@ -250,9 +250,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterAddValidData_R(SEXP handle,
* \param train_data training data set
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetTrainingData_R(SEXP handle,
SEXP train_data,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterResetTrainingData_R(LGBM_SE handle,
LGBM_SE train_data,
LGBM_SE call_state);
/*!
* \brief Reset config for current booster
......@@ -260,9 +260,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetTrainingData_R(SEXP handle,
* \param parameters format: 'key1=value1 key2=value2'
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetParameter_R(SEXP handle,
SEXP parameters,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterResetParameter_R(LGBM_SE handle,
LGBM_SE parameters,
LGBM_SE call_state);
/*!
* \brief Get number of classes
......@@ -270,17 +270,17 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetParameter_R(SEXP handle,
* \param out number of classes
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumClasses_R(SEXP handle,
SEXP out,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetNumClasses_R(LGBM_SE handle,
LGBM_SE out,
LGBM_SE call_state);
/*!
* \brief update the model in one round
* \param handle handle
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterUpdateOneIter_R(SEXP handle,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterUpdateOneIter_R(LGBM_SE handle,
LGBM_SE call_state);
/*!
* \brief update the model, by directly specify gradient and second order gradient,
......@@ -291,39 +291,39 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterUpdateOneIter_R(SEXP handle,
* \param len length of grad/hess
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterUpdateOneIterCustom_R(SEXP handle,
SEXP grad,
SEXP hess,
SEXP len,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterUpdateOneIterCustom_R(LGBM_SE handle,
LGBM_SE grad,
LGBM_SE hess,
LGBM_SE len,
LGBM_SE call_state);
/*!
* \brief Rollback one iteration
* \param handle handle
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterRollbackOneIter_R(SEXP handle,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterRollbackOneIter_R(LGBM_SE handle,
LGBM_SE call_state);
/*!
* \brief Get iteration of current boosting rounds
* \param out iteration of boosting rounds
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetCurrentIteration_R(SEXP handle,
SEXP out,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetCurrentIteration_R(LGBM_SE handle,
LGBM_SE out,
LGBM_SE call_state);
/*!
* \brief Get Name of eval
* \param eval_names eval names
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEvalNames_R(SEXP handle,
SEXP buf_len,
SEXP actual_len,
SEXP eval_names,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetEvalNames_R(LGBM_SE handle,
LGBM_SE buf_len,
LGBM_SE actual_len,
LGBM_SE eval_names,
LGBM_SE call_state);
/*!
* \brief get evaluation for training data and validation data
......@@ -332,10 +332,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEvalNames_R(SEXP handle,
* \param out_result float arrary contains result
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEval_R(SEXP handle,
SEXP data_idx,
SEXP out_result,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetEval_R(LGBM_SE handle,
LGBM_SE data_idx,
LGBM_SE out_result,
LGBM_SE call_state);
/*!
* \brief Get number of prediction for training data and validation data
......@@ -344,10 +344,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEval_R(SEXP handle,
* \param out size of predict
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumPredict_R(SEXP handle,
SEXP data_idx,
SEXP out,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetNumPredict_R(LGBM_SE handle,
LGBM_SE data_idx,
LGBM_SE out,
LGBM_SE call_state);
/*!
* \brief Get prediction for training data and validation data.
......@@ -357,10 +357,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumPredict_R(SEXP handle,
* \param out_result, used to store predict result, should pre-allocate memory
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetPredict_R(SEXP handle,
SEXP data_idx,
SEXP out_result,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetPredict_R(LGBM_SE handle,
LGBM_SE data_idx,
LGBM_SE out_result,
LGBM_SE call_state);
/*!
* \brief make prediction for file
......@@ -373,14 +373,14 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetPredict_R(SEXP handle,
* \return 0 when succeed, -1 when failure happens
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForFile_R(SEXP handle,
SEXP data_filename,
SEXP data_has_header,
SEXP is_rawscore,
SEXP is_leafidx,
SEXP num_iteration,
SEXP result_filename,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterPredictForFile_R(LGBM_SE handle,
LGBM_SE data_filename,
LGBM_SE data_has_header,
LGBM_SE is_rawscore,
LGBM_SE is_leafidx,
LGBM_SE num_iteration,
LGBM_SE result_filename,
LGBM_SE call_state);
/*!
* \brief Get number of prediction
......@@ -392,13 +392,13 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForFile_R(SEXP handle,
* \param out_len lenght of prediction
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCalcNumPredict_R(SEXP handle,
SEXP num_row,
SEXP is_rawscore,
SEXP is_leafidx,
SEXP num_iteration,
SEXP out_len,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterCalcNumPredict_R(LGBM_SE handle,
LGBM_SE num_row,
LGBM_SE is_rawscore,
LGBM_SE is_leafidx,
LGBM_SE num_iteration,
LGBM_SE out_len,
LGBM_SE call_state);
/*!
* \brief make prediction for an new data set
......@@ -418,18 +418,18 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCalcNumPredict_R(SEXP handle,
* \param out prediction result
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForCSC_R(SEXP handle,
SEXP indptr,
SEXP indices,
SEXP data,
SEXP nindptr,
SEXP nelem,
SEXP num_row,
SEXP is_rawscore,
SEXP is_leafidx,
SEXP num_iteration,
SEXP out_result,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterPredictForCSC_R(LGBM_SE handle,
LGBM_SE indptr,
LGBM_SE indices,
LGBM_SE data,
LGBM_SE nindptr,
LGBM_SE nelem,
LGBM_SE num_row,
LGBM_SE is_rawscore,
LGBM_SE is_leafidx,
LGBM_SE num_iteration,
LGBM_SE out_result,
LGBM_SE call_state);
/*!
* \brief make prediction for a new data set
......@@ -446,15 +446,15 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForCSC_R(SEXP handle,
* \param out prediction result
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForMat_R(SEXP handle,
SEXP data,
SEXP nrow,
SEXP ncol,
SEXP is_rawscore,
SEXP is_leafidx,
SEXP num_iteration,
SEXP out_result,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterPredictForMat_R(LGBM_SE handle,
LGBM_SE data,
LGBM_SE nrow,
LGBM_SE ncol,
LGBM_SE is_rawscore,
LGBM_SE is_leafidx,
LGBM_SE num_iteration,
LGBM_SE out_result,
LGBM_SE call_state);
/*!
* \brief save model into file
......@@ -463,10 +463,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForMat_R(SEXP handle,
* \param filename file name
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterSaveModel_R(SEXP handle,
SEXP num_iteration,
SEXP filename,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterSaveModel_R(LGBM_SE handle,
LGBM_SE num_iteration,
LGBM_SE filename,
LGBM_SE call_state);
/*!
* \brief dump model to json
......@@ -475,11 +475,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterSaveModel_R(SEXP handle,
* \param out_str json format string of model
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterDumpModel_R(SEXP handle,
SEXP num_iteration,
SEXP buffer_len,
SEXP actual_len,
SEXP out_str,
SEXP call_state);
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterDumpModel_R(LGBM_SE handle,
LGBM_SE num_iteration,
LGBM_SE buffer_len,
LGBM_SE actual_len,
LGBM_SE out_str,
LGBM_SE call_state);
#endif // LIGHTGBM_R_H_
......@@ -193,7 +193,6 @@ public:
return ip_list;
}
#else
// see in http://stackoverflow.com/questions/212528/get-the-ip-address-of-the-machine
inline static std::unordered_set<std::string> GetLocalIpList() {
std::unordered_set<std::string> ip_list;
struct ifaddrs * ifAddrStruct = NULL;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment