Parallel evaluation#

Collection of functions that enable parallelism.

Functions:

arrange_in_parallel

Arrange the given algorithms to run (embarrassingly) parallel.

run_in_parallel

Run the given algorithms (embarrassingly) parallel.

arrange_in_parallel(algos, data, num_cpus=None)#

Arrange the given algorithms to run (embarrassingly) parallel.

Parameters
  • algos (Sequence[ethicml.evaluators.parallelism.Algorithm[ethicml.evaluators.parallelism._RT]]) – list of tuples consisting of a run_async function of an algorithm and a name

  • data (Sequence[ethicml.utility.data_structures.TrainTestPair]) – list of pairs of data tuples (train and test)

  • num_cpus (Optional[int]) – number of CPUs to use. None means all.

Returns

list of the results

Return type

List[List[ethicml.evaluators.parallelism._RT]]

run_in_parallel(algos: Sequence[ethicml.algorithms.inprocess.in_algorithm.InAlgorithm], data: Sequence[ethicml.utility.data_structures.TrainTestPair], num_cpus: int = 0) List[List[ethicml.utility.data_structures.Prediction]]#
run_in_parallel(algos: Sequence[ethicml.algorithms.preprocess.pre_algorithm.PreAlgorithm], data: Sequence[ethicml.utility.data_structures.TrainTestPair], num_cpus: int = 0) List[List[Tuple[ethicml.utility.data_structures.DataTuple, ethicml.utility.data_structures.TestTuple]]]

Run the given algorithms (embarrassingly) parallel.

Parameters
  • algos – list of algorithms

  • data – list of pairs of data tuples (train and test)

  • num_cpus – how many processes can run in parallel at most. if zero (or negative), then there is no maximum

Returns

list of the results