Skip to content

Commit

Permalink
FIX (FTI) model converter for lightGBM models (#2220)
Browse files Browse the repository at this point in the history
* fix fti converter for lgb models

* Update src/gbt_convertors.pyx

Co-authored-by: Andreas Huber <[email protected]>

* Update gbt_convertors.pyx

---------

Co-authored-by: Dmitry Razdoburdin <>
Co-authored-by: Andreas Huber <[email protected]>
  • Loading branch information
razdoburdin and ahuber21 authored Dec 12, 2024
1 parent 7743060 commit ab143a2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/gbt_convertors.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,15 @@ class Node:
right_child = None

is_leaf = "leaf_value" in tree
# get cover and value for leaf nodes or internal nodes
cover = tree.get("leaf_count", 0) or tree.get("internal_count", 0)
value = tree.get("leaf_value", 0) or tree.get("threshold", 0)
return Node(
cover=tree["leaf_count"] if is_leaf else tree["internal_count"],
cover=cover,
is_leaf=is_leaf,
default_left=tree.get("default_left", 0),
feature=tree.get("split_feature"),
value=tree["leaf_value"] if is_leaf else tree["threshold"],
value=value,
n_children=n_children,
left_child=left_child,
right_child=right_child,
Expand Down

0 comments on commit ab143a2

Please sign in to comment.