Skip to content

Commit 1596a9e

Browse files
committed
Added constants for feature importance [skip ci]
1 parent f1d3ade commit 1596a9e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/lightgbm/booster.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ def feature_importance(iteration: nil, importance_type: "split")
6565
importance_type =
6666
case importance_type
6767
when "split"
68-
0
68+
FFI::C_API_FEATURE_IMPORTANCE_SPLIT
6969
when "gain"
70-
1
70+
FFI::C_API_FEATURE_IMPORTANCE_GAIN
7171
else
7272
-1
7373
end

lib/lightgbm/ffi.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ module FFI
2020
C_API_PREDICT_LEAF_INDEX = 2
2121
C_API_PREDICT_CONTRIB = 3
2222

23+
C_API_FEATURE_IMPORTANCE_SPLIT = 0
24+
C_API_FEATURE_IMPORTANCE_GAIN = 1
25+
2326
# error
2427
attach_function :LGBM_GetLastError, %i[], :string
2528

0 commit comments

Comments
 (0)