Parallel#

class sklearn.utils.parallel.Parallel(n_jobs=default(None), backend=default(None), return_as='list', verbose=default(0), timeout=None, pre_dispatch='2 * n_jobs', batch_size='auto', temp_folder=default(None), max_nbytes=default('1M'), mmap_mode=default('r'), prefer=default(None), require=default(None))#

调整 joblib.Parallel 以传播 scikit-learn 配置。

这个 joblib.Parallel 的子类确保在并行任务执行期间,scikit-learn 的活动配置(线程本地)被传播到并行工作线程。

API 没有变化,你可以参考 joblib.Parallel 文档获取更多细节。

Added in version 1.3.

__call__(iterable)#

分派任务并返回结果。

Parameters:
iterableiterable

包含 (delayed_function, args, kwargs) 元组的可迭代对象,这些元组将被消费。

Returns:
resultslist

任务结果的列表。

dispatch_next()#

Dispatch more data for parallel processing

This method is meant to be called concurrently by the multiprocessing callback. We rely on the thread-safety of dispatch_one_batch to protect against concurrent consumption of the unprotected iterator.

dispatch_one_batch(iterator)#

Prefetch the tasks for the next batch and dispatch them.

The effective size of the batch is computed here. If there are no more jobs to dispatch, return False, else return True.

The iterator consumption and dispatching is protected by the same lock so calling this function should be thread safe.

format(obj, indent=0)#

Return the formatted representation of the object.

print_progress()#

Display the process of the parallel execution only a fraction of time, controlled by self.verbose.