Unverified Commit 02467213 authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

[docs][R-package] update docs on C++ interface (#4257)



* [R-package] update docs on C++ interface

* Update R-package/src/lightgbm_R.h
Co-authored-by: default avatarNikita Titov <nekit94-08@mail.ru>

* Update R-package/src/lightgbm_R.h
Co-authored-by: default avatarNikita Titov <nekit94-08@mail.ru>

* add missing start_iteration doc
Co-authored-by: default avatarNikita Titov <nekit94-08@mail.ru>
parent 11b77471
...@@ -15,22 +15,19 @@ ...@@ -15,22 +15,19 @@
/*! /*!
* \brief get string message of the last error * \brief get string message of the last error
* all functions in this file will return 0 on success * \return err_msg string with error information
* and -1 when an error occurred
* \return err_msg error information
* \return error information
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_GetLastError_R(); LIGHTGBM_C_EXPORT SEXP LGBM_GetLastError_R();
// --- start Dataset interface // --- start Dataset interface
/*! /*!
* \brief load data set from file like the command_line LightGBM does * \brief load Dataset from file like the command_line LightGBM does
* \param filename the name of the file * \param filename the name of the file
* \param parameters additional parameters * \param parameters additional parameters
* \param reference used to align bin mapper with other dataset, nullptr means not used * \param reference used to align bin mapper with other Dataset, nullptr means not used
* \param out created dataset * \param out created Dataset
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromFile_R( LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromFile_R(
SEXP filename, SEXP filename,
...@@ -40,7 +37,7 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromFile_R( ...@@ -40,7 +37,7 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromFile_R(
); );
/*! /*!
* \brief create a dataset from CSC format * \brief create a Dataset from Compressed Sparse Column (CSC) format
* \param indptr pointer to row headers * \param indptr pointer to row headers
* \param indices findex * \param indices findex
* \param data fvalue * \param data fvalue
...@@ -48,9 +45,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromFile_R( ...@@ -48,9 +45,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromFile_R(
* \param nelem number of nonzero elements in the matrix * \param nelem number of nonzero elements in the matrix
* \param num_row number of rows * \param num_row number of rows
* \param parameters additional parameters * \param parameters additional parameters
* \param reference used to align bin mapper with other dataset, nullptr means not used * \param reference used to align bin mapper with other Dataset, nullptr means not used
* \param out created dataset * \param out created Dataset
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromCSC_R( LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromCSC_R(
SEXP indptr, SEXP indptr,
...@@ -65,14 +62,14 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromCSC_R( ...@@ -65,14 +62,14 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromCSC_R(
); );
/*! /*!
* \brief create dataset from dense matrix * \brief create Dataset from dense matrix
* \param data matric data * \param data matrix data
* \param num_row number of rows * \param num_row number of rows
* \param num_col number columns * \param num_col number columns
* \param parameters additional parameters * \param parameters additional parameters
* \param reference used to align bin mapper with other dataset, nullptr means not used * \param reference used to align bin mapper with other Dataset, nullptr means not used
* \param out created dataset * \param out created Dataset
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromMat_R( LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromMat_R(
SEXP data, SEXP data,
...@@ -84,13 +81,13 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromMat_R( ...@@ -84,13 +81,13 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromMat_R(
); );
/*! /*!
* \brief Create subset of a data * \brief Create subset of a Dataset
* \param handle handle of full dataset * \param handle handle of full Dataset
* \param used_row_indices Indices used in subset * \param used_row_indices Indices used in subset
* \param len_used_row_indices length of Indices used in subset * \param len_used_row_indices length of Indices used in subset
* \param parameters additional parameters * \param parameters additional parameters
* \param out created dataset * \param out created Dataset
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetSubset_R( LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetSubset_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -104,7 +101,7 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetSubset_R( ...@@ -104,7 +101,7 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetSubset_R(
* \brief save feature names to Dataset * \brief save feature names to Dataset
* \param handle handle * \param handle handle
* \param feature_names feature names * \param feature_names feature names
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetFeatureNames_R( LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetFeatureNames_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -125,10 +122,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFeatureNames_R( ...@@ -125,10 +122,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFeatureNames_R(
); );
/*! /*!
* \brief save dataset to binary file * \brief save Dataset to binary file
* \param handle an instance of dataset * \param handle an instance of Dataset
* \param filename file name * \param filename file name
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSaveBinary_R( LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSaveBinary_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -136,9 +133,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSaveBinary_R( ...@@ -136,9 +133,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSaveBinary_R(
); );
/*! /*!
* \brief free dataset * \brief free Dataset
* \param handle an instance of dataset * \param handle an instance of Dataset
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetFree_R( LIGHTGBM_C_EXPORT SEXP LGBM_DatasetFree_R(
LGBM_SE handle LGBM_SE handle
...@@ -148,11 +145,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetFree_R( ...@@ -148,11 +145,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetFree_R(
* \brief set vector to a content in info * \brief set vector to a content in info
* Note: group and group_id only work for C_API_DTYPE_INT32 * Note: group and group_id only work for C_API_DTYPE_INT32
* label and weight only work for C_API_DTYPE_FLOAT32 * label and weight only work for C_API_DTYPE_FLOAT32
* \param handle an instance of dataset * \param handle an instance of Dataset
* \param field_name field name, can be label, weight, group, group_id * \param field_name field name, can be label, weight, group, group_id
* \param field_data pointer to vector * \param field_data pointer to vector
* \param num_element number of element in field_data * \param num_element number of element in field_data
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetField_R( LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetField_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -162,11 +159,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetField_R( ...@@ -162,11 +159,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetField_R(
); );
/*! /*!
* \brief get size of info vector from dataset * \brief get size of info vector from Dataset
* \param handle an instance of dataset * \param handle an instance of Dataset
* \param field_name field name * \param field_name field name
* \param out size of info vector from dataset * \param out size of info vector from Dataset
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFieldSize_R( LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFieldSize_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -175,11 +172,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFieldSize_R( ...@@ -175,11 +172,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFieldSize_R(
); );
/*! /*!
* \brief get info vector from dataset * \brief get info vector from Dataset
* \param handle an instance of dataset * \param handle an instance of Dataset
* \param field_name field name * \param field_name field name
* \param field_data pointer to vector * \param field_data pointer to vector
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetField_R( LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetField_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -188,10 +185,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetField_R( ...@@ -188,10 +185,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetField_R(
); );
/*! /*!
* \brief Raise errors for attempts to update dataset parameters * \brief Raise errors for attempts to update Dataset parameters.
* \param old_params Current dataset parameters * Some parameters cannot be updated after construction.
* \param new_params New dataset parameters * \param old_params Current Dataset parameters
* \return 0 when succeed, -1 when failure happens * \param new_params New Dataset parameters
* \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetUpdateParamChecking_R( LIGHTGBM_C_EXPORT SEXP LGBM_DatasetUpdateParamChecking_R(
SEXP old_params, SEXP old_params,
...@@ -200,9 +198,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetUpdateParamChecking_R( ...@@ -200,9 +198,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetUpdateParamChecking_R(
/*! /*!
* \brief get number of data. * \brief get number of data.
* \param handle the handle to the dataset * \param handle the handle to the Dataset
* \param out The address to hold number of data * \param out The address to hold number of data
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumData_R( LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumData_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -211,9 +209,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumData_R( ...@@ -211,9 +209,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumData_R(
/*! /*!
* \brief get number of features * \brief get number of features
* \param handle the handle to the dataset * \param handle the handle to the Dataset
* \param out The output of number of features * \param out The output of number of features
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumFeature_R( LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumFeature_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -224,10 +222,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumFeature_R( ...@@ -224,10 +222,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumFeature_R(
/*! /*!
* \brief create a new boosting learner * \brief create a new boosting learner
* \param train_data training data set * \param train_data training Dataset
* \param parameters format: 'key1=value1 key2=value2' * \param parameters format: 'key1=value1 key2=value2'
* \param out handle of created Booster * \param out handle of created Booster
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreate_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreate_R(
LGBM_SE train_data, LGBM_SE train_data,
...@@ -236,19 +234,19 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreate_R( ...@@ -236,19 +234,19 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreate_R(
); );
/*! /*!
* \brief free obj in handle * \brief free Booster
* \param handle handle to be freed * \param handle handle to be freed
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterFree_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterFree_R(
LGBM_SE handle LGBM_SE handle
); );
/*! /*!
* \brief load an existing boosting from model file * \brief load an existing Booster from model file
* \param filename filename of model * \param filename filename of model
* \param out handle of created Booster * \param out handle of created Booster
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreateFromModelfile_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreateFromModelfile_R(
SEXP filename, SEXP filename,
...@@ -256,10 +254,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreateFromModelfile_R( ...@@ -256,10 +254,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreateFromModelfile_R(
); );
/*! /*!
* \brief load an existing boosting from model_str * \brief load an existing Booster from a string
* \param model_str string containing the model * \param model_str string containing the model
* \param out handle of created Booster * \param out handle of created Booster
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterLoadModelFromString_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterLoadModelFromString_R(
SEXP model_str, SEXP model_str,
...@@ -267,10 +265,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterLoadModelFromString_R( ...@@ -267,10 +265,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterLoadModelFromString_R(
); );
/*! /*!
* \brief Merge model in two boosters to first handle * \brief Merge model in two Boosters to first handle
* \param handle handle, will merge other handle to this * \param handle handle primary Booster handle, will merge other handle to this
* \param other_handle * \param other_handle secondary Booster handle
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterMerge_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterMerge_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -278,10 +276,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterMerge_R( ...@@ -278,10 +276,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterMerge_R(
); );
/*! /*!
* \brief Add new validation to booster * \brief Add new validation to Booster
* \param handle handle * \param handle Booster handle
* \param valid_data validation data set * \param valid_data validation Dataset
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterAddValidData_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterAddValidData_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -289,10 +287,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterAddValidData_R( ...@@ -289,10 +287,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterAddValidData_R(
); );
/*! /*!
* \brief Reset training data for booster * \brief Reset training data for Booster
* \param handle handle * \param handle Booster handle
* \param train_data training data set * \param train_data training Dataset
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetTrainingData_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetTrainingData_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -300,10 +298,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetTrainingData_R( ...@@ -300,10 +298,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetTrainingData_R(
); );
/*! /*!
* \brief Reset config for current booster * \brief Reset config for current Booster
* \param handle handle * \param handle Booster handle
* \param parameters format: 'key1=value1 key2=value2' * \param parameters format: 'key1=value1 key2=value2'
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetParameter_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetParameter_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -312,9 +310,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetParameter_R( ...@@ -312,9 +310,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetParameter_R(
/*! /*!
* \brief Get number of classes * \brief Get number of classes
* \param handle handle * \param handle Booster handle
* \param out number of classes * \param out number of classes
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumClasses_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumClasses_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -323,21 +321,21 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumClasses_R( ...@@ -323,21 +321,21 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumClasses_R(
/*! /*!
* \brief update the model in one round * \brief update the model in one round
* \param handle handle * \param handle Booster handle
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterUpdateOneIter_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterUpdateOneIter_R(
LGBM_SE handle LGBM_SE handle
); );
/*! /*!
* \brief update the model, by directly specify gradient and second order gradient, * \brief update the model, by directly specifying gradient and second order gradient,
* this can be used to support customized loss function * this can be used to support customized loss function
* \param handle handle * \param handle Booster handle
* \param grad gradient statistics * \param grad gradient statistics
* \param hess second order gradient statistics * \param hess second order gradient statistics
* \param len length of grad/hess * \param len length of grad/hess
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterUpdateOneIterCustom_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterUpdateOneIterCustom_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -348,8 +346,8 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterUpdateOneIterCustom_R( ...@@ -348,8 +346,8 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterUpdateOneIterCustom_R(
/*! /*!
* \brief Rollback one iteration * \brief Rollback one iteration
* \param handle handle * \param handle Booster handle
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterRollbackOneIter_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterRollbackOneIter_R(
LGBM_SE handle LGBM_SE handle
...@@ -357,8 +355,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterRollbackOneIter_R( ...@@ -357,8 +355,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterRollbackOneIter_R(
/*! /*!
* \brief Get iteration of current boosting rounds * \brief Get iteration of current boosting rounds
* \param handle Booster handle
* \param out iteration of boosting rounds * \param out iteration of boosting rounds
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetCurrentIteration_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetCurrentIteration_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -367,9 +366,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetCurrentIteration_R( ...@@ -367,9 +366,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetCurrentIteration_R(
/*! /*!
* \brief Get model upper bound value. * \brief Get model upper bound value.
* \param handle Handle of booster * \param handle Handle of Booster
* \param[out] out_results Result pointing to max value * \param[out] out_results Result pointing to max value
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetUpperBoundValue_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetUpperBoundValue_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -378,9 +377,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetUpperBoundValue_R( ...@@ -378,9 +377,9 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetUpperBoundValue_R(
/*! /*!
* \brief Get model lower bound value. * \brief Get model lower bound value.
* \param handle Handle of booster * \param handle Handle of Booster
* \param[out] out_results Result pointing to min value * \param[out] out_results Result pointing to min value
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetLowerBoundValue_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetLowerBoundValue_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -401,10 +400,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEvalNames_R( ...@@ -401,10 +400,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEvalNames_R(
/*! /*!
* \brief get evaluation for training data and validation data * \brief get evaluation for training data and validation data
* \param handle handle * \param handle Booster handle
* \param data_idx 0:training data, 1: 1st valid data, 2:2nd valid data ... * \param data_idx 0:training data, 1: 1st valid data, 2:2nd valid data ...
* \param out_result float array contains result * \param out_result float array containing result
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEval_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEval_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -414,10 +413,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEval_R( ...@@ -414,10 +413,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEval_R(
/*! /*!
* \brief Get number of prediction for training data and validation data * \brief Get number of prediction for training data and validation data
* \param handle handle * \param handle Booster handle
* \param data_idx 0:training data, 1: 1st valid data, 2:2nd valid data ... * \param data_idx 0:training data, 1: 1st valid data, 2:2nd valid data ...
* \param out size of predict * \param out size of predict
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumPredict_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumPredict_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -428,10 +427,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumPredict_R( ...@@ -428,10 +427,10 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumPredict_R(
/*! /*!
* \brief Get prediction for training data and validation data. * \brief Get prediction for training data and validation data.
* This can be used to support customized eval function * This can be used to support customized eval function
* \param handle handle * \param handle Booster handle
* \param data_idx 0:training data, 1: 1st valid data, 2:2nd valid data ... * \param data_idx 0:training data, 1: 1st valid data, 2:2nd valid data ...
* \param out_result, used to store predict result, should pre-allocate memory * \param out_result, used to store predict result, should pre-allocate memory
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetPredict_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetPredict_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -441,14 +440,19 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetPredict_R( ...@@ -441,14 +440,19 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetPredict_R(
/*! /*!
* \brief make prediction for file * \brief make prediction for file
* \param handle handle * \param handle Booster handle
* \param data_filename filename of data file * \param data_filename filename of data file
* \param data_has_header data file has header or not * \param data_has_header data file has header or not
* \param is_rawscore * \param is_rawscore 1 to get raw predictions, before transformations like
* \param is_leafidx * converting to probabilities, 0 otherwise
* \param is_leafidx 1 to get record of which leaf in each tree
* observations fell into, 0 otherwise
* \param is_predcontrib 1 to get feature contributions, 0 otherwise
* \param start_iteration Start index of the iteration to predict
* \param num_iteration number of iteration for prediction, <= 0 means no limit * \param num_iteration number of iteration for prediction, <= 0 means no limit
* \return 0 when succeed, -1 when failure happens * \param parameter additional parameters
* \return 0 when succeed, -1 when failure happens * \param result_filename filename of file to write predictions to
* \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForFile_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForFile_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -465,13 +469,17 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForFile_R( ...@@ -465,13 +469,17 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForFile_R(
/*! /*!
* \brief Get number of prediction * \brief Get number of prediction
* \param handle handle * \param handle Booster handle
* \param num_row * \param num_row number of rows in input
* \param is_rawscore * \param is_rawscore 1 to get raw predictions, before transformations like
* \param is_leafidx * converting to probabilities, 0 otherwise
* \param is_leafidx 1 to get record of which leaf in each tree
* observations fell into, 0 otherwise
* \param is_predcontrib 1 to get feature contributions, 0 otherwise
* \param start_iteration Start index of the iteration to predict
* \param num_iteration number of iteration for prediction, <= 0 means no limit * \param num_iteration number of iteration for prediction, <= 0 means no limit
* \param out_len length of prediction * \param out_len length of prediction
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCalcNumPredict_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCalcNumPredict_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -485,22 +493,27 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCalcNumPredict_R( ...@@ -485,22 +493,27 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCalcNumPredict_R(
); );
/*! /*!
* \brief make prediction for a new data set * \brief make prediction for a new Dataset
* Note: should pre-allocate memory for out_result, * Note: should pre-allocate memory for out_result,
* for normal and raw score: its length is equal to num_class * num_data * for normal and raw score: its length is equal to num_class * num_data
* for leaf index, its length is equal to num_class * num_data * num_iteration * for leaf index, its length is equal to num_class * num_data * num_iteration
* \param handle handle * \param handle Booster handle
* \param indptr pointer to row headers * \param indptr pointer to row headers
* \param indices findex * \param indices findex
* \param data fvalue * \param data fvalue
* \param num_indptr number of cols in the matrix + 1 * \param num_indptr number of cols in the matrix + 1
* \param nelem number of non-zero elements in the matrix * \param nelem number of non-zero elements in the matrix
* \param num_row number of rows * \param num_row number of rows
* \param is_rawscore * \param is_rawscore 1 to get raw predictions, before transformations like
* \param is_leafidx * converting to probabilities, 0 otherwise
* \param is_leafidx 1 to get record of which leaf in each tree
* observations fell into, 0 otherwise
* \param is_predcontrib 1 to get feature contributions, 0 otherwise
* \param start_iteration Start index of the iteration to predict
* \param num_iteration number of iteration for prediction, <= 0 means no limit * \param num_iteration number of iteration for prediction, <= 0 means no limit
* \param out prediction result * \param parameter additional parameters
* \return 0 when succeed, -1 when failure happens * \param out_result prediction result
* \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForCSC_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForCSC_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -520,19 +533,24 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForCSC_R( ...@@ -520,19 +533,24 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForCSC_R(
); );
/*! /*!
* \brief make prediction for a new data set * \brief make prediction for a new Dataset
* Note: should pre-allocate memory for out_result, * Note: should pre-allocate memory for out_result,
* for normal and raw score: its length is equal to num_class * num_data * for normal and raw score: its length is equal to num_class * num_data
* for leaf index, its length is equal to num_class * num_data * num_iteration * for leaf index, its length is equal to num_class * num_data * num_iteration
* \param handle handle * \param handle Booster handle
* \param data pointer to the data space * \param data pointer to the data space
* \param num_row number of rows * \param num_row number of rows
* \param num_col number columns * \param num_col number columns
* \param is_rawscore * \param is_rawscore 1 to get raw predictions, before transformations like
* \param is_leafidx * converting to probabilities, 0 otherwise
* \param is_leafidx 1 to get record of which leaf in each tree
* observations fell into, 0 otherwise
* \param is_predcontrib 1 to get feature contributions, 0 otherwise
* \param start_iteration Start index of the iteration to predict
* \param num_iteration number of iteration for prediction, <= 0 means no limit * \param num_iteration number of iteration for prediction, <= 0 means no limit
* \param out prediction result * \param parameter additional parameters
* \return 0 when succeed, -1 when failure happens * \param out_result prediction result
* \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForMat_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForMat_R(
LGBM_SE handle, LGBM_SE handle,
...@@ -550,10 +568,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForMat_R( ...@@ -550,10 +568,11 @@ LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForMat_R(
/*! /*!
* \brief save model into file * \brief save model into file
* \param handle handle * \param handle Booster handle
* \param num_iteration, <= 0 means save all * \param num_iteration, <= 0 means save all
* \param feature_importance_type type of feature importance, 0: split, 1: gain
* \param filename file name * \param filename file name
* \return 0 when succeed, -1 when failure happens * \return R NULL value
*/ */
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterSaveModel_R( LIGHTGBM_C_EXPORT SEXP LGBM_BoosterSaveModel_R(
LGBM_SE handle, LGBM_SE handle,
......
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