@@ -33,7 +33,10 @@ def _get_threadlocal_config():
33
33
34
34
35
35
def get_config ():
36
- """Retrieve current values for configuration set by :func:`set_config`.
36
+ """Retrieve the current scikit-learn configuration.
37
+
38
+ This reflects the effective global configurations as established by default upon
39
+ library import, or modified via :func:`set_config` or :func:`config_context`.
37
40
38
41
Returns
39
42
-------
@@ -71,6 +74,15 @@ def set_config(
71
74
):
72
75
"""Set global scikit-learn configuration.
73
76
77
+ These settings control the behaviour of scikit-learn functions during a library
78
+ usage session. Global configuration defaults (as described in the parameter list
79
+ below) take effect when scikit-learn is imported.
80
+
81
+ This function can be used to modify the global scikit-learn configuration at
82
+ runtime. Passing `None` as an argument (the default) leaves the corresponding
83
+ setting unchanged. This allows users to selectively update the global configuration
84
+ values without affecting the others.
85
+
74
86
.. versionadded:: 0.19
75
87
76
88
Parameters
@@ -79,7 +91,7 @@ def set_config(
79
91
If True, validation for finiteness will be skipped,
80
92
saving time, but leading to potential crashes. If
81
93
False, validation for finiteness will be performed,
82
- avoiding error. Global default: False.
94
+ avoiding error. Global default: False.
83
95
84
96
.. versionadded:: 0.19
85
97
@@ -96,20 +108,22 @@ def set_config(
96
108
values will be printed when printing an estimator. For example,
97
109
``print(SVC())`` while True will only print 'SVC()' while the default
98
110
behaviour would be to print 'SVC(C=1.0, cache_size=200, ...)' with
99
- all the non-changed parameters.
111
+ all the non-changed parameters. Global default: True.
100
112
101
113
.. versionadded:: 0.21
114
+ .. versionchanged:: 0.23
115
+ Global default configuration changed from False to True.
102
116
103
117
display : {'text', 'diagram'}, default=None
104
118
If 'diagram', estimators will be displayed as a diagram in a Jupyter
105
119
lab or notebook context. If 'text', estimators will be displayed as
106
- text. Default is 'diagram'.
120
+ text. Global default: 'diagram'.
107
121
108
122
.. versionadded:: 0.23
109
123
110
124
pairwise_dist_chunk_size : int, default=None
111
125
The number of row vectors per chunk for the accelerated pairwise-
112
- distances reduction backend. Default is 256 (suitable for most of
126
+ distances reduction backend. Global default: 256 (suitable for most of
113
127
modern laptops' caches and architectures).
114
128
115
129
Intended for easier benchmarking and testing of scikit-learn internals.
@@ -130,7 +144,7 @@ def set_config(
130
144
131
145
array_api_dispatch : bool, default=None
132
146
Use Array API dispatching when inputs follow the Array API standard.
133
- Default is False.
147
+ Global default: False.
134
148
135
149
See the :ref:`User Guide <array_api>` for more details.
136
150
@@ -147,6 +161,8 @@ def set_config(
147
161
- `"polars"`: Polars output
148
162
- `None`: Transform configuration is unchanged
149
163
164
+ Global default: "default".
165
+
150
166
.. versionadded:: 1.2
151
167
.. versionadded:: 1.4
152
168
`"polars"` option was added.
@@ -161,13 +177,16 @@ def set_config(
161
177
- `False`: Metadata routing is disabled, use the old syntax.
162
178
- `None`: Configuration is unchanged
163
179
180
+ Global default: False.
181
+
164
182
.. versionadded:: 1.3
165
183
166
184
skip_parameter_validation : bool, default=None
167
185
If `True`, disable the validation of the hyper-parameters' types and values in
168
186
the fit method of estimators and for arguments passed to public helper
169
187
functions. It can save time in some situations but can lead to low level
170
188
crashes and exceptions with confusing error messages.
189
+ Global default: False.
171
190
172
191
Note that for data parameters, such as `X` and `y`, only type validation is
173
192
skipped but validation with `check_array` will continue to run.
@@ -225,46 +244,53 @@ def config_context(
225
244
enable_metadata_routing = None ,
226
245
skip_parameter_validation = None ,
227
246
):
228
- """Context manager for global scikit-learn configuration.
247
+ """Context manager to temporarily change the global scikit-learn configuration.
248
+
249
+ This context manager can be used to apply scikit-learn configuration changes within
250
+ the scope of the with statement. Once the context exits, the global configuration is
251
+ restored again.
252
+
253
+ The default global configurations (which take effect when scikit-learn is imported)
254
+ are defined below in the parameter list.
229
255
230
256
Parameters
231
257
----------
232
258
assume_finite : bool, default=None
233
259
If True, validation for finiteness will be skipped,
234
260
saving time, but leading to potential crashes. If
235
261
False, validation for finiteness will be performed,
236
- avoiding error. If None, the existing value won't change.
237
- The default value is False.
262
+ avoiding error. If None, the existing configuration won't change.
263
+ Global default: False.
238
264
239
265
working_memory : int, default=None
240
266
If set, scikit-learn will attempt to limit the size of temporary arrays
241
267
to this number of MiB (per job when parallelised), often saving both
242
268
computation time and memory on expensive operations that can be
243
- performed in chunks. If None, the existing value won't change.
244
- The default value is 1024.
269
+ performed in chunks. If None, the existing configuration won't change.
270
+ Global default: 1024.
245
271
246
272
print_changed_only : bool, default=None
247
273
If True, only the parameters that were set to non-default
248
274
values will be printed when printing an estimator. For example,
249
275
``print(SVC())`` while True will only print 'SVC()', but would print
250
276
'SVC(C=1.0, cache_size=200, ...)' with all the non-changed parameters
251
- when False. If None, the existing value won't change.
252
- The default value is True.
277
+ when False. If None, the existing configuration won't change.
278
+ Global default: True.
253
279
254
280
.. versionchanged:: 0.23
255
- Default changed from False to True.
281
+ Global default configuration changed from False to True.
256
282
257
283
display : {'text', 'diagram'}, default=None
258
284
If 'diagram', estimators will be displayed as a diagram in a Jupyter
259
285
lab or notebook context. If 'text', estimators will be displayed as
260
- text. If None, the existing value won't change.
261
- The default value is 'diagram'.
286
+ text. If None, the existing configuration won't change.
287
+ Global default: 'diagram'.
262
288
263
289
.. versionadded:: 0.23
264
290
265
291
pairwise_dist_chunk_size : int, default=None
266
292
The number of row vectors per chunk for the accelerated pairwise-
267
- distances reduction backend. Default is 256 (suitable for most of
293
+ distances reduction backend. Global default: 256 (suitable for most of
268
294
modern laptops' caches and architectures).
269
295
270
296
Intended for easier benchmarking and testing of scikit-learn internals.
@@ -285,7 +311,7 @@ def config_context(
285
311
286
312
array_api_dispatch : bool, default=None
287
313
Use Array API dispatching when inputs follow the Array API standard.
288
- Default is False.
314
+ Global default: False.
289
315
290
316
See the :ref:`User Guide <array_api>` for more details.
291
317
@@ -302,6 +328,8 @@ def config_context(
302
328
- `"polars"`: Polars output
303
329
- `None`: Transform configuration is unchanged
304
330
331
+ Global default: "default".
332
+
305
333
.. versionadded:: 1.2
306
334
.. versionadded:: 1.4
307
335
`"polars"` option was added.
@@ -316,13 +344,16 @@ def config_context(
316
344
- `False`: Metadata routing is disabled, use the old syntax.
317
345
- `None`: Configuration is unchanged
318
346
347
+ Global default: False.
348
+
319
349
.. versionadded:: 1.3
320
350
321
351
skip_parameter_validation : bool, default=None
322
352
If `True`, disable the validation of the hyper-parameters' types and values in
323
353
the fit method of estimators and for arguments passed to public helper
324
354
functions. It can save time in some situations but can lead to low level
325
355
crashes and exceptions with confusing error messages.
356
+ Global default: False.
326
357
327
358
Note that for data parameters, such as `X` and `y`, only type validation is
328
359
skipped but validation with `check_array` will continue to run.
0 commit comments