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

Received error 'csr_matrix' object has no attribute 'A'

rr1964 opened this issue · comments

Environment is Python 3.11. In order to avoid the issues of #337 I uninstall scikit-sparse. However, this then presents a new error from line 81 of utils.py:

File [~/micromamba/envs/ml/lib/python3.11/site-packages/pygam/utils.py:81]

(http://localhost:8888/~/micromamba/envs/ml/lib/python3.11/site-packages/pygam/utils.py#line=80), in cholesky(A, sparse, verbose)

 78     warnings.warn(msg)
 80 if sp.sparse.issparse(A):
 81     A = A.A
 83 try:
 84     L = sp.linalg.cholesky(A, lower=False)

AttributeError: 'csr_matrix' object has no attribute 'A'

As it stands now, PyGAM is no longer usable for "newer" version of Python Scipy. (As far as I can tell, this fails on versions of Scipy going back several years).

To fix this, I manually changed line 81 of utils.py to A = A.toarray(). You will also need to change lines 706 and 783 of pygam.py to use toarray() instead of the .A syntax. There may be more places as well, depending on which models you use. The broad fix is just to replace .A with toarray() everywhere you get that error.

You can downgrade to scipy=1.13.1 to resolve the issue. I suspect it requires a new release to fix the dependency to scipy>1.14.0