config_context#
- mlquantify.config_context(*, prevalence_return_type=None, prevalence_normalization=None)[source]#
Context manager to temporarily change the global mlquantify configuration.
- Parameters:
- prevalence_return_type{‘dict’, ‘array’}, default=None
If ‘dict’, validate_prevalences returns a dictionary. If ‘array’, validate_prevalences returns a numpy array. If None, the existing configuration won’t change. Global default: ‘dict’.
- prevalence_normalization{‘sum’, ‘l1’, ‘softmax’, ‘mean’, ‘median’, None}, default=None
Default normalization or aggregation strategy for validate_prevalences. If None, the existing configuration won’t change. Global default: ‘mean’.
- Yields:
- None.
See also
set_configSet global mlquantify configuration.
get_configRetrieve current values of the global configuration.
Notes
All settings, not just those presently modified, will be returned to their previous values when the context manager is exited.
Examples
>>> import mlquantify >>> from mlquantify import config_context >>> with config_context(prevalence_return_type='array'): ... mlquantify.get_config()['prevalence_return_type'] 'array' >>> mlquantify.get_config()['prevalence_return_type'] 'dict'