When running pyGAM with Python 3.13+, a DeprecationWarning is triggered during model scoring or grid search for models with a known scale (e.g. PoissonGAM or BinomialGAM).
The warning points to pygam/pygam.py at line 1223:
Deprecation Warning: Bitwise inversion '~' on bool is deprecated and will be removed in Python 3.16. This returns the bitwise inversion of the underlying int object and is usually not what you expect from negating a bool. Use the 'not' operator for boolean negation or ~int(x) if you really want the bitwise inversion of the underlying int.
Upon investigating, using the bitwise inversion operator ~ on the bo0lean parameter add scale is not only deprecated but also introduces a mathematical bug that shifts the calculated UBRE score by exactly + 2 * scale under all settings.
Main Cause -
In Python, bool is a subclass of int. The bitwise negation operator ~ maps x to -(x + 1). Thus:
~True (which is ~1) evaluates to -2 (instead of False or 0).
~False (which is ~0) evaluates to -1 (instead of True or 1).
When running pyGAM with Python 3.13+, a DeprecationWarning is triggered during model scoring or grid search for models with a known scale (e.g. PoissonGAM or BinomialGAM).
The warning points to pygam/pygam.py at line 1223:
Deprecation Warning: Bitwise inversion '~' on bool is deprecated and will be removed in Python 3.16. This returns the bitwise inversion of the underlying int object and is usually not what you expect from negating a bool. Use the 'not' operator for boolean negation or ~int(x) if you really want the bitwise inversion of the underlying int.
Upon investigating, using the bitwise inversion operator ~ on the bo0lean parameter add scale is not only deprecated but also introduces a mathematical bug that shifts the calculated UBRE score by exactly + 2 * scale under all settings.
Main Cause -
In Python, bool is a subclass of int. The bitwise negation operator ~ maps x to -(x + 1). Thus:
~True (which is ~1) evaluates to -2 (instead of False or 0).
~False (which is ~0) evaluates to -1 (instead of True or 1).