Skip to content

Commit

Permalink
Added constants for feature importance [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Dec 16, 2024
1 parent f1d3ade commit 1596a9e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/lightgbm/booster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ def feature_importance(iteration: nil, importance_type: "split")
importance_type =
case importance_type
when "split"
0
FFI::C_API_FEATURE_IMPORTANCE_SPLIT
when "gain"
1
FFI::C_API_FEATURE_IMPORTANCE_GAIN
else
-1
end
Expand Down
3 changes: 3 additions & 0 deletions lib/lightgbm/ffi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ module FFI
C_API_PREDICT_LEAF_INDEX = 2
C_API_PREDICT_CONTRIB = 3

C_API_FEATURE_IMPORTANCE_SPLIT = 0
C_API_FEATURE_IMPORTANCE_GAIN = 1

# error
attach_function :LGBM_GetLastError, %i[], :string

Expand Down

0 comments on commit 1596a9e

Please sign in to comment.