sklearn.utils.joblib
.parallel_backend¶
-
sklearn.utils.joblib.
parallel_backend
(backend, n_jobs=-1, **backend_params)[source]¶ Change the default backend used by Parallel inside a with block.
If
backend
is a string it must match a previously registered implementation using theregister_parallel_backend
function.Alternatively backend can be passed directly as an instance.
By default all available workers will be used (
n_jobs=-1
) unless the caller passes an explicit value for then_jobs
parameter.This is an alternative to passing a
backend='backend_name'
argument to theParallel
class constructor. It is particularly useful when calling into library code that uses joblib internally but does not expose the backend argument in its own API.>>> from operator import neg >>> with parallel_backend('threading'): ... print(Parallel()(delayed(neg)(i + 1) for i in range(5))) ... [-1, -2, -3, -4, -5]
Warning: this function is experimental and subject to change in a future version of joblib.
New in version 0.10.