validate_params¶
-
gtda.utils.
validate_params
(parameters, references, exclude=None)[source]¶ Function to automate the validation of (hyper)parameters.
- Parameters
parameters (dict, required) – Dictionary in which the keys parameter names (as strings) and the corresponding values are parameter values. Unless exclude (see below) contains some of the keys in this dictionary, all parameters are checked against references.
references (dict, required) –
Dictionary in which the keys are parameter names (as strings). Let
name
andparameter
denote a key-value pair in parameters. Sincename
should also be a key in references, letreference
be the corresponding value there. Then,reference
must be a dictionary containing any of the following keys:'type'
, mapping to a class or tuple of classes.parameter
is checked to be an instance of this class or tuple of classes.'in'
, mapping to a dictionary, when the value of'type'
is not one oflist
,tuple
,numpy.ndarray
ordict
. Lettingref_in
denote that dictionary, the following check is performed:parameter in ref_in
.'of'
, mapping to a dictionary, when the value of'type'
is one oflist
,tuple
,numpy.ndarray
ordict
. Letref_of
denote that dictionary. Then:If
reference['type'] == dict
– meaning thatparameter
should be a dictionary –ref_of
should have a similar structure as references, andvalidate_params
is called recursively on(parameter, ref_of)
.Otherwise,
ref_of
should have a similar structure asreference
and each entry inparameter
is checked to satisfy the constraints inref_of
.
'other'
, which should map to a callable defining custom checks onparameter
.
exclude (list of str, or None, optional, default:
None
) – List of parameter names which are among the keys in parameters but should be excluded from validation.None
is equivalent to passing the empty list.