sklearn.set_config#

sklearn.set_config(assume_finite=None, working_memory=None, print_changed_only=None, display=None, pairwise_dist_chunk_size=None, enable_cython_pairwise_dist=None, array_api_dispatch=None, transform_output=None, enable_metadata_routing=None, skip_parameter_validation=None)[source]#

Set global scikit-learn configuration.

New in version 0.19.

Parameters:
assume_finitebool, default=None

If True, validation for finiteness will be skipped, saving time, but leading to potential crashes. If False, validation for finiteness will be performed, avoiding error. Global default: False.

New in version 0.19.

working_memoryint, default=None

If set, scikit-learn will attempt to limit the size of temporary arrays to this number of MiB (per job when parallelised), often saving both computation time and memory on expensive operations that can be performed in chunks. Global default: 1024.

New in version 0.20.

print_changed_onlybool, default=None

If True, only the parameters that were set to non-default values will be printed when printing an estimator. For example, print(SVC()) while True will only print ‘SVC()’ while the default behaviour would be to print ‘SVC(C=1.0, cache_size=200, …)’ with all the non-changed parameters.

New in version 0.21.

display{‘text’, ‘diagram’}, default=None

If ‘diagram’, estimators will be displayed as a diagram in a Jupyter lab or notebook context. If ‘text’, estimators will be displayed as text. Default is ‘diagram’.

New in version 0.23.

pairwise_dist_chunk_sizeint, default=None

The number of row vectors per chunk for the accelerated pairwise- distances reduction backend. Default is 256 (suitable for most of modern laptops’ caches and architectures).

Intended for easier benchmarking and testing of scikit-learn internals. End users are not expected to benefit from customizing this configuration setting.

New in version 1.1.

enable_cython_pairwise_distbool, default=None

Use the accelerated pairwise-distances reduction backend when possible. Global default: True.

Intended for easier benchmarking and testing of scikit-learn internals. End users are not expected to benefit from customizing this configuration setting.

New in version 1.1.

array_api_dispatchbool, default=None

Use Array API dispatching when inputs follow the Array API standard. Default is False.

See the User Guide for more details.

New in version 1.2.

transform_outputstr, default=None

Configure output of transform and fit_transform.

See Introducing the set_output API for an example on how to use the API.

  • "default": Default output format of a transformer

  • "pandas": DataFrame output

  • "polars": Polars output

  • None: Transform configuration is unchanged

New in version 1.2.

New in version 1.4: "polars" option was added.

enable_metadata_routingbool, default=None

Enable metadata routing. By default this feature is disabled.

Refer to metadata routing user guide for more details.

  • True: Metadata routing is enabled

  • False: Metadata routing is disabled, use the old syntax.

  • None: Configuration is unchanged

New in version 1.3.

skip_parameter_validationbool, default=None

If True, disable the validation of the hyper-parameters’ types and values in the fit method of estimators and for arguments passed to public helper functions. It can save time in some situations but can lead to low level crashes and exceptions with confusing error messages.

Note that for data parameters, such as X and y, only type validation is skipped but validation with check_array will continue to run.

New in version 1.3.

See also

config_context

Context manager for global scikit-learn configuration.

get_config

Retrieve current values of the global configuration.

Examples

>>> from sklearn import set_config
>>> set_config(display='diagram')  

Examples using sklearn.set_config#

Release Highlights for scikit-learn 1.4

Release Highlights for scikit-learn 1.4

Release Highlights for scikit-learn 0.23

Release Highlights for scikit-learn 0.23

Displaying Pipelines

Displaying Pipelines

Introducing the set_output API

Introducing the set_output API

Metadata Routing

Metadata Routing

Target Encoder’s Internal Cross fitting

Target Encoder's Internal Cross fitting