PoissonGAM fails with dimension mismatch warning depending on n_splines
See original GitHub issueUsing a grid search and several options for n_splines, some fits fail due to a dimension mismatch.
gam = PoissonGAM(dtype='numerical').gridsearch(X, y, n_splines=np.arange(4,10))
....
return (mu**y) * np.exp(-mu) / sp.misc.factorial(y)
50% (3 of 6) |############# | Elapsed Time: 0:00:00 ETA: 0:00:00/usr/local/lib/python3.6/site-packages/pygam/pygam.py:1888: UserWarning: shapes (120,240) and (239,120) not aligned: 240 (dim 1) != 239 (dim 0)
on model:
PoissonGAM(callbacks=[Deviance(), Diffs(), Accuracy()],
constraints=None, dtype='numerical', fit_intercept=True,
fit_linear=False, fit_splines=True, lam=0.6, max_iter=100,
n_splines=7, penalties='auto', spline_order=3, tol=0.0001)
skipping...
warnings.warn(msg)
66% (4 of 6) |################## | Elapsed Time: 0:00:00 ETA: 0:00:00/usr/local/lib/python3.6/site-packages/pygam/pygam.py:1888: UserWarning: shapes (137,260) and (259,123) not aligned: 260 (dim 1) != 259 (dim 0)
on model:
PoissonGAM(callbacks=[Deviance(), Diffs(), Accuracy()],
constraints=None, dtype='numerical', fit_intercept=True,
fit_linear=False, fit_splines=True, lam=0.6, max_iter=100,
n_splines=8, penalties='auto', spline_order=3, tol=0.0001)
skipping...
...
Training a LinearGAM model using the same dataset and grid search options does not give rise to the same error.
gam = LinearGAM(dtype='numerical').gridsearch(X, y, n_splines=np.arange(4,10))
100% (6 of 6) |###########################| Elapsed Time: 0:00:00 Time: 0:00:00
Does this occur because there are more coefficients than data? If so, a more informative warning would be helpful.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:18 (11 by maintainers)
Top Results From Across the Web
A Tour of pyGAM - Read the Docs
0.1 ' ' 1 WARNING: Fitting splines and a linear function to a feature introduces a model identifiability problem which can cause p-values...
Read more >ValueError: Dimension mismatch - Stack Overflow
According to the IPython stacktrace below, the error occurs in SciPy: ... 278 raise ValueError('dimension mismatch') 279 280 result = self.
Read more >Epidemiology of human health effects association with ... - EPA
Caution in interpreting size-fraction PM studies is warranted due to the. 24 problem of measurement error and the correlation between the ...
Read more >Semiparametric Regression for the Social Sciences - EPDF
of the error term: are the errors heteroskedastic or serially correlated? Social ... by selecting a sampling distribution for the dependent variable.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ive put the depracation warning in a separate issue.
@maxpagels thanks for finding this bug.
i believe i’ve replicated the error locally, and it looks like it is occurring because of some poor book-keeping of the matrix shapes during the optimization loop.
(not because n_coef > n_samples)
i want to get a fix out this week.