Skip to content

Commit d4cd845

Browse files
fix for pandas input with set feature names (#917) (#921)
(cherry picked from commit c75a0fc) Co-authored-by: KalyanovD <[email protected]>
1 parent a94b1dd commit d4cd845

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/gbt_convertors.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,10 @@ def get_gbt_model_from_xgboost(booster: Any) -> Any:
122122
self.position = position
123123

124124
# Release Note for XGBoost 1.5.0: Python interface now supports configuring
125-
# constraints using feature names instead of feature indices.
126-
if booster.feature_names is None:
127-
lst = [*range(booster.num_features())]
128-
booster.feature_names = [str(i) for i in lst]
125+
# constraints using feature names instead of feature indices. This also
126+
# helps with pandas input with set feature names.
127+
lst = [*range(booster.num_features())]
128+
booster.feature_names = [str(i) for i in lst]
129129

130130
trees_arr = booster.get_dump(dump_format="json")
131131
xgb_config = json.loads(booster.save_config())

0 commit comments

Comments
 (0)