lightgbm_R.h 15.6 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
10
11
12
13

#define R_NO_REMAP
#define R_USE_C99_IN_CXX
#include <Rinternals.h>

Guolin Ke's avatar
Guolin Ke committed
14
15
/*!
* \brief get string message of the last error
16
* \return err_msg string with error information
Guolin Ke's avatar
Guolin Ke committed
17
*/
18
LIGHTGBM_C_EXPORT SEXP LGBM_GetLastError_R();
Guolin Ke's avatar
Guolin Ke committed
19

20
21
22
23
24
25
26
27
28
/*!
* \brief check if an R external pointer (like a Booster or Dataset handle) is a null pointer
* \param handle handle for a Booster, Dataset, or Predictor
* \return R logical, TRUE if the handle is a null pointer
*/
LIGHTGBM_C_EXPORT SEXP LGBM_HandleIsNull_R(
  SEXP handle
);

Guolin Ke's avatar
Guolin Ke committed
29
30
31
// --- start Dataset interface

/*!
32
* \brief load Dataset from file like the command_line LightGBM does
Guolin Ke's avatar
Guolin Ke committed
33
34
* \param filename the name of the file
* \param parameters additional parameters
35
* \param reference used to align bin mapper with other Dataset, nullptr means not used
36
* \return Dataset handle
Guolin Ke's avatar
Guolin Ke committed
37
*/
38
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromFile_R(
39
40
  SEXP filename,
  SEXP parameters,
41
  SEXP reference
42
);
Guolin Ke's avatar
Guolin Ke committed
43
44

/*!
45
* \brief create a Dataset from Compressed Sparse Column (CSC) format
Guolin Ke's avatar
Guolin Ke committed
46
47
48
* \param indptr pointer to row headers
* \param indices findex
* \param data fvalue
49
* \param num_indptr number of cols in the matrix + 1
Guolin Ke's avatar
Guolin Ke committed
50
51
52
* \param nelem number of nonzero elements in the matrix
* \param num_row number of rows
* \param parameters additional parameters
53
* \param reference used to align bin mapper with other Dataset, nullptr means not used
54
* \return Dataset handle
Guolin Ke's avatar
Guolin Ke committed
55
*/
56
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromCSC_R(
57
58
59
  SEXP indptr,
  SEXP indices,
  SEXP data,
60
61
62
  SEXP num_indptr,
  SEXP nelem,
  SEXP num_row,
63
  SEXP parameters,
64
  SEXP reference
65
);
Guolin Ke's avatar
Guolin Ke committed
66
67

/*!
68
69
* \brief create Dataset from dense matrix
* \param data matrix data
70
71
* \param num_row number of rows
* \param num_col number columns
Guolin Ke's avatar
Guolin Ke committed
72
* \param parameters additional parameters
73
* \param reference used to align bin mapper with other Dataset, nullptr means not used
74
* \return Dataset handle
Guolin Ke's avatar
Guolin Ke committed
75
*/
76
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromMat_R(
77
  SEXP data,
78
79
  SEXP num_row,
  SEXP num_col,
80
  SEXP parameters,
81
  SEXP reference
82
);
Guolin Ke's avatar
Guolin Ke committed
83
84

/*!
85
86
* \brief Create subset of a Dataset
* \param handle handle of full Dataset
Guolin Ke's avatar
Guolin Ke committed
87
88
89
* \param used_row_indices Indices used in subset
* \param len_used_row_indices length of Indices used in subset
* \param parameters additional parameters
90
* \return Dataset handle
Guolin Ke's avatar
Guolin Ke committed
91
*/
92
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetSubset_R(
93
  SEXP handle,
94
  SEXP used_row_indices,
95
  SEXP len_used_row_indices,
96
  SEXP parameters
97
);
Guolin Ke's avatar
Guolin Ke committed
98
99
100
101
102

/*!
* \brief save feature names to Dataset
* \param handle handle
* \param feature_names feature names
103
* \return R character vector of feature names
Guolin Ke's avatar
Guolin Ke committed
104
*/
105
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetFeatureNames_R(
106
  SEXP handle,
107
  SEXP feature_names
108
);
Guolin Ke's avatar
Guolin Ke committed
109
110

/*!
111
112
113
* \brief get feature names from Dataset
* \param handle Dataset handle
* \return an R character vector with feature names from the Dataset or NULL if no feature names
Guolin Ke's avatar
Guolin Ke committed
114
*/
115
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFeatureNames_R(
116
  SEXP handle
117
);
Guolin Ke's avatar
Guolin Ke committed
118
119

/*!
120
121
* \brief save Dataset to binary file
* \param handle an instance of Dataset
Guolin Ke's avatar
Guolin Ke committed
122
* \param filename file name
123
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
124
*/
125
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSaveBinary_R(
126
  SEXP handle,
127
  SEXP filename
128
);
Guolin Ke's avatar
Guolin Ke committed
129
130

/*!
131
132
133
* \brief free Dataset
* \param handle an instance of Dataset
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
134
*/
135
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetFree_R(
136
  SEXP handle
137
);
Guolin Ke's avatar
Guolin Ke committed
138
139
140

/*!
* \brief set vector to a content in info
141
*        Note: group and group_id only work for C_API_DTYPE_INT32
Guolin Ke's avatar
Guolin Ke committed
142
*              label and weight only work for C_API_DTYPE_FLOAT32
143
* \param handle an instance of Dataset
Guolin Ke's avatar
Guolin Ke committed
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
147
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
148
*/
149
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetField_R(
150
  SEXP handle,
151
  SEXP field_name,
152
  SEXP field_data,
153
  SEXP num_element
154
);
Guolin Ke's avatar
Guolin Ke committed
155
156

/*!
157
158
* \brief get size of info vector from Dataset
* \param handle an instance of Dataset
Guolin Ke's avatar
Guolin Ke committed
159
* \param field_name field name
160
161
* \param out size of info vector from Dataset
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
162
*/
163
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFieldSize_R(
164
  SEXP handle,
165
  SEXP field_name,
166
  SEXP out
167
);
Guolin Ke's avatar
Guolin Ke committed
168
169

/*!
170
171
* \brief get info vector from Dataset
* \param handle an instance of Dataset
Guolin Ke's avatar
Guolin Ke committed
172
173
* \param field_name field name
* \param field_data pointer to vector
174
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
175
*/
176
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetField_R(
177
  SEXP handle,
178
  SEXP field_name,
179
  SEXP field_data
180
);
Guolin Ke's avatar
Guolin Ke committed
181

182
/*!
183
184
185
186
187
 * \brief Raise errors for attempts to update Dataset parameters.
 *        Some parameters cannot be updated after construction.
 * \param old_params Current Dataset parameters
 * \param new_params New Dataset parameters
 * \return R NULL value
188
 */
189
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetUpdateParamChecking_R(
190
191
  SEXP old_params,
  SEXP new_params
192
);
193

Guolin Ke's avatar
Guolin Ke committed
194
195
/*!
* \brief get number of data.
196
* \param handle the handle to the Dataset
Guolin Ke's avatar
Guolin Ke committed
197
* \param out The address to hold number of data
198
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
199
*/
200
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumData_R(
201
  SEXP handle,
202
  SEXP out
203
);
Guolin Ke's avatar
Guolin Ke committed
204
205
206

/*!
* \brief get number of features
207
* \param handle the handle to the Dataset
Guolin Ke's avatar
Guolin Ke committed
208
* \param out The output of number of features
209
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
210
*/
211
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumFeature_R(
212
  SEXP handle,
213
  SEXP out
214
);
Guolin Ke's avatar
Guolin Ke committed
215
216
217
218

// --- start Booster interfaces

/*!
219
* \brief create a new boosting learner
220
* \param train_data training Dataset
Guolin Ke's avatar
Guolin Ke committed
221
* \param parameters format: 'key1=value1 key2=value2'
222
* \return Booster handle
Guolin Ke's avatar
Guolin Ke committed
223
*/
224
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreate_R(
225
226
  SEXP train_data,
  SEXP parameters
227
);
Guolin Ke's avatar
Guolin Ke committed
228
229

/*!
230
* \brief free Booster
Guolin Ke's avatar
Guolin Ke committed
231
* \param handle handle to be freed
232
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
233
*/
234
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterFree_R(
235
  SEXP handle
236
);
Guolin Ke's avatar
Guolin Ke committed
237
238

/*!
239
* \brief load an existing Booster from model file
Guolin Ke's avatar
Guolin Ke committed
240
* \param filename filename of model
241
* \return Booster handle
Guolin Ke's avatar
Guolin Ke committed
242
*/
243
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreateFromModelfile_R(
244
  SEXP filename
245
);
Guolin Ke's avatar
Guolin Ke committed
246

247
/*!
248
* \brief load an existing Booster from a string
249
* \param model_str string containing the model
250
* \return Booster handle
251
*/
252
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterLoadModelFromString_R(
253
  SEXP model_str
254
);
255

Guolin Ke's avatar
Guolin Ke committed
256
/*!
257
258
259
260
* \brief Merge model in two Boosters to first handle
* \param handle handle primary Booster handle, will merge other handle to this
* \param other_handle secondary Booster handle
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
261
*/
262
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterMerge_R(
263
264
  SEXP handle,
  SEXP other_handle
265
);
Guolin Ke's avatar
Guolin Ke committed
266
267

/*!
268
269
270
271
* \brief Add new validation to Booster
* \param handle Booster handle
* \param valid_data validation Dataset
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
272
*/
273
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterAddValidData_R(
274
275
  SEXP handle,
  SEXP valid_data
276
);
Guolin Ke's avatar
Guolin Ke committed
277
278

/*!
279
280
281
282
* \brief Reset training data for Booster
* \param handle Booster handle
* \param train_data training Dataset
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
283
*/
284
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetTrainingData_R(
285
286
  SEXP handle,
  SEXP train_data
287
);
Guolin Ke's avatar
Guolin Ke committed
288
289

/*!
290
291
* \brief Reset config for current Booster
* \param handle Booster handle
Guolin Ke's avatar
Guolin Ke committed
292
* \param parameters format: 'key1=value1 key2=value2'
293
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
294
*/
295
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetParameter_R(
296
  SEXP handle,
297
  SEXP parameters
298
);
Guolin Ke's avatar
Guolin Ke committed
299
300

/*!
301
* \brief Get number of classes
302
* \param handle Booster handle
Guolin Ke's avatar
Guolin Ke committed
303
* \param out number of classes
304
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
305
*/
306
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumClasses_R(
307
  SEXP handle,
308
  SEXP out
309
);
Guolin Ke's avatar
Guolin Ke committed
310
311
312

/*!
* \brief update the model in one round
313
314
* \param handle Booster handle
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
315
*/
316
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterUpdateOneIter_R(
317
  SEXP handle
318
);
Guolin Ke's avatar
Guolin Ke committed
319
320

/*!
321
* \brief update the model, by directly specifying gradient and second order gradient,
Guolin Ke's avatar
Guolin Ke committed
322
*       this can be used to support customized loss function
323
* \param handle Booster handle
Guolin Ke's avatar
Guolin Ke committed
324
325
326
* \param grad gradient statistics
* \param hess second order gradient statistics
* \param len length of grad/hess
327
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
328
*/
329
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterUpdateOneIterCustom_R(
330
  SEXP handle,
331
332
  SEXP grad,
  SEXP hess,
333
  SEXP len
334
);
Guolin Ke's avatar
Guolin Ke committed
335
336
337

/*!
* \brief Rollback one iteration
338
339
* \param handle Booster handle
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
340
*/
341
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterRollbackOneIter_R(
342
  SEXP handle
343
);
Guolin Ke's avatar
Guolin Ke committed
344
345
346

/*!
* \brief Get iteration of current boosting rounds
347
* \param handle Booster handle
Guolin Ke's avatar
Guolin Ke committed
348
* \param out iteration of boosting rounds
349
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
350
*/
351
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetCurrentIteration_R(
352
  SEXP handle,
353
  SEXP out
354
);
Guolin Ke's avatar
Guolin Ke committed
355

356
357
/*!
* \brief Get model upper bound value.
358
* \param handle Handle of Booster
359
* \param[out] out_results Result pointing to max value
360
* \return R NULL value
361
*/
362
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetUpperBoundValue_R(
363
    SEXP handle,
364
    SEXP out_result
365
366
367
368
);

/*!
* \brief Get model lower bound value.
369
* \param handle Handle of Booster
370
* \param[out] out_results Result pointing to min value
371
* \return R NULL value
372
*/
373
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetLowerBoundValue_R(
374
    SEXP handle,
375
    SEXP out_result
376
377
);

Guolin Ke's avatar
Guolin Ke committed
378
/*!
379
380
381
* \brief Get names of eval metrics
* \param handle Handle of booster
* \return R character vector with names of eval metrics
Guolin Ke's avatar
Guolin Ke committed
382
*/
383
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEvalNames_R(
384
  SEXP handle
385
);
Guolin Ke's avatar
Guolin Ke committed
386
387
388

/*!
* \brief get evaluation for training data and validation data
389
* \param handle Booster handle
Guolin Ke's avatar
Guolin Ke committed
390
* \param data_idx 0:training data, 1: 1st valid data, 2:2nd valid data ...
391
392
* \param out_result float array containing result
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
393
*/
394
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEval_R(
395
  SEXP handle,
396
  SEXP data_idx,
397
  SEXP out_result
398
);
Guolin Ke's avatar
Guolin Ke committed
399
400
401

/*!
* \brief Get number of prediction for training data and validation data
402
* \param handle Booster handle
Guolin Ke's avatar
Guolin Ke committed
403
404
* \param data_idx 0:training data, 1: 1st valid data, 2:2nd valid data ...
* \param out size of predict
405
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
406
*/
407
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumPredict_R(
408
  SEXP handle,
409
  SEXP data_idx,
410
  SEXP out
411
);
Guolin Ke's avatar
Guolin Ke committed
412
413

/*!
414
415
* \brief Get prediction for training data and validation data.
*        This can be used to support customized eval function
416
* \param handle Booster handle
Guolin Ke's avatar
Guolin Ke committed
417
418
* \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
419
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
420
*/
421
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetPredict_R(
422
  SEXP handle,
423
  SEXP data_idx,
424
  SEXP out_result
425
);
Guolin Ke's avatar
Guolin Ke committed
426
427
428

/*!
* \brief make prediction for file
429
* \param handle Booster handle
Guolin Ke's avatar
Guolin Ke committed
430
431
* \param data_filename filename of data file
* \param data_has_header data file has header or not
432
433
434
435
436
437
* \param is_rawscore 1 to get raw predictions, before transformations like
*                    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
Guolin Ke's avatar
Guolin Ke committed
438
* \param num_iteration number of iteration for prediction, <= 0 means no limit
439
440
441
* \param parameter additional parameters
* \param result_filename filename of file to write predictions to
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
442
*/
443
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForFile_R(
444
  SEXP handle,
445
  SEXP data_filename,
446
447
448
449
450
451
  SEXP data_has_header,
  SEXP is_rawscore,
  SEXP is_leafidx,
  SEXP is_predcontrib,
  SEXP start_iteration,
  SEXP num_iteration,
452
453
  SEXP parameter,
  SEXP result_filename
454
);
Guolin Ke's avatar
Guolin Ke committed
455
456
457

/*!
* \brief Get number of prediction
458
459
460
461
462
463
464
465
* \param handle Booster handle
* \param num_row number of rows in input
* \param is_rawscore 1 to get raw predictions, before transformations like
*                    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
Guolin Ke's avatar
Guolin Ke committed
466
* \param num_iteration number of iteration for prediction, <= 0 means no limit
467
* \param out_len length of prediction
468
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
469
*/
470
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCalcNumPredict_R(
471
  SEXP handle,
472
473
474
475
476
477
  SEXP num_row,
  SEXP is_rawscore,
  SEXP is_leafidx,
  SEXP is_predcontrib,
  SEXP start_iteration,
  SEXP num_iteration,
478
  SEXP out_len
479
);
Guolin Ke's avatar
Guolin Ke committed
480
481

/*!
482
* \brief make prediction for a new Dataset
Guolin Ke's avatar
Guolin Ke committed
483
*        Note:  should pre-allocate memory for out_result,
484
*               for normal and raw score: its length is equal to num_class * num_data
Guolin Ke's avatar
Guolin Ke committed
485
*               for leaf index, its length is equal to num_class * num_data * num_iteration
486
* \param handle Booster handle
Guolin Ke's avatar
Guolin Ke committed
487
488
489
* \param indptr pointer to row headers
* \param indices findex
* \param data fvalue
490
* \param num_indptr number of cols in the matrix + 1
491
* \param nelem number of non-zero elements in the matrix
Guolin Ke's avatar
Guolin Ke committed
492
* \param num_row number of rows
493
494
495
496
497
498
* \param is_rawscore 1 to get raw predictions, before transformations like
*                    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
Guolin Ke's avatar
Guolin Ke committed
499
* \param num_iteration number of iteration for prediction, <= 0 means no limit
500
501
502
* \param parameter additional parameters
* \param out_result prediction result
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
503
*/
504
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForCSC_R(
505
  SEXP handle,
506
507
508
  SEXP indptr,
  SEXP indices,
  SEXP data,
509
510
511
512
513
514
515
516
  SEXP num_indptr,
  SEXP nelem,
  SEXP num_row,
  SEXP is_rawscore,
  SEXP is_leafidx,
  SEXP is_predcontrib,
  SEXP start_iteration,
  SEXP num_iteration,
517
  SEXP parameter,
518
  SEXP out_result
519
);
Guolin Ke's avatar
Guolin Ke committed
520
521

/*!
522
* \brief make prediction for a new Dataset
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
*               for leaf index, its length is equal to num_class * num_data * num_iteration
526
* \param handle Booster handle
Guolin Ke's avatar
Guolin Ke committed
527
* \param data pointer to the data space
528
529
* \param num_row number of rows
* \param num_col number columns
530
531
532
533
534
535
* \param is_rawscore 1 to get raw predictions, before transformations like
*                    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
Guolin Ke's avatar
Guolin Ke committed
536
* \param num_iteration number of iteration for prediction, <= 0 means no limit
537
538
539
* \param parameter additional parameters
* \param out_result prediction result
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
540
*/
541
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForMat_R(
542
  SEXP handle,
543
  SEXP data,
544
545
546
547
548
549
550
  SEXP num_row,
  SEXP num_col,
  SEXP is_rawscore,
  SEXP is_leafidx,
  SEXP is_predcontrib,
  SEXP start_iteration,
  SEXP num_iteration,
551
  SEXP parameter,
552
  SEXP out_result
553
);
Guolin Ke's avatar
Guolin Ke committed
554
555
556

/*!
* \brief save model into file
557
* \param handle Booster handle
Guolin Ke's avatar
Guolin Ke committed
558
* \param num_iteration, <= 0 means save all
559
* \param feature_importance_type type of feature importance, 0: split, 1: gain
Guolin Ke's avatar
Guolin Ke committed
560
* \param filename file name
561
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
562
*/
563
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterSaveModel_R(
564
  SEXP handle,
565
566
  SEXP num_iteration,
  SEXP feature_importance_type,
567
  SEXP filename
568
);
Guolin Ke's avatar
Guolin Ke committed
569

570
571
/*!
* \brief create string containing model
572
* \param handle Booster handle
573
* \param num_iteration, <= 0 means save all
574
575
* \param feature_importance_type type of feature importance, 0: split, 1: gain
* \return R character vector (length=1) with model string
576
*/
577
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterSaveModelToString_R(
578
  SEXP handle,
579
  SEXP num_iteration,
580
  SEXP feature_importance_type
581
);
582

Guolin Ke's avatar
Guolin Ke committed
583
/*!
584
585
* \brief dump model to JSON
* \param handle Booster handle
Guolin Ke's avatar
Guolin Ke committed
586
* \param num_iteration, <= 0 means save all
587
588
* \param feature_importance_type type of feature importance, 0: split, 1: gain
* \return R character vector (length=1) with model JSON
Guolin Ke's avatar
Guolin Ke committed
589
*/
590
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterDumpModel_R(
591
  SEXP handle,
592
  SEXP num_iteration,
593
  SEXP feature_importance_type
594
);
Guolin Ke's avatar
Guolin Ke committed
595

596
#endif  // LIGHTGBM_R_H_