Skip to content

Commit

Permalink
adding check for n_features in skl gb (#952)
Browse files Browse the repository at this point in the history
Signed-off-by: Karla Saur <kasaur@microsoft.com>

Signed-off-by: Karla Saur <kasaur@microsoft.com>
  • Loading branch information
ksaur authored Dec 9, 2022
1 parent 3c9e0c1 commit 81fd481
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion skl2onnx/operator_converters/gradient_boosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ def convert_sklearn_gradient_boosting_classifier(
if op.init == 'zero':
base_values = np.zeros(op.loss_.K)
elif op.init is None:
x0 = np.zeros((1, op.estimators_[0, 0].n_features_))
if hasattr(op.estimators_[0, 0], 'n_features_in_'):
# sklearn >= 1.2
x0 = np.zeros((1, op.estimators_[0, 0].n_features_in_))
else:
# sklearn < 1.2
x0 = np.zeros((1, op.estimators_[0, 0].n_features_))
if hasattr(op, '_raw_predict_init'):
# sklearn >= 0.21
base_values = op._raw_predict_init(x0).ravel()
Expand Down

0 comments on commit 81fd481

Please sign in to comment.