Skip to content

Commit f44960c

Browse files
committed
improved optimization docstring further
1 parent a4dfb57 commit f44960c

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

pynumdiff/optimize/_optimize.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -172,29 +172,27 @@ def optimize(func, x, dt, dxdt_truth=None, tvgamma=1e-2, search_space_updates={}
172172
padding=0, opt_method='Nelder-Mead', maxiter=10, parallel=True, huberM=6):
173173
"""Find the optimal hyperparameters for a given differentiation method.
174174
175-
:param function func: differentiation method to optimize parameters for, e.g. linear_model.savgoldiff
175+
:param function func: differentiation method to optimize parameters for, e.g. kalman_smooth.rtsdiff
176176
:param np.array[float] x: data to differentiate
177177
:param float dt: step size
178178
:param np.array[float] dxdt_truth: actual time series of the derivative of x, if known
179-
:param float tvgamma: Only used if :code:`dxdt_truth` is given. Regularization value used to select for parameters
179+
:param float tvgamma: Only used if :code:`dxdt_truth` is *not* given. Regularization value used to select for parameters
180180
that yield a smooth derivative. Larger value results in a smoother derivative.
181-
:param dict search_space_updates: At the top of :code:`_optimize.py`, each method has a search space of parameters
182-
settings structured as :code:`{param1:[values], param2:[values], param3:value, ...}`. The Cartesian
183-
product of values are used as initial starting points in optimization. If left None, the default
184-
search space is used.
185-
:param str metric: either :code:`'rmse'` or :code:`'error_correlation'`, only applies if :code:`dxdt_truth`
186-
is not None, see _objective_function
187-
:param int padding: number of time steps to ignore at the beginning and end of the time series in the
188-
optimization, or :code:`'auto'` to ignore 2.5% at each end. Larger value causes the
189-
optimization to emphasize the accuracy of dxdt in the middle of the time series
181+
:param dict search_space_updates: Each method has a default search space of parameter settings, structured as
182+
:code:`{param1:[numerical, values], param2:{categorical, values}, param3:value, ...}` (defined in
183+
:code:`_optimize.py`). The Cartesian product of values are used as initial starting points in optimization.
184+
If left None, the default search space is used, if :code:`{param1:[different,values]}`, these are applied.
185+
:param str metric: either :code:`'rmse'` or :code:`'error_correlation'`, only applies if :code:`dxdt_truth` is given
186+
:param int padding: number of steps to ignore at the beginning and end of the data series, or :code:`'auto'` to ignore
187+
2.5% at each end. Larger value causes the optimization to emphasize the accuracy in the series middle.
190188
:param str opt_method: Optimization technique used by :code:`scipy.minimize`, the workhorse
191189
:param int maxiter: passed down to :code:`scipy.minimize`, maximum iterations
192190
:param bool parallel: whether to use multiple processes to optimize, typically faster for single optimizations.
193-
For experiments, it is a usually a better use of resources to parallelize at that level, meaning
191+
For experiments, it is often a better use of resources to parallelize at that level, meaning
194192
each must run in its own process, since spawned processes are not allowed to further spawn.
195193
:param float huberM: For ground-truth-less situation, if :math:`M < \\infty`, use outlier-robust, Huber-based accuracy
196-
metric in loss function. :math:`M` is in units akin to standard deviation (see :code:`evaluate.robust_rme`),
197-
so transition from quadratic to linear regime for errors lying :math:`>M\\sigma` away from mean error.
194+
metric in objective. :math:`M` is in units akin to standard deviation (see :code:`evaluate.robust_rme`),
195+
so transition from quadratic to linear regime for errors lying :math:`>\\!M\\sigma` away from mean error.
198196
199197
:return: - **opt_params** (dict) -- best parameter settings for the differentation method
200198
- **opt_value** (float) -- lowest value found for objective function

0 commit comments

Comments
 (0)