-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
[MRG] Fix GBDT init parameter when it's a pipeline #13472
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
Changes from all commits
8486ccb
e4e6de7
050366f
3801a1e
2cb1bb0
b7f7f9a
d1ffe54
f1124f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1476,20 +1476,25 @@ def fit(self, X, y, sample_weight=None, monitor=None): | |
raw_predictions = np.zeros(shape=(X.shape[0], self.loss_.K), | ||
dtype=np.float64) | ||
else: | ||
try: | ||
self.init_.fit(X, y, sample_weight=sample_weight) | ||
except TypeError: | ||
if sample_weight_is_none: | ||
self.init_.fit(X, y) | ||
else: | ||
raise ValueError( | ||
"The initial estimator {} does not support sample " | ||
"weights.".format(self.init_.__class__.__name__)) | ||
# XXX clean this once we have a support_sample_weight tag | ||
if sample_weight_is_none: | ||
self.init_.fit(X, y) | ||
else: | ||
msg = ("The initial estimator {} does not support sample " | ||
"weights.".format(self.init_.__class__.__name__)) | ||
try: | ||
self.init_.fit(X, y, sample_weight=sample_weight) | ||
except TypeError: # regular estimator without SW support | ||
raise ValueError(msg) | ||
except ValueError as e: | ||
if 'not enough values to unpack' in str(e): # pipeline | ||
raise ValueError(msg) from e | ||
else: # regular estimator whose input checking failed | ||
raise | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Do not need the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally prefer the whole if/else logic. It's clearer, it doesn't rely on the fact that the above block exits, and has a more functional flavor. |
||
|
||
raw_predictions = \ | ||
self.loss_.get_init_raw_predictions(X, self.init_) | ||
|
||
|
||
begin_at_stage = 0 | ||
|
||
# The rng state must be preserved if warm_start is True | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather it if we improved the message for fit params missing
__
in Pipeline, but okay