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=, , , ,
Set global scikit-learn configuration.
These settings control the behaviour of scikit-learn functions during a library usage session. Global configuration defaults (as described in the parameter list below) take effect when scikit-learn is imported.
This function can be used to modify the global scikit-learn configuration at
runtime. Passing None as an argument (the default) leaves the corresponding
setting unchanged. This allows users to selectively update the global configuration
values without affecting the others.
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.
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.
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. Global default: True.
If ‘diagram’, estimators will be displayed as a diagram in a Jupyter lab or notebook context. If ‘text’, estimators will be displayed as text. Global default: ‘diagram’.
The number of row vectors per chunk for the accelerated pairwise- distances reduction backend. Global default: 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.
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.
Use Array API dispatching when inputs follow the Array API standard. Global default: False.
See the User Guide for more details.
Configure output of transform and fit_transform.
Refer to the user guide for more details and 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
Global default: “default”.
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
Global default: False.
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.
Global default: False.
Note that for data parameters, such as X and y, only type validation is
skipped but validation with check_array will continue to run.
The sparse interface used for every sparse object that scikit-learn produces, e.g., function returns, estimator attributes, estimator properties, etc.
"sparray": Return sparse as SciPy sparse array
"spmatrix": Return sparse as SciPy sparse matrix
>>> from sklearn import set_config
>>> set_config(display='diagram')
Developing Estimators Compliant with Metadata Routing
Post-tuning the decision threshold for cost-sensitive learning
Added in version 1.2.