Skip to content

Conversation

@MaxwellLZH
Copy link
Contributor

@MaxwellLZH MaxwellLZH commented Apr 10, 2022

Fixes #22430

Reference Issues/PRs

This PR adds a new argument n_targets for GaussianProcessRegressor as suggested in issue #22430 , which will be used to determine the output shape of both predict and sample_y, so the shape will be consistent before and after calling fit method.

Any other comments?

I'm not sure if we should raise error during the fit process if the dimension ofy does not match n_targets, since once we fit the model the output shape will be determined by the shape of y.

@MaxwellLZH
Copy link
Contributor Author

MaxwellLZH commented Apr 22, 2022

Hi @glemaitre, could you help take a look at this PR, thank you

Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good. Could you add a what's new entry in 1.2.
Note that this is a bug fix rather than a feature.

@glemaitre glemaitre changed the title FET add argument n_targets for GPR FIX add n_targets allowing consistent shape prediction before calling fit in GPR Jun 22, 2022
MaxwellLZH and others added 15 commits June 23, 2022 22:04
Co-authored-by: Guillaume Lemaitre <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
Co-authored-by: Guillaume Lemaitre <[email protected]>
@MaxwellLZH MaxwellLZH requested a review from glemaitre June 24, 2022 01:39
Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@glemaitre glemaitre added this to the 1.3 milestone Jan 11, 2023
@glemaitre glemaitre added the Waiting for Second Reviewer First reviewer is done, need a second one! label Jan 11, 2023
Copy link
Member

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @MaxwellLZH. I directly pushed the remaining requested change. LGTM.

@jeremiedbb
Copy link
Member

@thomasjpfan are you happy with the latest updates ?

n_targets_seen = y.shape[1] if y.ndim > 1 else 1
if self.n_targets is not None and n_targets_seen != self.n_targets:
raise ValueError(
"Number of targets seen != n_targets. "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would favor a more literal error:

The number of targets seen in `y` is different from the parameter `n_targets`.
Got ...

Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still my +1 on this one. Just a nitpick regarding the error message raised.

@glemaitre glemaitre merged commit c8f79e2 into scikit-learn:main May 31, 2023
@glemaitre
Copy link
Member

LGTM. Merging since the changes requested by @thomasjpfan have been implemented.

REDVM pushed a commit to REDVM/scikit-learn that referenced this pull request Nov 16, 2023
…ng `fit` in GPR (scikit-learn#23099)

Co-authored-by: Guillaume Lemaitre <[email protected]>
Co-authored-by: Jérémie du Boisberranger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:gaussian_process Waiting for Second Reviewer First reviewer is done, need a second one!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GPR sample_y enforce n_targets=1 before calling fit

4 participants