Skip to content

ParallelModel class#

This model is created together with the RandomForest. It is later passed to the Predictor class as input to the static method forest_predictor.

ParallelModel #

ParallelModel(n_jobs=-1)

Class used to parallelize

Parameters:

Name Type Description Default
n_jobs int

The number of processes used to fit, and predict for the forest, -1 uses all available proccesors

Number of cpu cores

apply #

apply(function, n_iterations, **kwargs)

Applies the function n_iterations number of times and returns the result of the n_iterations where element i corresponds to the i'th return value of function.

Parameters:

Name Type Description Default
function Callable

Function to apply

required
n_iterations int

Number of applications of function

required

Returns:

Type Description
Iterable

Function applied n_iterations number of times

async_apply #

async_apply(function, n_iterations, **kwargs)

Applies the function n_iterations number of times and returns the result of the n_iterations in an unknown order.

Parameters:

Name Type Description Default
function Callable

Function to apply

required
n_iterations int

Number of applications of function

required

Returns:

Type Description
Iterable

Function applied n_iterations number of times

async_map #

async_map(function, map_input, **kwargs)

Asynchronously applies the function to the map_input passing along any kwargs given to the function.

Parameters:

Name Type Description Default
function Callable

Function to apply Asynchronously

required
map_input Iterable

Iterable input which can be passed to the function

required

Returns:

Type Description
Iterable

Returns the result of running function on all elements of map_input

async_starmap #

async_starmap(function, map_input, **kwargs)

Asynchronously apply function to map_input, where map_input might be a list of tuple elements. Passes along any kwargs to function.

Parameters:

Name Type Description Default
function Callable

Function to apply to each element of map_input

required
map_input Iterable

Iterable input which might be a tuple, that can be passed to function

required

Returns:

Type Description
Iterable

Returns the result of applying function to each element of map_input

map #

map(function, map_input, **kwargs)

Maps the function with map_input. Similair to async_map, but instead guarantees that the first element returned is the result of the first map_input. Passes along any kwargs to function.

Parameters:

Name Type Description Default
function Callable

function to apply

required
map_input Iterable

Iterable input which can be passed to the function

required

Returns:

Type Description
Iterable

Returns in order the results of function applied to map_input

starmap #

starmap(function, map_input, **kwargs)

Applies function to each elemetn of map_input but guarantees that element i of return value is the result of function applied to element i of map_input. Can be a list of tuples as opposed to just map. Passes along any kwargs to function.

Parameters:

Name Type Description Default
function Callable

Function to apply to each element of map_input

required
map_input Iterable

Iterable input which might be a tuple, that can be passed to function

required

Returns:

Type Description
Iterable

Returns the result of applying function to each element of map_input