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
nameandparameterdenote a key-value pair in parameters. Sincenameshould also be a key in references, letreferencebe the corresponding value there. Then,referencemust be a dictionary containing any of the following keys:'type', mapping to a class or tuple of classes.parameteris 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.ndarrayordict. Lettingref_indenote 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.ndarrayordict. Letref_ofdenote that dictionary. Then:If
reference['type'] == dict– meaning thatparametershould be a dictionary –ref_ofshould have a similar structure as references, andvalidate_paramsis called recursively on(parameter, ref_of).Otherwise,
ref_ofshould have a similar structure asreferenceand each entry inparameteris 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.Noneis equivalent to passing the empty list.