dynamicslab / pysindy

A package for the sparse identification of nonlinear dynamical systems from data
https://pysindy.readthedocs.io/en/latest/
Other
1.36k stars 304 forks source link

Allow explicit control of randomness for ensembling #485

Open Jacob-Stevens-Haas opened 3 months ago

Jacob-Stevens-Haas commented 3 months ago

Is your feature request related to a problem? Please describe.

EnsembleOptimizer uses _drop_random_samples() and np.random.choice to determine which data/features are involved in each bag. When running experiments, you can create reproducible ensembles by setting numpy.random.seed. However, when reading experiments, its easy to overlook that this seed is actually used, because it mutates global state, a form of spooky action at a distance. Worse, if someone thinks that it isn't used, deleting np.random.seed(seed) won't cause errors.

The solution is to be explicit at least with setting the seed. Relevant Jax philosophy.

Describe the solution you'd like

EnsembleOptimizer accepts a rand_gen: np.random.Generator object.

Describe alternatives you've considered

EnsembleOptimizer accepts a seed: int object.