Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
28e891ad
Commit
28e891ad
authored
Nov 26, 2016
by
Guolin Ke
Browse files
typo
parent
d8ecdaf5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
49 deletions
+49
-49
include/LightGBM/c_api.h
include/LightGBM/c_api.h
+32
-32
src/boosting/gbdt.cpp
src/boosting/gbdt.cpp
+13
-13
src/c_api.cpp
src/c_api.cpp
+4
-4
No files found.
include/LightGBM/c_api.h
View file @
28e891ad
...
@@ -38,7 +38,7 @@ typedef void* BoosterHandle;
...
@@ -38,7 +38,7 @@ typedef void* BoosterHandle;
/*!
/*!
* \brief get string message of the last error
* \brief get string message of the last error
* all function in this file will return 0 when succe
ss
* all function in this file will return 0 when succe
ed
* and -1 when an error occured,
* and -1 when an error occured,
* \return const char* error inforomation
* \return const char* error inforomation
*/
*/
...
@@ -53,7 +53,7 @@ DllExport const char* LGBM_GetLastError();
...
@@ -53,7 +53,7 @@ DllExport const char* LGBM_GetLastError();
* \param parameters additional parameters
* \param parameters additional parameters
* \param reference used to align bin mapper with other dataset, nullptr means don't used
* \param reference used to align bin mapper with other dataset, nullptr means don't used
* \param out a loaded dataset
* \param out a loaded dataset
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_CreateDatasetFromFile
(
const
char
*
filename
,
DllExport
int
LGBM_CreateDatasetFromFile
(
const
char
*
filename
,
const
char
*
parameters
,
const
char
*
parameters
,
...
@@ -64,7 +64,7 @@ DllExport int LGBM_CreateDatasetFromFile(const char* filename,
...
@@ -64,7 +64,7 @@ DllExport int LGBM_CreateDatasetFromFile(const char* filename,
* \brief load data set from binary file like the command_line LightGBM do
* \brief load data set from binary file like the command_line LightGBM do
* \param filename the name of the file
* \param filename the name of the file
* \param out a loaded dataset
* \param out a loaded dataset
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_CreateDatasetFromBinaryFile
(
const
char
*
filename
,
DllExport
int
LGBM_CreateDatasetFromBinaryFile
(
const
char
*
filename
,
DatesetHandle
*
out
);
DatesetHandle
*
out
);
...
@@ -82,7 +82,7 @@ DllExport int LGBM_CreateDatasetFromBinaryFile(const char* filename,
...
@@ -82,7 +82,7 @@ DllExport int LGBM_CreateDatasetFromBinaryFile(const char* filename,
* \param parameters additional parameters
* \param parameters additional parameters
* \param reference used to align bin mapper with other dataset, nullptr means don't used
* \param reference used to align bin mapper with other dataset, nullptr means don't used
* \param out created dataset
* \param out created dataset
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_CreateDatasetFromCSR
(
const
void
*
indptr
,
DllExport
int
LGBM_CreateDatasetFromCSR
(
const
void
*
indptr
,
int
indptr_type
,
int
indptr_type
,
...
@@ -109,7 +109,7 @@ DllExport int LGBM_CreateDatasetFromCSR(const void* indptr,
...
@@ -109,7 +109,7 @@ DllExport int LGBM_CreateDatasetFromCSR(const void* indptr,
* \param parameters additional parameters
* \param parameters additional parameters
* \param reference used to align bin mapper with other dataset, nullptr means don't used
* \param reference used to align bin mapper with other dataset, nullptr means don't used
* \param out created dataset
* \param out created dataset
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_CreateDatasetFromCSC
(
const
void
*
col_ptr
,
DllExport
int
LGBM_CreateDatasetFromCSC
(
const
void
*
col_ptr
,
int
col_ptr_type
,
int
col_ptr_type
,
...
@@ -133,7 +133,7 @@ DllExport int LGBM_CreateDatasetFromCSC(const void* col_ptr,
...
@@ -133,7 +133,7 @@ DllExport int LGBM_CreateDatasetFromCSC(const void* col_ptr,
* \param parameters additional parameters
* \param parameters additional parameters
* \param reference used to align bin mapper with other dataset, nullptr means don't used
* \param reference used to align bin mapper with other dataset, nullptr means don't used
* \param out created dataset
* \param out created dataset
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_CreateDatasetFromMat
(
const
void
*
data
,
DllExport
int
LGBM_CreateDatasetFromMat
(
const
void
*
data
,
int
data_type
,
int
data_type
,
...
@@ -146,7 +146,7 @@ DllExport int LGBM_CreateDatasetFromMat(const void* data,
...
@@ -146,7 +146,7 @@ DllExport int LGBM_CreateDatasetFromMat(const void* data,
/*!
/*!
* \brief free space for dataset
* \brief free space for dataset
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_DatasetFree
(
DatesetHandle
handle
);
DllExport
int
LGBM_DatasetFree
(
DatesetHandle
handle
);
...
@@ -154,7 +154,7 @@ DllExport int LGBM_DatasetFree(DatesetHandle handle);
...
@@ -154,7 +154,7 @@ DllExport int LGBM_DatasetFree(DatesetHandle handle);
* \brief save dateset to binary file
* \brief save dateset to binary file
* \param handle a instance of dataset
* \param handle a instance of dataset
* \param filename file name
* \param filename file name
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_DatasetSaveBinary
(
DatesetHandle
handle
,
DllExport
int
LGBM_DatasetSaveBinary
(
DatesetHandle
handle
,
const
char
*
filename
);
const
char
*
filename
);
...
@@ -166,7 +166,7 @@ DllExport int LGBM_DatasetSaveBinary(DatesetHandle handle,
...
@@ -166,7 +166,7 @@ DllExport int LGBM_DatasetSaveBinary(DatesetHandle handle,
* \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
* \param type float32 or int32
* \param type float32 or int32
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_DatasetSetField
(
DatesetHandle
handle
,
DllExport
int
LGBM_DatasetSetField
(
DatesetHandle
handle
,
const
char
*
field_name
,
const
char
*
field_name
,
...
@@ -181,7 +181,7 @@ DllExport int LGBM_DatasetSetField(DatesetHandle handle,
...
@@ -181,7 +181,7 @@ DllExport int LGBM_DatasetSetField(DatesetHandle handle,
* \param out_len used to set result length
* \param out_len used to set result length
* \param out_ptr pointer to the result
* \param out_ptr pointer to the result
* \param out_type float32 or int32
* \param out_type float32 or int32
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_DatasetGetField
(
DatesetHandle
handle
,
DllExport
int
LGBM_DatasetGetField
(
DatesetHandle
handle
,
const
char
*
field_name
,
const
char
*
field_name
,
...
@@ -193,7 +193,7 @@ DllExport int LGBM_DatasetGetField(DatesetHandle handle,
...
@@ -193,7 +193,7 @@ DllExport int LGBM_DatasetGetField(DatesetHandle handle,
* \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 succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_DatasetGetNumData
(
DatesetHandle
handle
,
DllExport
int
LGBM_DatasetGetNumData
(
DatesetHandle
handle
,
int64_t
*
out
);
int64_t
*
out
);
...
@@ -202,7 +202,7 @@ DllExport int LGBM_DatasetGetNumData(DatesetHandle handle,
...
@@ -202,7 +202,7 @@ DllExport int LGBM_DatasetGetNumData(DatesetHandle handle,
* \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 succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_DatasetGetNumFeature
(
DatesetHandle
handle
,
DllExport
int
LGBM_DatasetGetNumFeature
(
DatesetHandle
handle
,
int64_t
*
out
);
int64_t
*
out
);
...
@@ -214,7 +214,7 @@ DllExport int LGBM_DatasetGetNumFeature(DatesetHandle handle,
...
@@ -214,7 +214,7 @@ DllExport int LGBM_DatasetGetNumFeature(DatesetHandle handle,
* \param train_data training data set
* \param train_data training data set
* \param parameters format: 'key1=value1 key2=value2'
* \param parameters format: 'key1=value1 key2=value2'
* \prama out handle of created Booster
* \prama out handle of created Booster
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_BoosterCreate
(
const
DatesetHandle
train_data
,
DllExport
int
LGBM_BoosterCreate
(
const
DatesetHandle
train_data
,
const
char
*
parameters
,
const
char
*
parameters
,
...
@@ -225,7 +225,7 @@ DllExport int LGBM_BoosterCreate(const DatesetHandle train_data,
...
@@ -225,7 +225,7 @@ DllExport int LGBM_BoosterCreate(const DatesetHandle train_data,
* \param filename filename of model
* \param filename filename of model
* \param out_num_total_model number of total models
* \param out_num_total_model number of total models
* \param out handle of created Booster
* \param out handle of created Booster
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_BoosterCreateFromModelfile
(
DllExport
int
LGBM_BoosterCreateFromModelfile
(
const
char
*
filename
,
const
char
*
filename
,
...
@@ -236,7 +236,7 @@ DllExport int LGBM_BoosterCreateFromModelfile(
...
@@ -236,7 +236,7 @@ DllExport int LGBM_BoosterCreateFromModelfile(
/*!
/*!
* \brief free obj in handle
* \brief free obj in handle
* \param handle handle to be freed
* \param handle handle to be freed
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_BoosterFree
(
BoosterHandle
handle
);
DllExport
int
LGBM_BoosterFree
(
BoosterHandle
handle
);
...
@@ -244,7 +244,7 @@ DllExport int LGBM_BoosterFree(BoosterHandle handle);
...
@@ -244,7 +244,7 @@ DllExport int LGBM_BoosterFree(BoosterHandle handle);
* \brief Merge model in two booster to first handle
* \brief Merge model in two booster to first handle
* \param handle handle, will merge other handle to this
* \param handle handle, will merge other handle to this
* \param other_handle
* \param other_handle
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_BoosterMerge
(
BoosterHandle
handle
,
DllExport
int
LGBM_BoosterMerge
(
BoosterHandle
handle
,
BoosterHandle
other_handle
);
BoosterHandle
other_handle
);
...
@@ -253,7 +253,7 @@ DllExport int LGBM_BoosterMerge(BoosterHandle handle,
...
@@ -253,7 +253,7 @@ DllExport int LGBM_BoosterMerge(BoosterHandle handle,
* \brief Add new validation to booster
* \brief Add new validation to booster
* \param handle handle
* \param handle handle
* \param valid_data validation data set
* \param valid_data validation data set
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_BoosterAddValidData
(
BoosterHandle
handle
,
DllExport
int
LGBM_BoosterAddValidData
(
BoosterHandle
handle
,
const
DatesetHandle
valid_data
);
const
DatesetHandle
valid_data
);
...
@@ -262,7 +262,7 @@ DllExport int LGBM_BoosterAddValidData(BoosterHandle handle,
...
@@ -262,7 +262,7 @@ DllExport int LGBM_BoosterAddValidData(BoosterHandle handle,
* \brief Reset training data for booster
* \brief Reset training data for booster
* \param handle handle
* \param handle handle
* \param train_data training data set
* \param train_data training data set
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_BoosterResetTrainingData
(
BoosterHandle
handle
,
DllExport
int
LGBM_BoosterResetTrainingData
(
BoosterHandle
handle
,
const
DatesetHandle
train_data
);
const
DatesetHandle
train_data
);
...
@@ -271,7 +271,7 @@ DllExport int LGBM_BoosterResetTrainingData(BoosterHandle handle,
...
@@ -271,7 +271,7 @@ DllExport int LGBM_BoosterResetTrainingData(BoosterHandle handle,
* \brief Reset config for current booster
* \brief Reset config for current booster
* \param handle handle
* \param handle handle
* \param parameters format: 'key1=value1 key2=value2'
* \param parameters format: 'key1=value1 key2=value2'
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_BoosterResetParameter
(
BoosterHandle
handle
,
const
char
*
parameters
);
DllExport
int
LGBM_BoosterResetParameter
(
BoosterHandle
handle
,
const
char
*
parameters
);
...
@@ -286,7 +286,7 @@ DllExport int LGBM_BoosterGetNumClasses(BoosterHandle handle, int64_t* out_len);
...
@@ -286,7 +286,7 @@ DllExport int LGBM_BoosterGetNumClasses(BoosterHandle handle, int64_t* out_len);
* \brief update the model in one round
* \brief update the model in one round
* \param handle handle
* \param handle handle
* \param is_finished 1 means finised(cannot split any more)
* \param is_finished 1 means finised(cannot split any more)
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_BoosterUpdateOneIter
(
BoosterHandle
handle
,
int
*
is_finished
);
DllExport
int
LGBM_BoosterUpdateOneIter
(
BoosterHandle
handle
,
int
*
is_finished
);
...
@@ -297,7 +297,7 @@ DllExport int LGBM_BoosterUpdateOneIter(BoosterHandle handle, int* is_finished);
...
@@ -297,7 +297,7 @@ DllExport int LGBM_BoosterUpdateOneIter(BoosterHandle handle, int* is_finished);
* \param grad gradient statistics
* \param grad gradient statistics
* \param hess second order gradient statistics
* \param hess second order gradient statistics
* \param is_finished 1 means finised(cannot split any more)
* \param is_finished 1 means finised(cannot split any more)
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_BoosterUpdateOneIterCustom
(
BoosterHandle
handle
,
DllExport
int
LGBM_BoosterUpdateOneIterCustom
(
BoosterHandle
handle
,
const
float
*
grad
,
const
float
*
grad
,
...
@@ -307,7 +307,7 @@ DllExport int LGBM_BoosterUpdateOneIterCustom(BoosterHandle handle,
...
@@ -307,7 +307,7 @@ DllExport int LGBM_BoosterUpdateOneIterCustom(BoosterHandle handle,
/*!
/*!
* \brief Rollback one iteration
* \brief Rollback one iteration
* \param handle handle
* \param handle handle
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_BoosterRollbackOneIter
(
BoosterHandle
handle
);
DllExport
int
LGBM_BoosterRollbackOneIter
(
BoosterHandle
handle
);
...
@@ -332,13 +332,13 @@ DllExport int LGBM_BoosterGetEvalNames(BoosterHandle handle, int64_t* out_len, c
...
@@ -332,13 +332,13 @@ DllExport int LGBM_BoosterGetEvalNames(BoosterHandle handle, int64_t* out_len, c
/*!
/*!
* \brief get evaluation for training data and validation data
* \brief get evaluation for training data and validation data
* \param handle handle
* \param handle handle
* \param data 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_len len of output result
* \param out_len len of output result
* \param out_result the string containing evaluation statistics, should allocate memory before call this function
* \param out_result the string containing evaluation statistics, should allocate memory before call this function
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_BoosterGetEval
(
BoosterHandle
handle
,
DllExport
int
LGBM_BoosterGetEval
(
BoosterHandle
handle
,
int
data
,
int
data
_idx
,
int64_t
*
out_len
,
int64_t
*
out_len
,
float
*
out_results
);
float
*
out_results
);
...
@@ -346,13 +346,13 @@ DllExport int LGBM_BoosterGetEval(BoosterHandle handle,
...
@@ -346,13 +346,13 @@ DllExport int LGBM_BoosterGetEval(BoosterHandle handle,
* \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 handle
* \param data 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_len len of output result
* \param out_len len of output result
* \param out_result used to set a pointer to array, should allocate memory before call this function
* \param out_result used to set a pointer to array, should allocate memory before call this function
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_BoosterGetPredict
(
BoosterHandle
handle
,
DllExport
int
LGBM_BoosterGetPredict
(
BoosterHandle
handle
,
int
data
,
int
data
_idx
,
int64_t
*
out_len
,
int64_t
*
out_len
,
float
*
out_result
);
float
*
out_result
);
...
@@ -367,7 +367,7 @@ DllExport int LGBM_BoosterGetPredict(BoosterHandle handle,
...
@@ -367,7 +367,7 @@ DllExport int LGBM_BoosterGetPredict(BoosterHandle handle,
* 2:leaf index
* 2:leaf index
* \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 result_filename filename of result file
* \param result_filename filename of result file
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_BoosterPredictForFile
(
BoosterHandle
handle
,
DllExport
int
LGBM_BoosterPredictForFile
(
BoosterHandle
handle
,
const
char
*
data_filename
,
const
char
*
data_filename
,
...
@@ -394,7 +394,7 @@ DllExport int LGBM_BoosterPredictForFile(BoosterHandle handle,
...
@@ -394,7 +394,7 @@ DllExport int LGBM_BoosterPredictForFile(BoosterHandle handle,
* \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 len of output result
* \param out_len len of output result
* \param out_result used to set a pointer to array, should allocate memory before call this function
* \param out_result used to set a pointer to array, should allocate memory before call this function
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_BoosterPredictForCSR
(
BoosterHandle
handle
,
DllExport
int
LGBM_BoosterPredictForCSR
(
BoosterHandle
handle
,
const
void
*
indptr
,
const
void
*
indptr
,
...
@@ -425,7 +425,7 @@ DllExport int LGBM_BoosterPredictForCSR(BoosterHandle handle,
...
@@ -425,7 +425,7 @@ DllExport int LGBM_BoosterPredictForCSR(BoosterHandle handle,
* \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 len of output result
* \param out_len len of output result
* \param out_result used to set a pointer to array, should allocate memory before call this function
* \param out_result used to set a pointer to array, should allocate memory before call this function
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_BoosterPredictForMat
(
BoosterHandle
handle
,
DllExport
int
LGBM_BoosterPredictForMat
(
BoosterHandle
handle
,
const
void
*
data
,
const
void
*
data
,
...
@@ -443,7 +443,7 @@ DllExport int LGBM_BoosterPredictForMat(BoosterHandle handle,
...
@@ -443,7 +443,7 @@ DllExport int LGBM_BoosterPredictForMat(BoosterHandle handle,
* \param handle handle
* \param handle handle
* \param num_iteration, < 0 means no limit
* \param num_iteration, < 0 means no limit
* \param filename file name
* \param filename file name
* \return 0 when succe
ss
, -1 when failure happens
* \return 0 when succe
ed
, -1 when failure happens
*/
*/
DllExport
int
LGBM_BoosterSaveModel
(
BoosterHandle
handle
,
DllExport
int
LGBM_BoosterSaveModel
(
BoosterHandle
handle
,
int
num_iteration
,
int
num_iteration
,
...
...
src/boosting/gbdt.cpp
View file @
28e891ad
...
@@ -395,23 +395,23 @@ void GBDT::Boosting() {
...
@@ -395,23 +395,23 @@ void GBDT::Boosting() {
void
GBDT
::
SaveModelToFile
(
int
num_iteration
,
const
char
*
filename
)
const
{
void
GBDT
::
SaveModelToFile
(
int
num_iteration
,
const
char
*
filename
)
const
{
/*! \brief File to write models */
/*! \brief File to write models */
std
::
ofstream
outpu_file
;
std
::
ofstream
outpu
t
_file
;
outpu_file
.
open
(
filename
);
outpu
t
_file
.
open
(
filename
);
// output model type
// output model type
outpu_file
<<
Name
()
<<
std
::
endl
;
outpu
t
_file
<<
Name
()
<<
std
::
endl
;
// output number of class
// output number of class
outpu_file
<<
"num_class="
<<
num_class_
<<
std
::
endl
;
outpu
t
_file
<<
"num_class="
<<
num_class_
<<
std
::
endl
;
// output label index
// output label index
outpu_file
<<
"label_index="
<<
label_idx_
<<
std
::
endl
;
outpu
t
_file
<<
"label_index="
<<
label_idx_
<<
std
::
endl
;
// output max_feature_idx
// output max_feature_idx
outpu_file
<<
"max_feature_idx="
<<
max_feature_idx_
<<
std
::
endl
;
outpu
t
_file
<<
"max_feature_idx="
<<
max_feature_idx_
<<
std
::
endl
;
// output objective name
// output objective name
if
(
object_function_
!=
nullptr
)
{
if
(
object_function_
!=
nullptr
)
{
outpu_file
<<
"objective="
<<
object_function_
->
GetName
()
<<
std
::
endl
;
outpu
t
_file
<<
"objective="
<<
object_function_
->
GetName
()
<<
std
::
endl
;
}
}
// output sigmoid parameter
// output sigmoid parameter
outpu_file
<<
"sigmoid="
<<
sigmoid_
<<
std
::
endl
;
outpu
t
_file
<<
"sigmoid="
<<
sigmoid_
<<
std
::
endl
;
outpu_file
<<
std
::
endl
;
outpu
t
_file
<<
std
::
endl
;
int
num_used_model
=
0
;
int
num_used_model
=
0
;
if
(
num_iteration
==
NO_LIMIT
)
{
if
(
num_iteration
==
NO_LIMIT
)
{
...
@@ -422,12 +422,12 @@ void GBDT::SaveModelToFile(int num_iteration, const char* filename) const {
...
@@ -422,12 +422,12 @@ void GBDT::SaveModelToFile(int num_iteration, const char* filename) const {
// output tree models
// output tree models
for
(
int
i
=
0
;
i
<
num_used_model
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num_used_model
;
++
i
)
{
outpu_file
<<
"Tree="
<<
i
<<
std
::
endl
;
outpu
t
_file
<<
"Tree="
<<
i
<<
std
::
endl
;
outpu_file
<<
models_
[
i
]
->
ToString
()
<<
std
::
endl
;
outpu
t
_file
<<
models_
[
i
]
->
ToString
()
<<
std
::
endl
;
}
}
outpu_file
<<
std
::
endl
<<
FeatureImportance
()
<<
std
::
endl
;
outpu
t
_file
<<
std
::
endl
<<
FeatureImportance
()
<<
std
::
endl
;
outpu_file
.
close
();
outpu
t
_file
.
close
();
}
}
void
GBDT
::
LoadModelFromString
(
const
std
::
string
&
model_str
)
{
void
GBDT
::
LoadModelFromString
(
const
std
::
string
&
model_str
)
{
...
...
src/c_api.cpp
View file @
28e891ad
...
@@ -593,13 +593,13 @@ DllExport int LGBM_BoosterGetEvalNames(BoosterHandle handle, int64_t* out_len, c
...
@@ -593,13 +593,13 @@ DllExport int LGBM_BoosterGetEvalNames(BoosterHandle handle, int64_t* out_len, c
DllExport
int
LGBM_BoosterGetEval
(
BoosterHandle
handle
,
DllExport
int
LGBM_BoosterGetEval
(
BoosterHandle
handle
,
int
data
,
int
data
_idx
,
int64_t
*
out_len
,
int64_t
*
out_len
,
float
*
out_results
)
{
float
*
out_results
)
{
API_BEGIN
();
API_BEGIN
();
Booster
*
ref_booster
=
reinterpret_cast
<
Booster
*>
(
handle
);
Booster
*
ref_booster
=
reinterpret_cast
<
Booster
*>
(
handle
);
auto
boosting
=
ref_booster
->
GetBoosting
();
auto
boosting
=
ref_booster
->
GetBoosting
();
auto
result_buf
=
boosting
->
GetEvalAt
(
data
);
auto
result_buf
=
boosting
->
GetEvalAt
(
data
_idx
);
*
out_len
=
static_cast
<
int64_t
>
(
result_buf
.
size
());
*
out_len
=
static_cast
<
int64_t
>
(
result_buf
.
size
());
for
(
size_t
i
=
0
;
i
<
result_buf
.
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
result_buf
.
size
();
++
i
)
{
(
out_results
)[
i
]
=
static_cast
<
float
>
(
result_buf
[
i
]);
(
out_results
)[
i
]
=
static_cast
<
float
>
(
result_buf
[
i
]);
...
@@ -608,13 +608,13 @@ DllExport int LGBM_BoosterGetEval(BoosterHandle handle,
...
@@ -608,13 +608,13 @@ DllExport int LGBM_BoosterGetEval(BoosterHandle handle,
}
}
DllExport
int
LGBM_BoosterGetPredict
(
BoosterHandle
handle
,
DllExport
int
LGBM_BoosterGetPredict
(
BoosterHandle
handle
,
int
data
,
int
data
_idx
,
int64_t
*
out_len
,
int64_t
*
out_len
,
float
*
out_result
)
{
float
*
out_result
)
{
API_BEGIN
();
API_BEGIN
();
Booster
*
ref_booster
=
reinterpret_cast
<
Booster
*>
(
handle
);
Booster
*
ref_booster
=
reinterpret_cast
<
Booster
*>
(
handle
);
int
len
=
0
;
int
len
=
0
;
ref_booster
->
GetPredictAt
(
data
,
out_result
,
&
len
);
ref_booster
->
GetPredictAt
(
data
_idx
,
out_result
,
&
len
);
*
out_len
=
static_cast
<
int64_t
>
(
len
);
*
out_len
=
static_cast
<
int64_t
>
(
len
);
API_END
();
API_END
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment