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

Gamma regression does not work with example in docs #32

Closed
ThomasMGeo opened this issue Aug 11, 2022 · 2 comments
Closed

Gamma regression does not work with example in docs #32

ThomasMGeo opened this issue Aug 11, 2022 · 2 comments

Comments

@ThomasMGeo
Copy link
Contributor

X, Y, T = xc.load_sample_data() # load test data

gamma = xc.rGammaRegression()
gamma.fit(X, Y)
pred = gamma.predict(X)

ValueError: Some value(s) of y are out of the valid range of the loss 'HalfGammaLoss'.

@kjhall01
Copy link
Owner

Hi Thomas,

https://github.com/scikit-learn/scikit-learn/blob/c900ad385cecf0063ddd2d78883b0ea0c99cd835/sklearn/linear_model/_glm/glm.py#L116

Scikit-Learn's Gamma Regression "HalfGammaLoss" loss function requires data to be greater than 0. there are some gridpoints with precipitation = 0 in the sample data, so It shouldn't work.

Some options might be:

1/ implement a wrapper for the 2D gamma regressor implementation which drops 0-valued samples , then use XCast to extend it
2/ add something very small to Y before fitting - like: gamma.fit(X, Y+0.0001)

You may want to do option 1 anyway, because it looks like gamma regressor needs a different shape input vector than normal. Happy to help if you'd like.

@ThomasMGeo
Copy link
Contributor Author

Option 2 does work, agree that 1 is a better path. I will work on it for a bit, and reach out if I get stuck.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants