lightgbm_R.h 15.7 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>

14
15
16
17
18
19
20
21
22
/*!
* \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
23
24
25
// --- start Dataset interface

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

/*!
39
* \brief create a Dataset from Compressed Sparse Column (CSC) format
Guolin Ke's avatar
Guolin Ke committed
40
41
42
* \param indptr pointer to row headers
* \param indices findex
* \param data fvalue
43
* \param num_indptr number of cols in the matrix + 1
Guolin Ke's avatar
Guolin Ke committed
44
45
46
* \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
48
* \return Dataset handle
Guolin Ke's avatar
Guolin Ke committed
49
*/
50
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetCreateFromCSC_R(
51
52
53
  SEXP indptr,
  SEXP indices,
  SEXP data,
54
55
56
  SEXP num_indptr,
  SEXP nelem,
  SEXP num_row,
57
  SEXP parameters,
58
  SEXP reference
59
);
Guolin Ke's avatar
Guolin Ke committed
60
61

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

/*!
79
80
* \brief Create subset of a Dataset
* \param handle handle of full Dataset
Guolin Ke's avatar
Guolin Ke committed
81
82
83
* \param used_row_indices Indices used in subset
* \param len_used_row_indices length of Indices used in subset
* \param parameters additional parameters
84
* \return Dataset handle
Guolin Ke's avatar
Guolin Ke committed
85
*/
86
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetSubset_R(
87
  SEXP handle,
88
  SEXP used_row_indices,
89
  SEXP len_used_row_indices,
90
  SEXP parameters
91
);
Guolin Ke's avatar
Guolin Ke committed
92
93
94
95
96

/*!
* \brief save feature names to Dataset
* \param handle handle
* \param feature_names feature names
97
* \return R character vector of feature names
Guolin Ke's avatar
Guolin Ke committed
98
*/
99
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSetFeatureNames_R(
100
  SEXP handle,
101
  SEXP feature_names
102
);
Guolin Ke's avatar
Guolin Ke committed
103
104

/*!
105
106
107
* \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
108
*/
109
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFeatureNames_R(
110
  SEXP handle
111
);
Guolin Ke's avatar
Guolin Ke committed
112
113

/*!
114
115
* \brief save Dataset to binary file
* \param handle an instance of Dataset
Guolin Ke's avatar
Guolin Ke committed
116
* \param filename file name
117
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
118
*/
119
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetSaveBinary_R(
120
  SEXP handle,
121
  SEXP filename
122
);
Guolin Ke's avatar
Guolin Ke committed
123
124

/*!
125
126
127
* \brief free Dataset
* \param handle an instance of Dataset
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
128
*/
129
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetFree_R(
130
  SEXP handle
131
);
Guolin Ke's avatar
Guolin Ke committed
132
133
134

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

/*!
151
152
* \brief get size of info vector from Dataset
* \param handle an instance of Dataset
Guolin Ke's avatar
Guolin Ke committed
153
* \param field_name field name
154
155
* \param out size of info vector from Dataset
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
156
*/
157
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetFieldSize_R(
158
  SEXP handle,
159
  SEXP field_name,
160
  SEXP out
161
);
Guolin Ke's avatar
Guolin Ke committed
162
163

/*!
164
165
* \brief get info vector from Dataset
* \param handle an instance of Dataset
Guolin Ke's avatar
Guolin Ke committed
166
167
* \param field_name field name
* \param field_data pointer to vector
168
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
169
*/
170
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetField_R(
171
  SEXP handle,
172
  SEXP field_name,
173
  SEXP field_data
174
);
Guolin Ke's avatar
Guolin Ke committed
175

176
/*!
177
178
179
180
181
 * \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
182
 */
183
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetUpdateParamChecking_R(
184
185
  SEXP old_params,
  SEXP new_params
186
);
187

Guolin Ke's avatar
Guolin Ke committed
188
189
/*!
* \brief get number of data.
190
* \param handle the handle to the Dataset
Guolin Ke's avatar
Guolin Ke committed
191
* \param out The address to hold number of data
192
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
193
*/
194
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumData_R(
195
  SEXP handle,
196
  SEXP out
197
);
Guolin Ke's avatar
Guolin Ke committed
198
199
200

/*!
* \brief get number of features
201
* \param handle the handle to the Dataset
Guolin Ke's avatar
Guolin Ke committed
202
* \param out The output of number of features
203
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
204
*/
205
LIGHTGBM_C_EXPORT SEXP LGBM_DatasetGetNumFeature_R(
206
  SEXP handle,
207
  SEXP out
208
);
Guolin Ke's avatar
Guolin Ke committed
209
210
211
212

// --- start Booster interfaces

/*!
213
* \brief create a new boosting learner
214
* \param train_data training Dataset
Guolin Ke's avatar
Guolin Ke committed
215
* \param parameters format: 'key1=value1 key2=value2'
216
* \return Booster handle
Guolin Ke's avatar
Guolin Ke committed
217
*/
218
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreate_R(
219
220
  SEXP train_data,
  SEXP parameters
221
);
Guolin Ke's avatar
Guolin Ke committed
222
223

/*!
224
* \brief free Booster
Guolin Ke's avatar
Guolin Ke committed
225
* \param handle handle to be freed
226
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
227
*/
228
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterFree_R(
229
  SEXP handle
230
);
Guolin Ke's avatar
Guolin Ke committed
231
232

/*!
233
* \brief load an existing Booster from model file
Guolin Ke's avatar
Guolin Ke committed
234
* \param filename filename of model
235
* \return Booster handle
Guolin Ke's avatar
Guolin Ke committed
236
*/
237
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterCreateFromModelfile_R(
238
  SEXP filename
239
);
Guolin Ke's avatar
Guolin Ke committed
240

241
/*!
242
* \brief load an existing Booster from a string
243
* \param model_str string containing the model
244
* \return Booster handle
245
*/
246
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterLoadModelFromString_R(
247
  SEXP model_str
248
);
249

Guolin Ke's avatar
Guolin Ke committed
250
/*!
251
252
253
254
* \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
255
*/
256
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterMerge_R(
257
258
  SEXP handle,
  SEXP other_handle
259
);
Guolin Ke's avatar
Guolin Ke committed
260
261

/*!
262
263
264
265
* \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
266
*/
267
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterAddValidData_R(
268
269
  SEXP handle,
  SEXP valid_data
270
);
Guolin Ke's avatar
Guolin Ke committed
271
272

/*!
273
274
275
276
* \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
277
*/
278
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetTrainingData_R(
279
280
  SEXP handle,
  SEXP train_data
281
);
Guolin Ke's avatar
Guolin Ke committed
282
283

/*!
284
285
* \brief Reset config for current Booster
* \param handle Booster handle
Guolin Ke's avatar
Guolin Ke committed
286
* \param parameters format: 'key1=value1 key2=value2'
287
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
288
*/
289
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterResetParameter_R(
290
  SEXP handle,
291
  SEXP parameters
292
);
Guolin Ke's avatar
Guolin Ke committed
293
294

/*!
295
* \brief Get number of classes
296
* \param handle Booster handle
Guolin Ke's avatar
Guolin Ke committed
297
* \param out number of classes
298
* \return R NULL value
Guolin Ke's avatar
Guolin Ke committed
299
*/
300
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumClasses_R(
301
  SEXP handle,
302
  SEXP out
303
);
Guolin Ke's avatar
Guolin Ke committed
304

305
306
307
308
309
310
311
312
313
/*!
* \brief Get number of features.
* \param handle Booster handle
* \return Total number of features, as R integer
*/
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetNumFeature_R(
  SEXP handle
);

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

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

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

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

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

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

Guolin Ke's avatar
Guolin Ke committed
381
/*!
382
383
384
* \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
385
*/
386
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterGetEvalNames_R(
387
  SEXP handle
388
);
Guolin Ke's avatar
Guolin Ke committed
389
390
391

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

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

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

/*!
* \brief make prediction for file
432
* \param handle Booster handle
Guolin Ke's avatar
Guolin Ke committed
433
434
* \param data_filename filename of data file
* \param data_has_header data file has header or not
435
436
437
438
439
440
* \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
441
* \param num_iteration number of iteration for prediction, <= 0 means no limit
442
443
444
* \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
445
*/
446
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterPredictForFile_R(
447
  SEXP handle,
448
  SEXP data_filename,
449
450
451
452
453
454
  SEXP data_has_header,
  SEXP is_rawscore,
  SEXP is_leafidx,
  SEXP is_predcontrib,
  SEXP start_iteration,
  SEXP num_iteration,
455
456
  SEXP parameter,
  SEXP result_filename
457
);
Guolin Ke's avatar
Guolin Ke committed
458
459
460

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

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

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

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

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

Guolin Ke's avatar
Guolin Ke committed
586
/*!
587
588
* \brief dump model to JSON
* \param handle Booster handle
Guolin Ke's avatar
Guolin Ke committed
589
* \param num_iteration, <= 0 means save all
590
591
* \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
592
*/
593
LIGHTGBM_C_EXPORT SEXP LGBM_BoosterDumpModel_R(
594
  SEXP handle,
595
  SEXP num_iteration,
596
  SEXP feature_importance_type
597
);
Guolin Ke's avatar
Guolin Ke committed
598

599
#endif  // LIGHTGBM_R_H_