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 "R_object_helper.h"
Guolin Ke's avatar
Guolin Ke committed
10
11
12

/*!
* \brief get string message of the last error
13
*  all functions in this file will return 0 on success
14
15
16
*  and -1 when an error occurred
* \return err_msg error information
* \return error information
Guolin Ke's avatar
Guolin Ke committed
17
*/
18
19
20
21
22
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
23
24
25
26

// --- start Dataset interface

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

/*!
* \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
50
* \param reference used to align bin mapper with other dataset, nullptr means not used
Guolin Ke's avatar
Guolin Ke committed
51
52
53
* \param out created dataset
* \return 0 when succeed, -1 when failure happens
*/
54
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromCSC_R(
55
  LGBM_SE indptr,
Guolin Ke's avatar
Guolin Ke committed
56
57
58
59
60
61
62
  LGBM_SE indices,
  LGBM_SE data,
  LGBM_SE nindptr,
  LGBM_SE nelem,
  LGBM_SE num_row,
  LGBM_SE parameters,
  LGBM_SE reference,
63
  LGBM_SE out
64
);
Guolin Ke's avatar
Guolin Ke committed
65
66
67
68
69
70
71

/*!
* \brief create dataset from dense matrix
* \param data matric data
* \param nrow number of rows
* \param ncol number columns
* \param parameters additional parameters
72
* \param reference used to align bin mapper with other dataset, nullptr means not used
Guolin Ke's avatar
Guolin Ke committed
73
74
75
* \param out created dataset
* \return 0 when succeed, -1 when failure happens
*/
76
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromMat_R(
77
  LGBM_SE data,
Guolin Ke's avatar
Guolin Ke committed
78
79
80
81
  LGBM_SE nrow,
  LGBM_SE ncol,
  LGBM_SE parameters,
  LGBM_SE reference,
82
  LGBM_SE out
83
);
Guolin Ke's avatar
Guolin Ke committed
84
85
86
87
88
89
90
91
92
93

/*!
* \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
*/
94
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetSubset_R(
95
  LGBM_SE handle,
Guolin Ke's avatar
Guolin Ke committed
96
97
98
  LGBM_SE used_row_indices,
  LGBM_SE len_used_row_indices,
  LGBM_SE parameters,
99
  LGBM_SE out
100
);
Guolin Ke's avatar
Guolin Ke committed
101
102
103
104
105
106
107

/*!
* \brief save feature names to Dataset
* \param handle handle
* \param feature_names feature names
* \return 0 when succeed, -1 when failure happens
*/
108
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetFeatureNames_R(
109
  LGBM_SE handle,
110
  LGBM_SE feature_names
111
);
Guolin Ke's avatar
Guolin Ke committed
112
113
114
115
116
117
118

/*!
* \brief save feature names to Dataset
* \param handle handle
* \param feature_names feature names
* \return 0 when succeed, -1 when failure happens
*/
119
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFeatureNames_R(
120
  LGBM_SE handle,
Guolin Ke's avatar
Guolin Ke committed
121
122
  LGBM_SE buf_len,
  LGBM_SE actual_len,
123
  LGBM_SE feature_names
124
);
Guolin Ke's avatar
Guolin Ke committed
125
126

/*!
127
* \brief save dataset to binary file
128
* \param handle an instance of dataset
Guolin Ke's avatar
Guolin Ke committed
129
130
131
* \param filename file name
* \return 0 when succeed, -1 when failure happens
*/
132
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSaveBinary_R(
133
  LGBM_SE handle,
134
  LGBM_SE filename
135
);
Guolin Ke's avatar
Guolin Ke committed
136
137
138

/*!
* \brief free dataset
139
* \param handle an instance of dataset
Guolin Ke's avatar
Guolin Ke committed
140
141
* \return 0 when succeed, -1 when failure happens
*/
142
143
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetFree_R(
  LGBM_SE handle
144
);
Guolin Ke's avatar
Guolin Ke committed
145
146
147

/*!
* \brief set vector to a content in info
148
*        Note: group and group_id only work for C_API_DTYPE_INT32
Guolin Ke's avatar
Guolin Ke committed
149
*              label and weight only work for C_API_DTYPE_FLOAT32
150
* \param handle an instance of dataset
Guolin Ke's avatar
Guolin Ke committed
151
152
153
154
155
* \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
*/
156
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetField_R(
157
  LGBM_SE handle,
Guolin Ke's avatar
Guolin Ke committed
158
159
  LGBM_SE field_name,
  LGBM_SE field_data,
160
  LGBM_SE num_element
161
);
Guolin Ke's avatar
Guolin Ke committed
162
163
164

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

/*!
* \brief get info vector from dataset
178
* \param handle an instance of dataset
Guolin Ke's avatar
Guolin Ke committed
179
180
181
182
* \param field_name field name
* \param field_data pointer to vector
* \return 0 when succeed, -1 when failure happens
*/
183
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetField_R(
184
  LGBM_SE handle,
Guolin Ke's avatar
Guolin Ke committed
185
  LGBM_SE field_name,
186
  LGBM_SE field_data
187
);
Guolin Ke's avatar
Guolin Ke committed
188

189
/*!
190
191
192
193
194
 * \brief Raise errors for attempts to update dataset parameters
 * \param old_params Current dataset parameters
 * \param new_params New dataset parameters
 * \return 0 when succeed, -1 when failure happens
 */
195
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetUpdateParamChecking_R(
196
  LGBM_SE old_params,
197
  LGBM_SE new_params
198
);
199

Guolin Ke's avatar
Guolin Ke committed
200
201
202
203
204
205
/*!
* \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
*/
206
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumData_R(
207
  LGBM_SE handle,
208
  LGBM_SE out
209
);
Guolin Ke's avatar
Guolin Ke committed
210
211
212
213
214
215
216

/*!
* \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
*/
217
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumFeature_R(
218
  LGBM_SE handle,
219
  LGBM_SE out
220
);
Guolin Ke's avatar
Guolin Ke committed
221
222
223
224

// --- start Booster interfaces

/*!
225
* \brief create a new boosting learner
Guolin Ke's avatar
Guolin Ke committed
226
227
* \param train_data training data set
* \param parameters format: 'key1=value1 key2=value2'
228
* \param out handle of created Booster
Guolin Ke's avatar
Guolin Ke committed
229
230
* \return 0 when succeed, -1 when failure happens
*/
231
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreate_R(
232
  LGBM_SE train_data,
Guolin Ke's avatar
Guolin Ke committed
233
  LGBM_SE parameters,
234
  LGBM_SE out
235
);
Guolin Ke's avatar
Guolin Ke committed
236
237
238
239
240
241

/*!
* \brief free obj in handle
* \param handle handle to be freed
* \return 0 when succeed, -1 when failure happens
*/
242
243
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterFree_R(
  LGBM_SE handle
244
);
Guolin Ke's avatar
Guolin Ke committed
245
246
247
248

/*!
* \brief load an existing boosting from model file
* \param filename filename of model
249
* \param out handle of created Booster
Guolin Ke's avatar
Guolin Ke committed
250
251
* \return 0 when succeed, -1 when failure happens
*/
252
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreateFromModelfile_R(
253
  LGBM_SE filename,
254
  LGBM_SE out
255
);
Guolin Ke's avatar
Guolin Ke committed
256

257
258
259
260
261
262
/*!
* \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
*/
263
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterLoadModelFromString_R(
264
  LGBM_SE model_str,
265
  LGBM_SE out
266
);
267

Guolin Ke's avatar
Guolin Ke committed
268
/*!
269
* \brief Merge model in two boosters to first handle
Guolin Ke's avatar
Guolin Ke committed
270
271
272
273
* \param handle handle, will merge other handle to this
* \param other_handle
* \return 0 when succeed, -1 when failure happens
*/
274
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterMerge_R(
275
  LGBM_SE handle,
276
  LGBM_SE other_handle
277
);
Guolin Ke's avatar
Guolin Ke committed
278
279
280
281
282
283
284

/*!
* \brief Add new validation to booster
* \param handle handle
* \param valid_data validation data set
* \return 0 when succeed, -1 when failure happens
*/
285
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterAddValidData_R(
286
  LGBM_SE handle,
287
  LGBM_SE valid_data
288
);
Guolin Ke's avatar
Guolin Ke committed
289
290
291
292
293
294
295

/*!
* \brief Reset training data for booster
* \param handle handle
* \param train_data training data set
* \return 0 when succeed, -1 when failure happens
*/
296
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetTrainingData_R(
297
  LGBM_SE handle,
298
  LGBM_SE train_data
299
);
Guolin Ke's avatar
Guolin Ke committed
300
301
302
303
304
305
306

/*!
* \brief Reset config for current booster
* \param handle handle
* \param parameters format: 'key1=value1 key2=value2'
* \return 0 when succeed, -1 when failure happens
*/
307
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetParameter_R(
308
  LGBM_SE handle,
309
  LGBM_SE parameters
310
);
Guolin Ke's avatar
Guolin Ke committed
311
312

/*!
313
* \brief Get number of classes
Guolin Ke's avatar
Guolin Ke committed
314
315
316
317
* \param handle handle
* \param out number of classes
* \return 0 when succeed, -1 when failure happens
*/
318
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumClasses_R(
319
  LGBM_SE handle,
320
  LGBM_SE out
321
);
Guolin Ke's avatar
Guolin Ke committed
322
323
324
325
326
327

/*!
* \brief update the model in one round
* \param handle handle
* \return 0 when succeed, -1 when failure happens
*/
328
329
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterUpdateOneIter_R(
  LGBM_SE handle
330
);
Guolin Ke's avatar
Guolin Ke committed
331
332
333
334
335
336
337
338
339
340

/*!
* \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
*/
341
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterUpdateOneIterCustom_R(
342
  LGBM_SE handle,
Guolin Ke's avatar
Guolin Ke committed
343
344
  LGBM_SE grad,
  LGBM_SE hess,
345
  LGBM_SE len
346
);
Guolin Ke's avatar
Guolin Ke committed
347
348
349
350
351
352

/*!
* \brief Rollback one iteration
* \param handle handle
* \return 0 when succeed, -1 when failure happens
*/
353
354
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterRollbackOneIter_R(
  LGBM_SE handle
355
);
Guolin Ke's avatar
Guolin Ke committed
356
357
358
359
360
361

/*!
* \brief Get iteration of current boosting rounds
* \param out iteration of boosting rounds
* \return 0 when succeed, -1 when failure happens
*/
362
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetCurrentIteration_R(
363
  LGBM_SE handle,
364
  LGBM_SE out
365
);
Guolin Ke's avatar
Guolin Ke committed
366

367
368
369
370
371
372
/*!
* \brief Get model upper bound value.
* \param handle Handle of booster
* \param[out] out_results Result pointing to max value
* \return 0 when succeed, -1 when failure happens
*/
373
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetUpperBoundValue_R(
374
    LGBM_SE handle,
375
    LGBM_SE out_result
376
377
378
379
380
381
382
383
);

/*!
* \brief Get model lower bound value.
* \param handle Handle of booster
* \param[out] out_results Result pointing to min value
* \return 0 when succeed, -1 when failure happens
*/
384
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetLowerBoundValue_R(
385
    LGBM_SE handle,
386
    LGBM_SE out_result
387
388
);

Guolin Ke's avatar
Guolin Ke committed
389
390
391
392
393
/*!
* \brief Get Name of eval
* \param eval_names eval names
* \return 0 when succeed, -1 when failure happens
*/
394
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEvalNames_R(
395
  LGBM_SE handle,
Guolin Ke's avatar
Guolin Ke committed
396
397
  LGBM_SE buf_len,
  LGBM_SE actual_len,
398
  LGBM_SE eval_names
399
);
Guolin Ke's avatar
Guolin Ke committed
400
401
402
403
404

/*!
* \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 ...
405
* \param out_result float array contains result
Guolin Ke's avatar
Guolin Ke committed
406
407
* \return 0 when succeed, -1 when failure happens
*/
408
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEval_R(
409
  LGBM_SE handle,
Guolin Ke's avatar
Guolin Ke committed
410
  LGBM_SE data_idx,
411
  LGBM_SE out_result
412
);
Guolin Ke's avatar
Guolin Ke committed
413
414
415
416
417
418
419
420

/*!
* \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
*/
421
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumPredict_R(
422
  LGBM_SE handle,
Guolin Ke's avatar
Guolin Ke committed
423
  LGBM_SE data_idx,
424
  LGBM_SE out
425
);
Guolin Ke's avatar
Guolin Ke committed
426
427

/*!
428
429
* \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
430
431
432
433
434
* \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
*/
435
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetPredict_R(
436
  LGBM_SE handle,
Guolin Ke's avatar
Guolin Ke committed
437
  LGBM_SE data_idx,
438
  LGBM_SE out_result
439
);
Guolin Ke's avatar
Guolin Ke committed
440
441
442
443
444
445
446
447
448
449
450
451

/*!
* \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
*/
452
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForFile_R(
453
  LGBM_SE handle,
Guolin Ke's avatar
Guolin Ke committed
454
455
456
457
  LGBM_SE data_filename,
  LGBM_SE data_has_header,
  LGBM_SE is_rawscore,
  LGBM_SE is_leafidx,
458
  LGBM_SE is_predcontrib,
459
  LGBM_SE start_iteration,
Guolin Ke's avatar
Guolin Ke committed
460
  LGBM_SE num_iteration,
461
  LGBM_SE parameter,
462
  LGBM_SE result_filename
463
);
Guolin Ke's avatar
Guolin Ke committed
464
465
466
467
468
469
470
471

/*!
* \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
472
* \param out_len length of prediction
Guolin Ke's avatar
Guolin Ke committed
473
474
* \return 0 when succeed, -1 when failure happens
*/
475
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCalcNumPredict_R(
476
  LGBM_SE handle,
Guolin Ke's avatar
Guolin Ke committed
477
478
479
  LGBM_SE num_row,
  LGBM_SE is_rawscore,
  LGBM_SE is_leafidx,
480
  LGBM_SE is_predcontrib,
481
  LGBM_SE start_iteration,
Guolin Ke's avatar
Guolin Ke committed
482
  LGBM_SE num_iteration,
483
  LGBM_SE out_len
484
);
Guolin Ke's avatar
Guolin Ke committed
485
486

/*!
487
* \brief make prediction for a new data set
Guolin Ke's avatar
Guolin Ke committed
488
*        Note:  should pre-allocate memory for out_result,
489
*               for normal and raw score: its length is equal to num_class * num_data
Guolin Ke's avatar
Guolin Ke committed
490
491
492
493
494
495
*               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
496
* \param nelem number of non-zero elements in the matrix
Guolin Ke's avatar
Guolin Ke committed
497
498
499
500
501
502
503
* \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
*/
504
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForCSC_R(
505
  LGBM_SE handle,
Guolin Ke's avatar
Guolin Ke committed
506
507
508
509
510
511
512
513
  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,
514
  LGBM_SE is_predcontrib,
515
  LGBM_SE start_iteration,
Guolin Ke's avatar
Guolin Ke committed
516
  LGBM_SE num_iteration,
517
  LGBM_SE parameter,
518
  LGBM_SE out_result
519
);
Guolin Ke's avatar
Guolin Ke committed
520
521

/*!
522
* \brief make prediction for a new data set
Guolin Ke's avatar
Guolin Ke committed
523
*        Note:  should pre-allocate memory for out_result,
524
*               for normal and raw score: its length is equal to num_class * num_data
Guolin Ke's avatar
Guolin Ke committed
525
526
527
528
529
530
531
532
533
534
535
*               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
*/
536
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForMat_R(
537
  LGBM_SE handle,
Guolin Ke's avatar
Guolin Ke committed
538
539
540
541
542
  LGBM_SE data,
  LGBM_SE nrow,
  LGBM_SE ncol,
  LGBM_SE is_rawscore,
  LGBM_SE is_leafidx,
543
  LGBM_SE is_predcontrib,
544
  LGBM_SE start_iteration,
Guolin Ke's avatar
Guolin Ke committed
545
  LGBM_SE num_iteration,
546
  LGBM_SE parameter,
547
  LGBM_SE out_result
548
);
Guolin Ke's avatar
Guolin Ke committed
549
550
551
552
553
554
555
556

/*!
* \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
*/
557
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterSaveModel_R(
558
  LGBM_SE handle,
Guolin Ke's avatar
Guolin Ke committed
559
  LGBM_SE num_iteration,
560
  LGBM_SE feature_importance_type,
561
  LGBM_SE filename
562
);
Guolin Ke's avatar
Guolin Ke committed
563

564
565
566
567
568
569
570
/*!
* \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
*/
571
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterSaveModelToString_R(
572
  LGBM_SE handle,
573
  LGBM_SE num_iteration,
574
  LGBM_SE feature_importance_type,
575
576
  LGBM_SE buffer_len,
  LGBM_SE actual_len,
577
  LGBM_SE out_str
578
);
579

Guolin Ke's avatar
Guolin Ke committed
580
581
582
583
584
585
586
/*!
* \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
*/
587
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterDumpModel_R(
588
  LGBM_SE handle,
Guolin Ke's avatar
Guolin Ke committed
589
  LGBM_SE num_iteration,
590
  LGBM_SE feature_importance_type,
Guolin Ke's avatar
Guolin Ke committed
591
592
  LGBM_SE buffer_len,
  LGBM_SE actual_len,
593
  LGBM_SE out_str
594
);
Guolin Ke's avatar
Guolin Ke committed
595

596
#endif  // LIGHTGBM_R_H_