dswah / pyGAM

[HELP REQUESTED] Generalized Additive Models in Python

Home Page:https://pygam.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use of logit link for regression

david-waterworth opened this issue · comments

Is it possible to use the logit link for a regression problem with bounded response variable?

I tried using gam = GAM(intercept + l(0) + te(1,2), link='logit') where 0,1 and 2 are continuous variables as is the target. I scaled the response to 0..1 using min/max scaling.

I'm getting the error below. I also tried LogisticGAM but I don't think that's equivalent, it models the response as binary


AttributeError Traceback (most recent call last)
in
5
6 gam = GAM(intercept + l(0) + te(1,2), link='logit')
----> 7 gam.gridsearch(x, y)
8 #gam.fit(x, y)
9 gam.summary()

~/.pyenv/versions/mirvac-foot-traffic/lib/python3.7/site-packages/pygam/pygam.py in gridsearch(self, X, y, weights, return_scores, keep_best, objective, progress, **param_grids)
1773 self._validate_data_dep_params(X)
1774
-> 1775 y = check_y(y, self.link, self.distribution, verbose=self.verbose)
1776 X = check_X(X, verbose=self.verbose)
1777 check_X_y(X, y)

~/.pyenv/versions/mirvac-foot-traffic/lib/python3.7/site-packages/pygam/utils.py in check_y(y, link, dist, min_samples, verbose)
222 warnings.simplefilter("ignore")
223
--> 224 if np.any(np.isnan(link.link(y, dist))):
225 raise ValueError('y data is not in domain of {} link function. '
226 'Expected domain: {}, but found {}' \

~/.pyenv/versions/mirvac-foot-traffic/lib/python3.7/site-packages/pygam/links.py in link(self, mu, dist)
115 lp : np.array of length n
116 """
--> 117 return np.log(mu) - np.log(dist.levels - mu)
118
119 def mu(self, lp, dist):

AttributeError: 'NormalDist' object has no attribute 'levels'