dynamicslab / pysindy

A package for the sparse identification of nonlinear dynamical systems from data
https://pysindy.readthedocs.io/en/latest/
Other
1.42k stars 310 forks source link

[BUG] Scikit-learn 1.3.0 changes _csr_polynomial_features #365

Closed Jacob-Stevens-Haas closed 1 year ago

Jacob-Stevens-Haas commented 1 year ago

Tests break on 1.3.0, part of the reason for the #363 CI failures, when an error traceback escapes into scipy's Cython file _csr_polynomial_exmpansion.pyx.

pysindy/feature_library/polynomial_library.py:229: in transform
    xp_next = _csr_polynomial_expansion(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   TypeError: Function call with ambiguous argument types

This is because we relied on _csr_polynomial_features, a non-public piece of the sklearn API that changed. Fortunately, PolynomialFeatures can handle sparse arrays natively, so we can probably remove a lot of the nested conditionals based upon type of sparse matrix.

It is worth noting that with ensembling removed from the feature library, the only role our PolynomialLibrary serves is to allow solely the non-interacting polynomial terms. There is probably a much lower-code version of our lib that can do that.