pyGAM
pyGAM copied to clipboard
Overflow RuntimeWarning
There seems to be some overflow in line 197 in pygam/links.py. This is mostly cause by exceeding the float value. The easiest fix would be to clip the function with np.clip to a smaller value like 700 to prevent this overflow. I manage to fix it but will open the PR after #366 has been merge to main.
I got something similar at a different spot:
File "/root/axiom/predict/clinical/dili_risk/models/gam_simple.py", line 105, in train
self.model.fit(X, y, weights=sample_weight)
File "/usr/local/lib/python3.11/site-packages/pygam/pygam.py", line 912, in fit
self._pirls(X, y, weights)
File "/usr/local/lib/python3.11/site-packages/pygam/pygam.py", line 769, in _pirls
W = self._W(mu, weights, y) # create pirls weight matrix
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pygam/pygam.py", line 630, in _W
self.link.gradient(mu, self.distribution) ** 2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^~~
FloatingPointError: overflow encountered in square
OK this is a good idea. i think we may want to add a tiny value to the denominators, and clip values before exponentiation (on values greater than 1)?