Context manager to temporarily change the global scikit-learn configuration. This context manager can be used to apply scikit-learn configuration changes within the scope of the with statement. Once the context exits, the global configuration is restored again. The default global c
(
*,
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,
sparse_interface=None,
)
| 247 | |
| 248 | @contextmanager |
| 249 | def config_context( |
| 250 | *, |
| 251 | assume_finite=None, |
| 252 | working_memory=None, |
| 253 | print_changed_only=None, |
| 254 | display=None, |
| 255 | pairwise_dist_chunk_size=None, |
| 256 | enable_cython_pairwise_dist=None, |
| 257 | array_api_dispatch=None, |
| 258 | transform_output=None, |
| 259 | enable_metadata_routing=None, |
| 260 | skip_parameter_validation=None, |
| 261 | sparse_interface=None, |
| 262 | ): |
| 263 | """Context manager to temporarily change the global scikit-learn configuration. |
| 264 | |
| 265 | This context manager can be used to apply scikit-learn configuration changes within |
| 266 | the scope of the with statement. Once the context exits, the global configuration is |
| 267 | restored again. |
| 268 | |
| 269 | The default global configurations (which take effect when scikit-learn is imported) |
| 270 | are defined below in the parameter list. |
| 271 | |
| 272 | Parameters |
| 273 | ---------- |
| 274 | assume_finite : bool, default=None |
| 275 | If True, validation for finiteness will be skipped, |
| 276 | saving time, but leading to potential crashes. If |
| 277 | False, validation for finiteness will be performed, |
| 278 | avoiding error. If None, the existing configuration won't change. |
| 279 | Global default: False. |
| 280 | |
| 281 | working_memory : int, default=None |
| 282 | If set, scikit-learn will attempt to limit the size of temporary arrays |
| 283 | to this number of MiB (per job when parallelised), often saving both |
| 284 | computation time and memory on expensive operations that can be |
| 285 | performed in chunks. If None, the existing configuration won't change. |
| 286 | Global default: 1024. |
| 287 | |
| 288 | print_changed_only : bool, default=None |
| 289 | If True, only the parameters that were set to non-default |
| 290 | values will be printed when printing an estimator. For example, |
| 291 | ``print(SVC())`` while True will only print 'SVC()', but would print |
| 292 | 'SVC(C=1.0, cache_size=200, ...)' with all the non-changed parameters |
| 293 | when False. If None, the existing configuration won't change. |
| 294 | Global default: True. |
| 295 | |
| 296 | .. versionchanged:: 0.23 |
| 297 | Global default configuration changed from False to True. |
| 298 | |
| 299 | display : {'text', 'diagram'}, default=None |
| 300 | If 'diagram', estimators will be displayed as a diagram in a Jupyter |
| 301 | lab or notebook context. If 'text', estimators will be displayed as |
| 302 | text. If None, the existing configuration won't change. |
| 303 | Global default: 'diagram'. |
| 304 | |
| 305 | .. versionadded:: 0.23 |
| 306 |
searching dependent graphs…