The Wayback Machine - https://web.archive.org/web/20230304095726/https://github.com/scikit-learn/scikit-learn/pull/23099
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

FIX add n_targets allowing consistent shape prediction before calling fit in GPR #23099

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

MaxwellLZH
Copy link
Contributor

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
Contributor

@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.

sklearn/gaussian_process/_gpr.py Outdated Show resolved Hide resolved
sklearn/gaussian_process/_gpr.py Outdated Show resolved Hide resolved
sklearn/gaussian_process/_gpr.py Outdated Show resolved Hide resolved
sklearn/gaussian_process/_gpr.py Outdated Show resolved Hide resolved
sklearn/gaussian_process/tests/test_gpr.py Show resolved Hide resolved
sklearn/gaussian_process/tests/test_gpr.py Outdated Show resolved Hide resolved
sklearn/gaussian_process/tests/test_gpr.py Outdated Show resolved Hide resolved
sklearn/gaussian_process/tests/test_gpr.py Outdated Show resolved Hide resolved
sklearn/gaussian_process/tests/test_gpr.py Outdated Show resolved Hide resolved
sklearn/gaussian_process/tests/test_gpr.py Outdated Show resolved Hide resolved
@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]>
Copy link
Contributor

@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
:meth:`sample_y` before :meth:`fit`). This parameter is ignored once
:meth:`fit` has been called.
Copy link
Member

Choose a reason for hiding this comment

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

API-wise, ignoring n_targets after fit is strange to me.

@glemaitre Assuming n_targets is set, what do you think of requiring the number of targets seen in fit to be consistent with n_targets?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is less lenient and more conservative but I don't have any objection to that.
@MaxwellLZH Do you want to make this change of behaviour?

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.

None yet

3 participants