-
Notifications
You must be signed in to change notification settings - Fork 328
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
Sindyc #71
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #71 +/- ##
==========================================
- Coverage 95.67% 95.58% -0.10%
==========================================
Files 18 18
Lines 810 884 +74
==========================================
+ Hits 775 845 +70
- Misses 35 39 +4 ☔ View full report in Codecov by Sentry. |
Overall the PR looks good to me. However, we have a lot of overlap with the main |
Yes, it should be possible to combine them. The reason I didn't group them together from the beginning was just that it makes some of the important SINDy methods more cluttered (e.g. fit and simulate). I will take a stab at combining them and push the changes. If we decide it looks too sloppy we can always revert back to this version. |
Okay I moved everything into one class at the cost of a few extra if-else blocks here and there. I also updated the unit tests to reflect the new structure. On that topic, @Ohjeah, do you know of a good way to handle all the SINDYc unit tests at the same time as the SINDy ones? Most of the tests I wrote for SINDYc are very similar to the SINDy versions, but the SINDy tests require slightly different data fixtures than the SINDYc ones. E.g. for SINDy we might look like this x, t = data
model = SINDy()
model.fit(x, t=t)
x_dot = model.predict(x)
assert x.shape == x_dot.shape whereas the corresponding test for SINDYc would look like x, t, u, _ = data
model = SINDy()
model.fit(x, u=u, t=t)
x_dot = model.predict(x, u=u)
assert x.shape == x_dot.shape Do you have any ideas on how to combine tests like these? |
Usually I think it is a good idea to be a little bit more verbose with test such that the unit tests are easily understandable and do not have additional logic. You could parametrize like this though: @pytest.mark.parametrize()
def test_shape(model_cls, data):
model = model_cls()
*inputs, time = data
model.fit(*inputs, t=t)
x_dot = model.predict(*inputs)
assert inputs[0].shape == x_dot.shape |
I will leave them as separate tests for now for the sake of readability. |
Sure. The complexity test is still failing sporadically. We should try to constrain that a bit more and make it more deterministic. Should I accept the PR anyway? |
Sorry, I didn't see your comment before making the most recent commit. I relaxed the complexity test constraint a bit more. I was able to reproduce the failed test locally by using the same parameters: Maybe we could remove LASSO from this test? Or we could stick with the quick fix I made. In any case, the bug isn't caused by this PR, so I think it's okay to accept it. |
fix json formatting issue
Rework docs, add issue templates, fix minor bugs
This pull request implements a
SINDyC
object (SINDy with control) #66 along with a full set of unit tests. The class is very similar to a standardSINDy
object, but with an additional parameter,u
, representing the control inputs, which is needed when thefit
,predict
,score
, orsimulate
functions are called.Instead of solving
SINDyC solves
where
U
is a matrix containing the control inputs.Internally we essentially just ignore the control inputs when computing
X'
, but use them when computing the libraryTheta(X, U)
.This pull request also allows you to fit a model to a subset of the variables as in #40. You simply group all the variables in which you're interested inside
X
and the variables for which you aren't seeking differential equations insideU
.Other changes:
SINDy.process_multiple_trajectories
causingx
to be shrunk each time it was called withdiscrete_time=True
andx_dot=None
.