Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error in fit() method #190

Closed
lahoff opened this issue May 31, 2022 · 1 comment
Closed

[BUG] Error in fit() method #190

lahoff opened this issue May 31, 2022 · 1 comment

Comments

@lahoff
Copy link

lahoff commented May 31, 2022

Hi! I've installed pysindy in my Windows and Mac (via pip)
In all of them when I try to simply run the toy examples I get the same error
I tried with python 3.8, 3.9 and 3.10

Thanks!

Reproducing code example:

x = np.load('./DATA/data.npy')
t = np.arange(0, 10, 0.01)

model = ps.SINDy()
model.fit(x, t=t)

Error message:

Traceback (most recent call last):
File "...\PycharmProjects\DataScience\DynamicalSystems\PYSINDy.py", line 16, in
model.fit(x, t=t)
File "...\PycharmProjects\DataScience.venv\lib\site-packages\pysindy\pysindy.py", line 563, in fit
self.model.fit(x, x_dot)
File "...\PycharmProjects\DataScience.venv\lib\site-packages\sklearn\pipeline.py", line 382, in fit
self._final_estimator.fit(Xt, y, **fit_params_last_step)
File "...\PycharmProjects\DataScience.venv\lib\site-packages\pysindy\optimizers\sindy_optimizer.py", line 58, in fit
self.optimizer.fit(x, y)
File "...s\PycharmProjects\DataScience.venv\lib\site-packages\pysindy\optimizers\base.py", line 134, in fit
x, y, X_offset, y_offset, X_scale = self._preprocess_data(
AttributeError: 'STLSQ' object has no attribute '_preprocess_data'

@Jacob-Stevens-Haas
Copy link
Collaborator

Sounds like same issue as in #179. Tl; dr: scikit-learn changed where we import _preprocess_data() from. What are your pysindy and sklearn versions?

@akaptano akaptano closed this as completed Jun 2, 2022
jpcurbelo pushed a commit to jpcurbelo/pysindy_fork that referenced this issue May 9, 2024
jpcurbelo pushed a commit to jpcurbelo/pysindy_fork that referenced this issue May 9, 2024
* Fix typo in models doc (dynamicslab#190)

* CPU environment now pulls from conda forge, which is necessary to ensure an up-to-date xarray. (dynamicslab#193)

* Fix handling of weekly frequencies. (dynamicslab#194)

From neuralhydrology/neuralhydrology#111:
pd.infer_freq will return strings like "W-SUN" for weekly data, which
pd.Timestamp doesn't understand. We now convert these frequencies to
their equivalent multiple of 7D.

* Correcting the pre model hook and UMAL sampling (dynamicslab#195)

* The current use of `pre_model_hook` only applied the hook in training.
This can be useful, but UMAL requires the hook also in validation and
test. Thus, with the old setup UMAL only worked for the training.
My propsoed changes make the `pre_model_hook` part of the model, apply
it everywhere, and allow UMAL validation and evaluation.

I think in the future we should also allow for different hook behaviors
according to the setting at which it is called. But, for now  the
proposed changes are enough.

* Simpler Hook and Cleaner Pipeline

This commit comprises two things.
(1) A pre model hook that is simpler than the one in  original PR.
(2) An idea to avoid copying the whole dataset that just involves
a copy of the labels. That is still suboptimal in terms of memory
use, but make the overall code simpler. Not sure if it is the best
version. However,  at some point we have to extend the labels for
the loss, and we need to do so  withouth breaking the whole
downstream procedure. So maybe this is a good middle ground.

* Simplified UMAL Sampling Logic

This commit implements an idea from Martin that simplifies the sampling logic of the UMAL sampling util so that the sampling automatically checks whether the data has been extended.
Thus no extra argument is required for the function call for `sample_umal`.

* Spell correction neuralhydrology/modelzoo/basemodel.py

Updated comment so that additional is spelled correctly

Co-authored-by: Martin Gauch <15731649+gauchm@users.noreply.github.com>

* Spell correction for neuralhydrology/utils/samplingutils.py

UMAl -> UMAL

Co-authored-by: Martin Gauch <15731649+gauchm@users.noreply.github.com>

* Imporvement for Comments

Added some minor changes to the comments.

---------

Co-authored-by: Martin Gauch <15731649+gauchm@users.noreply.github.com>

* Update __about__.py

---------

Co-authored-by: Martin Gauch <15731649+gauchm@users.noreply.github.com>
Co-authored-by: Grey Nearing <grey.nearing@gmail.com>
Co-authored-by: Daniel Klotz <klotz@ml.jku.at>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants