Comments (14)
PI is my least familiar part of the repo, but I see why it might not. But it looks like it creates coef_
in the correct shape, so what happens if you give it a try?
from pysindy.
PI is my least familiar part of the repo, but I see why it might not. But it looks like it creates
coef_
in the correct shape, so what happens if you give it a try?
Thanks for your response. After getting the fitted implicit ODEs model, model.predict() works well.
To demonstrate the question, here are two models from my results:
x0_t = -0.031 1 + -0.104 x2 + 0.053 x5 + 0.132 x6 + 0.081 x0x1 + 0.024 x0x0 + -0.843 x5_t + 0.728 x0x0_t
x7_t = 0.015 1 + -0.044 x0 + 0.054 x5 + -0.156 x7 + 0.002 x0x1 + 0.030 x0x0
Follow your suggestion, save the model coefficient by: coefs = model.coefficients()
If I let the coefficients corresponding to x7_t (which has no x_t terms on the right hand side) loop the dataset, will get the same results compared to the resutls from model.predict(). It is consistent with the documentation which is 'result = [self.model.predict([xi]) for xi in x]'.
Then the question is how model.predict() loop data if there are x_t terms on the right hand side of implicit ODEs model?
Thanks.
from pysindy.
I'm sorry, I don't understand everything you've done. How many models did SINDyPI fit in your example? And what do you mean when you say you "let the coefficients corresponding to x7_t loop the dataset?"
from pysindy.
I'm sorry, I don't understand everything you've done. How many models did SINDyPI fit in your example? And what do you mean when you say you "let the coefficients corresponding to x7_t loop the dataset?"
Hi thanks for your response.
For the first question, my dataset has 8 features. The library functions are defined below:
library_functions = [
lambda x: x,
lambda x, y: x * y,
lambda x: x ** 2,
]
x_dot_library_functions = [lambda x: x]
library_function_names = [
lambda x: x,
lambda x, y: x + y,
lambda x: x + x,
]
So I got a total of 405 models (model0 -model404).
For the second question, I picked up model 45 and model 53 which are
x0_t = -0.031 1 + -0.104 x2 + 0.053 x5 + 0.132 x6 + 0.081 x0x1 + 0.024 x0x0 + -0.843 x5_t + 0.728 x0x0_t
x7_t = 0.015 1 + -0.044 x0 + 0.054 x5 + -0.156 x7 + 0.002 x0x1 + 0.030 x0x0
The reason I picked up those two as the first model has x_t terms on the right hand side and the second one does not.
I am using those two models to try to understand how model. predict () works.
As described in the documentation, the model.predict() works as 'result = [self.model.predict([xi]) for xi in x]'.
https://github.com/dynamicslab/pysindy/blob/master/pysindy/pysindy.py, at line 274
If I get the coefficients from x7_t, and loop the dataset. The results are consistent with the results model.predict(dataset)[:,53]
.
Then the question is just like the title, how model.predict() works if the fitted model (just like model x0_t here) has x_t terms on the right hand side? We only give x (to be input) to this function instead of x_t.
I test model.predict(dataset) by myself, and it works without any issues. Thanks.
from pysindy.
Which library are you using? PDELibrary
, or CustomLibrary
?
from pysindy.
It is PDELibrary.
Here is my code:
sindy_library = ps.PDELibrary(
library_functions=library_functions,
temporal_grid=t,
function_names=library_function_names,
include_bias=True,
implicit_terms=True,
derivative_order=1
)
sindy_opt = ps.SINDyPI( ### lambda = threshold^2 / (2 * nu)
threshold=1e-2,
tol=1e-8,
thresholder="l1",
max_iter=20000,
)
model = ps.SINDy(
optimizer=sindy_opt,
feature_library=sindy_library,
differentiation_method=ps.SINDyDerivative(kind="kalman", alpha=0.6)
)
model.fit(X_sm_poly, t=t)
model.print()
sindy_library.get_feature_names()
from pysindy.
My guess is that predict
is giving you bad outputs. I don't think you can trust what you get out. My guess is that SINDyPI
is reordering the features internally between each model it's fitting.
Also, you can format your code in Github comments. Heads up, I did this for a few of your comments.
from pysindy.
OK, thanks for your reply. I just wonder, for the multiple features implicit ODE model, is there any function/way in pysindy to evaluate each fitted model? If I follow the example 9_sindypi_with_sympy.ipynb. The method from 'Check all the model fits produce sensible models' to 'integrate and plot the new equations for x_dot' part, only works for single feature ODE model. I tested by myself, this method could not work for multiple features. Thanks.
from pysindy.
I'm sorry, you would need to troubleshoot further. That code involves heavy use of sympy, which I've never used. Specifically, can you see where pysindy provides something unexpected?
from pysindy.
Related Issues (20)
- Incorporate make_constraints into trapping_sr3.py HOT 8
- Initial Guess - SR3 - Custom Library [BUG] HOT 3
- [Help] Can't get the right model for 2d system HOT 3
- [DOC] WeakPDELibrary.transform does not produce output in shape specified by documentation.
- Help in figuring out the cause behind TypeError while fitting with tensor libraries HOT 7
- Optimizer for SINDy-PI feature of implicit ODEs HOT 7
- Let model.print() respect the same kwargs as print()
- Use `x_dot` kwarg in `model.fit` in PDEs with `WeakPDELibrary()`
- constraint_separation_index undocumented
- Do we need `test_trapping_cubic_library()`? HOT 1
- Make `IdentityLibrary` a subclass of `PolynomialLibrary`
- Make models guaranteed pickleable
- Error in '3_original_Paper' Example: Missing 'quiet' Argument in pysindy.py HOT 1
- Remove research experiments from pysindy HOT 4
- Passing custom derivatives instead of using predefined differentiation classes HOT 4
- [BUG] pytest-lazy-fixture may be dead, blocking pytest upgrades HOT 1
- `np.median(model.coef_list, axis=0)` does not give the same answer as `model.print()` from first example in ensembling documentation HOT 2
- [BUG] SINDyDerivative does not handle PDEs HOT 2
- Feature request: Manually set coefficients HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pysindy.