fit_regselect_discrete()#
- ParametricROM.fit_regselect_discrete(candidates: list, parameters: list, states: list, inputs: list = None, fit_transformer: bool = True, fit_basis: bool = True, regularizer_factory=None, gridsearch_only: bool = False, num_test_iters: int = 0, stability_margin: float = 5.0, test_cases: list = None, verbose: bool = False)#
Calibrate the fully discrete model to training data, selecting the regularization hyperparameter(s) that minimize the training error while maintaining stability over the testing regime.
This method requires the
model
to be time-continuous and to have asolver
of one of the following types:The
solver.regularizer
is repeatedly adjusted, and the model is recalibrated, until a best regularization is selected.- candidateslist of regularization hyperparameters
Regularization hyperparameters to check. If a single hyperparameter is given, use it as the start of an optimization-based search.
- parameterslist of s (floats or (p,) ndarrays)
Parameter values for which training data are available.
- stateslist of s (n, k_i) ndarrays
State snapshots in the original state space. Each array
states[i]
is the data corresponding to parameter valueparameters[i]
; each columnstates[i][:, j]
is one snapshot. This method assumes the snapshots are sequential, i.e., the model mapsstates[i][:, j]
tostates[i][:, j+1]
.- inputslist of s (m, k_i + num_test_iters) ndarrays
Inputs corresponding to the training data, together with inputs for the testing regime. Only required if the
model
takes external inputs.- fit_transformerbool
If
True
(default), calibrate the preprocessing transformation using thestates
. IfFalse
, assume the transformer is already calibrated.- fit_basisbool
If
True
(default), calibrate the high-to-low dimensional mapping using thestates
. IfFalse
, assume the basis is already calibrated.- regularizer_factorycallable or None
Function mapping regularization hyperparameters to the full regularizer. Specifically,
regularizer_factory(candidates[i])
will be assigned tomodel.solver.regularizer
for eachi
.- gridsearch_onlybool
If
True
, stop after checking all regularizationcandidates
and do not follow up with optimization.- num_test_itersint
Number of iterations after the training data in which to require model stability.
- stability_marginfloat,
Factor by which the reduced states may deviate from the range of the training data without being flagged as unstable.
- test_caseslist of DiscreteRegTest objects
Additional test cases for which the model is required to be stable. See
opinf.utils.DiscreteRegTest
.- verbosebool
If
True
, print information during the regularization selection.
Notes
If there is only one trajectory of training data (s = 1),
states
may be provided as an (n, k) ndarray. In this case, it is assumed thatinputs
(if provided) is a single (m, k) ndarray.