kwcoco.util package¶
Submodules¶
Module contents¶
mkinit ~/code/kwcoco/kwcoco/util/__init__.py -w
-
class
kwcoco.util.
Executor
(mode='thread', max_workers=0)[source]¶ Bases:
object
Wrapper around a specific executor.
Abstracts Serial, Thread, and Process Executor via arguments.
Parameters: - mode (str, default=’thread’) – either thread, serial, or process
- max_workers (int, default=0) – number of workers. If 0, serial is forced.
-
class
kwcoco.util.
SerialExecutor
[source]¶ Bases:
object
Implements the concurrent.futures API around a single-threaded backend
Example
>>> with SerialExecutor() as executor: >>> futures = [] >>> for i in range(100): >>> f = executor.submit(lambda x: x + 1, i) >>> futures.append(f) >>> for f in concurrent.futures.as_completed(futures): >>> assert f.result() > 0 >>> for i, f in enumerate(futures): >>> assert i + 1 == f.result()
-
class
kwcoco.util.
StratifiedGroupKFold
(n_splits=3, shuffle=False, random_state=None)[source]¶ Bases:
sklearn.model_selection._split._BaseKFold
Stratified K-Folds cross-validator with Grouping
Provides train/test indices to split data in train/test sets.
This cross-validation object is a variation of GroupKFold that returns stratified folds. The folds are made by preserving the percentage of samples for each class.
Read more in the User Guide.
Parameters: n_splits (int, default=3) – Number of folds. Must be at least 2.