lightgbm_R.h 15.3 KB
Newer Older
1
2
3
4
/*!
 * Copyright (c) 2017 Microsoft Corporation. All rights reserved.
 * Licensed under the MIT License. See LICENSE file in the project root for license information.
 */
Guolin Ke's avatar
Guolin Ke committed
5
6
7
8
#ifndef LIGHTGBM_R_H_
#define LIGHTGBM_R_H_

#include <LightGBM/c_api.h>
9
#include <LightGBM/R_object_helper.h>
Guolin Ke's avatar
Guolin Ke committed
10

11
#include <cstdint>
Guolin Ke's avatar
Guolin Ke committed
12
13
14

/*!
* \brief get string message of the last error
15
16
*  all functions in this file will return 0 on success
*  and -1 when an error occured
Guolin Ke's avatar
Guolin Ke committed
17
18
19
* \return err_msg error inforomation
* \return error inforomation
*/
Guolin Ke's avatar
Guolin Ke committed
20
LIGHTGBM_C_EXPORT LGBM_SE LGBM_GetLastError_R(LGBM_SE buf_len, LGBM_SE actual_len, LGBM_SE err_msg);
Guolin Ke's avatar
Guolin Ke committed
21
22
23
24

// --- start Dataset interface

/*!
25
* \brief load data set from file like the command_line LightGBM does
Guolin Ke's avatar
Guolin Ke committed
26
27
* \param filename the name of the file
* \param parameters additional parameters
28
* \param reference used to align bin mapper with other dataset, nullptr means not used
Guolin Ke's avatar
Guolin Ke committed
29
30
31
* \param out created dataset
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
32
33
34
35
36
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetCreateFromFile_R(LGBM_SE filename,
  LGBM_SE parameters,
  LGBM_SE reference,
  LGBM_SE out,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
37
38
39
40
41
42
43
44
45
46

/*!
* \brief create a dataset from CSC format
* \param indptr pointer to row headers
* \param indices findex
* \param data fvalue
* \param nindptr number of cols in the matrix + 1
* \param nelem number of nonzero elements in the matrix
* \param num_row number of rows
* \param parameters additional parameters
47
* \param reference used to align bin mapper with other dataset, nullptr means not used
Guolin Ke's avatar
Guolin Ke committed
48
49
50
* \param out created dataset
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
51
52
53
54
55
56
57
58
59
60
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);
Guolin Ke's avatar
Guolin Ke committed
61
62
63
64
65
66
67
68


/*!
* \brief create dataset from dense matrix
* \param data matric data
* \param nrow number of rows
* \param ncol number columns
* \param parameters additional parameters
69
* \param reference used to align bin mapper with other dataset, nullptr means not used
Guolin Ke's avatar
Guolin Ke committed
70
71
72
* \param out created dataset
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
73
74
75
76
77
78
79
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);
Guolin Ke's avatar
Guolin Ke committed
80
81
82
83
84
85
86
87
88
89

/*!
* \brief Create subset of a data
* \param handle handle of full dataset
* \param used_row_indices Indices used in subset
* \param len_used_row_indices length of Indices used in subset
* \param parameters additional parameters
* \param out created dataset
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
90
91
92
93
94
95
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);
Guolin Ke's avatar
Guolin Ke committed
96
97
98
99
100
101
102

/*!
* \brief save feature names to Dataset
* \param handle handle
* \param feature_names feature names
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
103
104
105
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetSetFeatureNames_R(LGBM_SE handle,
  LGBM_SE feature_names,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
106
107
108
109
110
111
112

/*!
* \brief save feature names to Dataset
* \param handle handle
* \param feature_names feature names
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
113
114
115
116
117
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);
Guolin Ke's avatar
Guolin Ke committed
118
119
120

/*!
* \brief save dateset to binary file
121
* \param handle an instance of dataset
Guolin Ke's avatar
Guolin Ke committed
122
123
124
* \param filename file name
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
125
126
127
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetSaveBinary_R(LGBM_SE handle,
  LGBM_SE filename,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
128
129
130

/*!
* \brief free dataset
131
* \param handle an instance of dataset
Guolin Ke's avatar
Guolin Ke committed
132
133
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
134
135
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetFree_R(LGBM_SE handle,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
136
137
138

/*!
* \brief set vector to a content in info
139
*        Note: group and group_id only work for C_API_DTYPE_INT32
Guolin Ke's avatar
Guolin Ke committed
140
*              label and weight only work for C_API_DTYPE_FLOAT32
141
* \param handle an instance of dataset
Guolin Ke's avatar
Guolin Ke committed
142
143
144
145
146
* \param field_name field name, can be label, weight, group, group_id
* \param field_data pointer to vector
* \param num_element number of element in field_data
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
147
148
149
150
151
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);
Guolin Ke's avatar
Guolin Ke committed
152
153
154

/*!
* \brief get size of info vector from dataset
155
* \param handle an instance of dataset
Guolin Ke's avatar
Guolin Ke committed
156
157
158
159
* \param field_name field name
* \param out size of info vector from dataset
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
160
161
162
163
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetGetFieldSize_R(LGBM_SE handle,
  LGBM_SE field_name,
  LGBM_SE out,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
164
165
166

/*!
* \brief get info vector from dataset
167
* \param handle an instance of dataset
Guolin Ke's avatar
Guolin Ke committed
168
169
170
171
* \param field_name field name
* \param field_data pointer to vector
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
172
173
174
175
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetGetField_R(LGBM_SE handle,
  LGBM_SE field_name,
  LGBM_SE field_data,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
176

177
178
179
180
181
182
183
184
185
186
/*!
* \brief Update parameters for a Dataset
* \param handle a instance of data matrix
* \param parameters parameters
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetUpdateParam_R(LGBM_SE handle,
  LGBM_SE params,
  LGBM_SE call_state);

Guolin Ke's avatar
Guolin Ke committed
187
188
189
190
191
192
/*!
* \brief get number of data.
* \param handle the handle to the dataset
* \param out The address to hold number of data
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
193
194
195
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetGetNumData_R(LGBM_SE handle,
  LGBM_SE out,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
196
197
198
199
200
201
202

/*!
* \brief get number of features
* \param handle the handle to the dataset
* \param out The output of number of features
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
203
204
205
LIGHTGBM_C_EXPORT LGBM_SE LGBM_DatasetGetNumFeature_R(LGBM_SE handle,
  LGBM_SE out,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
206
207
208
209
210
211
212
213
214
215

// --- start Booster interfaces

/*!
* \brief create an new boosting learner
* \param train_data training data set
* \param parameters format: 'key1=value1 key2=value2'
* \prama out handle of created Booster
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
216
217
218
219
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterCreate_R(LGBM_SE train_data,
  LGBM_SE parameters,
  LGBM_SE out,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
220
221
222
223
224
225

/*!
* \brief free obj in handle
* \param handle handle to be freed
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
226
227
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterFree_R(LGBM_SE handle,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
228
229
230
231
232
233
234

/*!
* \brief load an existing boosting from model file
* \param filename filename of model
* \prama out handle of created Booster
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
235
236
237
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterCreateFromModelfile_R(LGBM_SE filename,
  LGBM_SE out,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
238

239
240
241
242
243
244
245
246
247
/*!
* \brief load an existing boosting from model_str
* \param model_str string containing the model
* \param out handle of created Booster
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterLoadModelFromString_R(LGBM_SE model_str,
  LGBM_SE out,
  LGBM_SE call_state);
248

Guolin Ke's avatar
Guolin Ke committed
249
/*!
250
* \brief Merge model in two boosters to first handle
Guolin Ke's avatar
Guolin Ke committed
251
252
253
254
* \param handle handle, will merge other handle to this
* \param other_handle
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
255
256
257
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterMerge_R(LGBM_SE handle,
  LGBM_SE other_handle,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
258
259
260
261
262
263
264

/*!
* \brief Add new validation to booster
* \param handle handle
* \param valid_data validation data set
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
265
266
267
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterAddValidData_R(LGBM_SE handle,
  LGBM_SE valid_data,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
268
269
270
271
272
273
274

/*!
* \brief Reset training data for booster
* \param handle handle
* \param train_data training data set
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
275
276
277
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterResetTrainingData_R(LGBM_SE handle,
  LGBM_SE train_data,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
278
279
280
281
282
283
284

/*!
* \brief Reset config for current booster
* \param handle handle
* \param parameters format: 'key1=value1 key2=value2'
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
285
286
287
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterResetParameter_R(LGBM_SE handle,
  LGBM_SE parameters,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
288
289

/*!
290
* \brief Get number of classes
Guolin Ke's avatar
Guolin Ke committed
291
292
293
294
* \param handle handle
* \param out number of classes
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
295
296
297
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetNumClasses_R(LGBM_SE handle,
  LGBM_SE out,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
298
299
300
301
302
303

/*!
* \brief update the model in one round
* \param handle handle
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
304
305
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterUpdateOneIter_R(LGBM_SE handle,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
306
307
308
309
310
311
312
313
314
315

/*!
* \brief update the model, by directly specify gradient and second order gradient,
*       this can be used to support customized loss function
* \param handle handle
* \param grad gradient statistics
* \param hess second order gradient statistics
* \param len length of grad/hess
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
316
317
318
319
320
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterUpdateOneIterCustom_R(LGBM_SE handle,
  LGBM_SE grad,
  LGBM_SE hess,
  LGBM_SE len,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
321
322
323
324
325
326

/*!
* \brief Rollback one iteration
* \param handle handle
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
327
328
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterRollbackOneIter_R(LGBM_SE handle,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
329
330
331
332
333
334

/*!
* \brief Get iteration of current boosting rounds
* \param out iteration of boosting rounds
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
335
336
337
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetCurrentIteration_R(LGBM_SE handle,
  LGBM_SE out,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
338
339
340
341
342
343

/*!
* \brief Get Name of eval
* \param eval_names eval names
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
344
345
346
347
348
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);
Guolin Ke's avatar
Guolin Ke committed
349
350
351
352
353
354
355
356

/*!
* \brief get evaluation for training data and validation data
* \param handle handle
* \param data_idx 0:training data, 1: 1st valid data, 2:2nd valid data ...
* \param out_result float arrary contains result
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
357
358
359
360
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetEval_R(LGBM_SE handle,
  LGBM_SE data_idx,
  LGBM_SE out_result,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
361
362
363
364
365
366
367
368

/*!
* \brief Get number of prediction for training data and validation data
* \param handle handle
* \param data_idx 0:training data, 1: 1st valid data, 2:2nd valid data ...
* \param out size of predict
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
369
370
371
372
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetNumPredict_R(LGBM_SE handle,
  LGBM_SE data_idx,
  LGBM_SE out,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
373
374

/*!
375
376
* \brief Get prediction for training data and validation data.
*        This can be used to support customized eval function
Guolin Ke's avatar
Guolin Ke committed
377
378
379
380
381
* \param handle handle
* \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
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
382
383
384
385
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterGetPredict_R(LGBM_SE handle,
  LGBM_SE data_idx,
  LGBM_SE out_result,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
386
387
388
389
390
391
392
393
394
395
396
397

/*!
* \brief make prediction for file
* \param handle handle
* \param data_filename filename of data file
* \param data_has_header data file has header or not
* \param is_rawscore
* \param is_leafidx
* \param num_iteration number of iteration for prediction, <= 0 means no limit
* \return 0 when succeed, -1 when failure happens
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
398
399
400
401
402
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,
403
  LGBM_SE is_predcontrib,
Guolin Ke's avatar
Guolin Ke committed
404
  LGBM_SE num_iteration,
405
  LGBM_SE parameter,
Guolin Ke's avatar
Guolin Ke committed
406
407
  LGBM_SE result_filename,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
408
409
410
411
412
413
414
415
416
417
418

/*!
* \brief Get number of prediction
* \param handle handle
* \param num_row
* \param is_rawscore
* \param is_leafidx
* \param num_iteration number of iteration for prediction, <= 0 means no limit
* \param out_len lenght of prediction
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
419
420
421
422
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterCalcNumPredict_R(LGBM_SE handle,
  LGBM_SE num_row,
  LGBM_SE is_rawscore,
  LGBM_SE is_leafidx,
423
  LGBM_SE is_predcontrib,
Guolin Ke's avatar
Guolin Ke committed
424
425
426
  LGBM_SE num_iteration,
  LGBM_SE out_len,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
427
428
429
430

/*!
* \brief make prediction for an new data set
*        Note:  should pre-allocate memory for out_result,
431
*               for normal and raw score: its length is equal to num_class * num_data
Guolin Ke's avatar
Guolin Ke committed
432
433
434
435
436
437
*               for leaf index, its length is equal to num_class * num_data * num_iteration
* \param handle handle
* \param indptr pointer to row headers
* \param indices findex
* \param data fvalue
* \param nindptr number of cols in the matrix + 1
438
* \param nelem number of non-zero elements in the matrix
Guolin Ke's avatar
Guolin Ke committed
439
440
441
442
443
444
445
* \param num_row number of rows
* \param is_rawscore
* \param is_leafidx
* \param num_iteration number of iteration for prediction, <= 0 means no limit
* \param out prediction result
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
446
447
448
449
450
451
452
453
454
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,
455
  LGBM_SE is_predcontrib,
Guolin Ke's avatar
Guolin Ke committed
456
  LGBM_SE num_iteration,
457
  LGBM_SE parameter,
Guolin Ke's avatar
Guolin Ke committed
458
459
  LGBM_SE out_result,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
460
461

/*!
462
* \brief make prediction for a new data set
Guolin Ke's avatar
Guolin Ke committed
463
*        Note:  should pre-allocate memory for out_result,
464
*               for normal and raw score: its length is equal to num_class * num_data
Guolin Ke's avatar
Guolin Ke committed
465
466
467
468
469
470
471
472
473
474
475
*               for leaf index, its length is equal to num_class * num_data * num_iteration
* \param handle handle
* \param data pointer to the data space
* \param nrow number of rows
* \param ncol number columns
* \param is_rawscore
* \param is_leafidx
* \param num_iteration number of iteration for prediction, <= 0 means no limit
* \param out prediction result
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
476
477
478
479
480
481
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,
482
  LGBM_SE is_predcontrib,
Guolin Ke's avatar
Guolin Ke committed
483
  LGBM_SE num_iteration,
484
  LGBM_SE parameter,
Guolin Ke's avatar
Guolin Ke committed
485
486
  LGBM_SE out_result,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
487
488
489
490
491
492
493
494

/*!
* \brief save model into file
* \param handle handle
* \param num_iteration, <= 0 means save all
* \param filename file name
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
495
496
497
498
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterSaveModel_R(LGBM_SE handle,
  LGBM_SE num_iteration,
  LGBM_SE filename,
  LGBM_SE call_state);
Guolin Ke's avatar
Guolin Ke committed
499

500
501
502
503
504
505
506
507
508
509
510
511
512
513
/*!
* \brief create string containing model
* \param handle handle
* \param num_iteration, <= 0 means save all
* \param out_str string of model
* \return 0 when succeed, -1 when failure happens
*/
LIGHTGBM_C_EXPORT LGBM_SE LGBM_BoosterSaveModelToString_R(LGBM_SE handle,
  LGBM_SE num_iteration,
  LGBM_SE buffer_len,
  LGBM_SE actual_len,
  LGBM_SE out_str,
  LGBM_SE call_state);

Guolin Ke's avatar
Guolin Ke committed
514
515
516
517
518
519
520
/*!
* \brief dump model to json
* \param handle handle
* \param num_iteration, <= 0 means save all
* \param out_str json format string of model
* \return 0 when succeed, -1 when failure happens
*/
Guolin Ke's avatar
Guolin Ke committed
521
522
523
524
525
526
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);
Guolin Ke's avatar
Guolin Ke committed
527

528
#endif  // LIGHTGBM_R_H_