pysindy.utils package¶
Submodules¶
pysindy.utils.axes module¶
- class pysindy.utils.axes.AxesArray(input_array, axes)[source]¶
Bases:
NDArrayOperatorsMixin
,ndarray
A numpy-like array that keeps track of the meaning of its axes.
- Parameters
input_array (array-like) – the data to create the array.
axes (dict) – A dictionary of axis labels to shape indices. Allowed keys: - ax_time: int - ax_coord: int - ax_sample: int - ax_spatial: List[int]
- Raises
AxesWarning if axes does not match shape of input_array –
- property n_spatial¶
- property n_time¶
- property n_sample¶
- property n_coord¶
- pysindy.utils.axes.implements(numpy_function)[source]¶
Register an __array_function__ implementation for MyArray objects.
pysindy.utils.base module¶
- pysindy.utils.base.validate_input(x, t=<object object>)[source]¶
Forces input data to have compatible dimensions, if possible.
- Parameters
x – array of input data (measured coordinates across time)
t – time values for measurements.
- Returns
x as 2D array, with time dimension on first axis and coordinate index on second axis.
- pysindy.utils.base.validate_no_reshape(x, t=<object object>)[source]¶
Check types and numerical sensibility of arguments.
- Parameters
x – array of input data (measured coordinates across time)
t – time values for measurements.
- Returns
x as 2D array, with time dimension on first axis and coordinate index on second axis.
- pysindy.utils.base.validate_control_variables(x, u, trim_last_point=False)[source]¶
Ensure that control variables u are compatible with the data x.
Trims last control variable timepoint if set to True
- pysindy.utils.base.drop_nan_samples(x, y)[source]¶
Drops samples from x and y where there is either has a nan value
- pysindy.utils.base.reorder_constraints(c, n_features, output_order='row')[source]¶
Reorder constraint matrix.
- pysindy.utils.base.prox_weighted_l0(x, thresholds)[source]¶
Proximal operator for weighted l0 regularization.
- pysindy.utils.base.prox_weighted_l1(x, thresholds)[source]¶
Proximal operator for weighted l1 regularization.
- pysindy.utils.base.prox_weighted_l2(x, thresholds)[source]¶
Proximal operator for ridge regularization.
- pysindy.utils.base.prox_cad(x, lower_threshold)[source]¶
Proximal operator for CAD regularization
prox_cad(z, a, b) = 0 if |z| < a sign(z)(|z| - a) if a < |z| <= b z if |z| > b
Entries of \(x\) smaller than a in magnitude are set to 0, entries with magnitudes larger than b are untouched, and entries in between have soft-thresholding applied.
For simplicity we set \(b = 5*a\) in this implementation.
- pysindy.utils.base.capped_simplex_projection(trimming_array, trimming_fraction)[source]¶
Projection of trimming_array onto the capped simplex
pysindy.utils.odes module¶
- pysindy.utils.odes.oscillator(t, x, mu1=0.05, mu2=-0.01, omega=3.0, alpha=-2.0, beta=-5.0, sigma=1.1)[source]¶
- pysindy.utils.odes.yeast(t, x, c1=2.5, c2=-100, c3=13.6769, d1=200, d2=13.6769, d3=-6, d4=-6, e1=6, e2=-64, e3=6, e4=16, f1=64, f2=-13, f3=13, f4=-16, f5=-100, g1=1.3, g2=-3.1, h1=-200, h2=13.6769, h3=128, h4=-1.28, h5=-32, j1=6, j2=-18, j3=-100)[source]¶
- pysindy.utils.odes.f_steer(x, u, min_sangle=-0.91, max_sangle=0.91, min_svel=-0.4, max_svel=0.4, min_vel=-13.9, max_vel=45.8, switch_vel=4.755, amax=11.5)[source]¶
Module contents¶
- class pysindy.utils.AxesArray(input_array, axes)[source]¶
Bases:
NDArrayOperatorsMixin
,ndarray
A numpy-like array that keeps track of the meaning of its axes.
- Parameters
input_array (array-like) – the data to create the array.
axes (dict) – A dictionary of axis labels to shape indices. Allowed keys: - ax_time: int - ax_coord: int - ax_sample: int - ax_spatial: List[int]
- Raises
AxesWarning if axes does not match shape of input_array –
- property n_spatial¶
- property n_time¶
- property n_sample¶
- property n_coord¶
- pysindy.utils.concat_sample_axis(x_list: List[AxesArray])[source]¶
Concatenate all trajectories and axes used to create samples.
- pysindy.utils.capped_simplex_projection(trimming_array, trimming_fraction)[source]¶
Projection of trimming_array onto the capped simplex
- pysindy.utils.drop_nan_samples(x, y)[source]¶
Drops samples from x and y where there is either has a nan value
- pysindy.utils.print_model(coef, input_features, errors=None, intercept=None, error_intercept=None, precision=3, pm='±')[source]¶
- Parameters
coef –
input_features –
errors –
intercept –
sigma_intercept –
precision –
pm –
Returns:
- pysindy.utils.prox_cad(x, lower_threshold)[source]¶
Proximal operator for CAD regularization
prox_cad(z, a, b) = 0 if |z| < a sign(z)(|z| - a) if a < |z| <= b z if |z| > b
Entries of \(x\) smaller than a in magnitude are set to 0, entries with magnitudes larger than b are untouched, and entries in between have soft-thresholding applied.
For simplicity we set \(b = 5*a\) in this implementation.
- pysindy.utils.prox_weighted_l0(x, thresholds)[source]¶
Proximal operator for weighted l0 regularization.
- pysindy.utils.prox_weighted_l1(x, thresholds)[source]¶
Proximal operator for weighted l1 regularization.
- pysindy.utils.reorder_constraints(c, n_features, output_order='row')[source]¶
Reorder constraint matrix.
- pysindy.utils.supports_multiple_targets(estimator)[source]¶
Checks whether estimator supports multiple targets.
- pysindy.utils.validate_control_variables(x, u, trim_last_point=False)[source]¶
Ensure that control variables u are compatible with the data x.
Trims last control variable timepoint if set to True
- pysindy.utils.validate_input(x, t=<object object>)[source]¶
Forces input data to have compatible dimensions, if possible.
- Parameters
x – array of input data (measured coordinates across time)
t – time values for measurements.
- Returns
x as 2D array, with time dimension on first axis and coordinate index on second axis.
- pysindy.utils.validate_no_reshape(x, t=<object object>)[source]¶
Check types and numerical sensibility of arguments.
- Parameters
x – array of input data (measured coordinates across time)
t – time values for measurements.
- Returns
x as 2D array, with time dimension on first axis and coordinate index on second axis.
- pysindy.utils.oscillator(t, x, mu1=0.05, mu2=-0.01, omega=3.0, alpha=-2.0, beta=-5.0, sigma=1.1)[source]¶