Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding check for n_features in skl gb #952

Merged
merged 1 commit into from
Dec 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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