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]Problems encountered in expanding the library(simulation step) #581

Open
BK201-kkk opened this issue Nov 6, 2024 · 1 comment
Open

Comments

@BK201-kkk
Copy link

BK201-kkk commented Nov 6, 2024

I added λx to the original quadratic model (including first-order and second-order terms), that is, I expanded my library to ['x0', 'x1', 'x2', 'x3', 'x4', 'x5', 'x6', 'x7', 'x0^2', 'x0 x1', 'x0 x2', 'x0 x3', 'x0 x4', 'x0 x5', 'x0 x6', 'x0 x7', 'x1^2', 'x1 x2', 'x1 x3', 'x1 x4', 'x1 x5', 'x1 x6', 'x1 x7', 'x2^2', 'x2 x3', 'x2 x4', 'x2 x5', 'x2 x6', 'x2 x7', 'x3^2', 'x3 x4', 'x3 x5', 'x3 x6', 'x3 x7', 'x4^2', 'x4 x5', 'x4 x6', 'x4 x7', 'x5^2', 'x5 x6', 'x5 x7', 'x6^2', 'x6 x7', 'x7^2', '27.550698135319728 x0', '27.30162539091796 x1', '17.823184677763013 x2', '19.962163132722978 x3', '18.583052660862982 x4', '19.606816257956034 x5', '22.26123984319782 x6', '23.015871481922936 x7']
New library has 52 items!

I successfully got the fitted model, for example for x0:
(x0)' = -0.002060 x0 x1 + 0.024776 x0 x2 + 0.001030 x0 x3 + 0.013200 x0 x4 + 0.032148 x0 x5 + -0.011575 x0 x6 + 0.001541 x0 x7 + 0.015141 x1^2 + 0.015628 x1 x2 + 0.046373 x1 x3 + -0.001168 x1 x4 + 0.024892 x1 x5 + 0.001096 x1 x7 + -0.017467 x2^2 + 0.017878 x2 x3 + -0.006292 x2 x4 + 0.024463 x2 x5 + 0.010341 x2 x6 + 0.005851 x2 x7 + 0.009305 x3^2 + -0.010523 x3 x4 + 0.029996 x3 x5 + -0.002509 x3 x6 + 0.011126 x3 x7 + -0.006788 x4^2 + -0.004106 x4 x5 + 0.004906 x4 x7 + 0.001332 x5 x6 + 0.015972 x6^2 + -0.003034 x6 x7 + -0.015874 x7^2 + 0.025424 27.30162539091796 x1 + -0.006484 17.823184677763013 x2 + 0.001398 19.962163132722978 x3 + 0.001691 18.583052660862982 x4

But it is clear that terms like 0.025424 27.30162539091796 x1 are not optimally represented. When I then run simulation, I get the error Simulation error: cannot reshape array of size 44 into shape (12000,newaxis). I don't know why the newly added terms are not recognized during model.simulate, even though they were successfully recognized during the model.fit step.

I tried to manually modify the parameters to make the correlation term a first-order term with only one coefficient (which exists at the same time as the ordinary first-order term, i.e. there may be two x0 terms), but the same problem still exists.

Thank you very much for your guidance and help!

Reproducing code example:

import pysindy
<< your code here >>

Error message:

Simulation error: cannot reshape array of size 44 into shape (12000,newaxis)
Simulation error: [[-1.21098846e-01 1.10845991e-01 -5.11850682e-02 2.38984799e-01......

PySINDy/Python version information:

@ricor07
Copy link

ricor07 commented Dec 26, 2024

Hello, I'd be glad to contribute to the project by fixing the issue. Can you assign it to me? Thanks

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

2 participants