-
Notifications
You must be signed in to change notification settings - Fork 2
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
Grid locator #20
Grid locator #20
Changes from all commits
ba34313
e341495
c51cea3
f3425fe
abfa77f
7872478
b0b3517
ff0a8bc
855458d
dc97a46
3b954fc
adf2d08
d17275e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
from collections.abc import Iterable | ||
from typing import TypeVar | ||
|
||
import numpy as np | ||
import pysindy as ps | ||
|
||
from gen_experiments.data import _signal_avg_power | ||
from gen_experiments.gridsearch.typing import ( | ||
GridLocator, | ||
SeriesDef, | ||
SeriesList, | ||
SkinnySpecs, | ||
) | ||
from gen_experiments.plotting import _PlotPrefs | ||
from gen_experiments.utils import FullSINDyTrialData, NestedDict, SeriesDef, SeriesList | ||
from gen_experiments.typing import NestedDict | ||
from gen_experiments.utils import FullSINDyTrialData | ||
|
||
T = TypeVar("T") | ||
U = TypeVar("U") | ||
|
@@ -41,77 +49,43 @@ def addn(x): | |
|
||
|
||
plot_prefs = { | ||
"test": _PlotPrefs(True, False, ({"sim_params.t_end": 10},)), | ||
"test": _PlotPrefs(), | ||
"test-absrel": _PlotPrefs( | ||
True, _convert_abs_rel_noise, ({"sim_params.noise_abs": 1},) | ||
True, _convert_abs_rel_noise, GridLocator(..., {("sim_params.noise_abs", (1,))}) | ||
), | ||
"test-absrel2": _PlotPrefs( | ||
True, | ||
_convert_abs_rel_noise, | ||
( | ||
{"sim_params.noise_abs": 0.1}, | ||
{"sim_params.noise_abs": 0.5}, | ||
{"sim_params.noise_abs": 1}, | ||
{"sim_params.noise_abs": 2}, | ||
{"sim_params.noise_abs": 4}, | ||
{"sim_params.noise_abs": 8}, | ||
GridLocator( | ||
..., | ||
(..., ...), | ||
( | ||
{"sim_params.noise_abs": 0.1}, | ||
{"sim_params.noise_abs": 0.5}, | ||
{"sim_params.noise_abs": 1}, | ||
{"sim_params.noise_abs": 2}, | ||
{"sim_params.noise_abs": 4}, | ||
{"sim_params.noise_abs": 8}, | ||
), | ||
), | ||
), | ||
"test-absrel3": _PlotPrefs( | ||
"absrel-newloc": _PlotPrefs( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For running the experiments, which one of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
True, | ||
_convert_abs_rel_noise, | ||
( | ||
{ | ||
"sim_params.noise_abs": 1, | ||
"diff_params.smoother_kws.window_length": 15, | ||
}, | ||
{"sim_params.noise_abs": 1, "diff_params.meas_var": 1}, | ||
{"sim_params.noise_abs": 1, "diff_params.alpha": 1e-2}, | ||
GridLocator( | ||
["coeff_mse", "coeff_f1"], | ||
(..., (2, 3, 4)), | ||
( | ||
{"diff_params.kind": "kalman", "diff_params.alpha": None}, | ||
{ | ||
"diff_params.kind": "kalman", | ||
"diff_params.alpha": lambda a: isinstance(a, int), | ||
}, | ||
{"diff_params.kind": "trend_filtered"}, | ||
{"diff_params.diffcls": "SmoothedFiniteDifference"}, | ||
), | ||
), | ||
), | ||
"test-absrel4": _PlotPrefs( | ||
True, | ||
_convert_abs_rel_noise, | ||
( | ||
{ | ||
"sim_params.noise_abs": 1, | ||
"diff_params.smoother_kws.window_length": 15, | ||
}, | ||
{"sim_params.noise_abs": 1, "diff_params.meas_var": 1}, | ||
{"sim_params.noise_abs": 1, "diff_params.alpha": 1e0}, | ||
{ | ||
"sim_params.noise_abs": 2, | ||
"diff_params.smoother_kws.window_length": 15, | ||
}, | ||
{"sim_params.noise_abs": 2, "diff_params.meas_var": 4}, | ||
{"sim_params.noise_abs": 2, "diff_params.alpha": 1e-1}, | ||
), | ||
), | ||
"test-absrel5": _PlotPrefs( | ||
True, | ||
_convert_abs_rel_noise, | ||
( | ||
{ | ||
"sim_params.noise_abs": 1, | ||
"diff_params.diffcls": "SmoothedFiniteDifference", | ||
}, | ||
{"sim_params.noise_abs": 1, "diff_params.kind": "kalman"}, | ||
{"sim_params.noise_abs": 1, "diff_params.kind": "trend_filtered"}, | ||
{ | ||
"sim_params.noise_abs": 2, | ||
"diff_params.diffcls": "SmoothedFiniteDifference", | ||
}, | ||
{"sim_params.noise_abs": 2, "diff_params.kind": "kalman"}, | ||
{"sim_params.noise_abs": 2, "diff_params.kind": "trend_filtered"}, | ||
{ | ||
"sim_params.noise_abs": 4, | ||
"diff_params.diffcls": "SmoothedFiniteDifference", | ||
}, | ||
{"sim_params.noise_abs": 4, "diff_params.kind": "kalman"}, | ||
{"sim_params.noise_abs": 4, "diff_params.kind": "trend_filtered"}, | ||
), | ||
{(0, 2), (3, 2), (0, 3), (3, 3), (0, 4), (3, 4)}, | ||
), | ||
} | ||
sim_params = { | ||
"test": ND({"n_trajectories": 2}), | ||
|
@@ -301,7 +275,7 @@ def addn(x): | |
"duration-absnoise": ["sim_params.t_end", "sim_params.noise_abs"], | ||
"rel_noise": ["sim_params.t_end", "sim_params.noise_rel"], | ||
} | ||
grid_vals = { | ||
grid_vals: dict[str, list[Iterable]] = { | ||
"test": [[5, 10, 15, 20]], | ||
"abs_noise": [[0.1, 0.5, 1, 2, 4, 8]], | ||
"abs_noise-kalman": [[0.1, 0.5, 1, 2, 4, 8], [0.1, 0.5, 1, 2, 4, 8]], | ||
|
@@ -319,7 +293,7 @@ def addn(x): | |
"lorenzk": ["plot", "plot", "max"], | ||
"plot2": ["plot", "plot"], | ||
} | ||
diff_series = { | ||
diff_series: dict[str, SeriesDef] = { | ||
"kalman1": SeriesDef( | ||
"Kalman", | ||
diff_params["kalman"], | ||
|
@@ -375,7 +349,7 @@ def addn(x): | |
[[5, 8, 12, 15]], | ||
), | ||
} | ||
series_params = { | ||
series_params: dict[str, SeriesList] = { | ||
"test": SeriesList( | ||
"diff_params", | ||
"Differentiation Method", | ||
|
@@ -434,7 +408,7 @@ def addn(x): | |
} | ||
|
||
|
||
skinny_specs = { | ||
skinny_specs: dict[str, SkinnySpecs] = { | ||
"exp3": ( | ||
("sim_params.noise_abs", "diff_params.meas_var"), | ||
((identity,), (identity,)), | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does
...
signify here in the GridLocator arguments? Is it meant to be taking all the metrics or is it empty?Edit: I've read about the
Ellipsis
object.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Yeah, I wanted to borrow some notation from numpy that means "all elements". They're both what are called "singletons". Only one
NoneType
object exists in a python program, just like only oneEllipsisType
object ever exists.I suppose I could have used
None
instead. That may be an arguably better way, I just wanted to use an object that people associate with "all" of something.