gemseo / mlearning / data_formatters

Hide inherited members

supervised_data_formatters module

Data formatters for supervised machine learning algorithms.

class gemseo.mlearning.data_formatters.supervised_data_formatters.SupervisedDataFormatters[source]

Bases: BaseDataFormatters

Data formatters for supervised machine learning algorithms.

classmethod format_dict(func)[source]

Make an array-based function be called with a dictionary of NumPy arrays.

Parameters:

func (Callable[[BaseMLSupervisedAlgo, ndarray, Any, ...], ndarray]) – The function to be called; it takes a NumPy array in input and returns a NumPy array.

Returns:

A function making the function func work with either a NumPy data array or a dictionary of NumPy data arrays indexed by variables names. The evaluation will have the same type as the input data.

Return type:

Callable[[BaseMLSupervisedAlgo, DataType, Any, …], DataType]

classmethod format_input_output(func)[source]

Make a function robust to type, array shape and data transformation.

Parameters:

func (Callable[[BaseMLSupervisedAlgo, ndarray, Any, ...], ndarray]) – The function of interest to be called.

Returns:

A function calling the function of interest func, while guaranteeing consistency in terms of data type and array shape, and applying input and/or output data transformation if required.

Return type:

Callable[[BaseMLSupervisedAlgo, DataType, Any, …], DataType]

classmethod format_samples(func)[source]

Make a 2D NumPy array-based function work with 1D NumPy array.

Parameters:

func (Callable[[BaseMLSupervisedAlgo, ndarray, Any, ...], ndarray]) – The function to be called; it takes a 2D NumPy array in input and returns a 2D NumPy array. The first dimension represents the samples while the second one represents the components of the variables.

Returns:

A function making the function func work with either a 1D NumPy array or a 2D NumPy array. The evaluation will have the same dimension as the input data.

Return type:

Callable[[BaseMLSupervisedAlgo, ndarray, Any, …], ndarray]

classmethod format_transform(transform_inputs=True, transform_outputs=True)[source]

Force a function to transform its input and/or output variables.

Parameters:
  • transform_inputs (bool) –

    Whether to transform the input variables.

    By default it is set to True.

  • transform_outputs (bool) –

    Whether to transform the output variables.

    By default it is set to True.

Returns:

A function evaluating a function of interest, after transforming its input data and/or before transforming its output data.

Return type:

Callable[[Callable[[BaseMLSupervisedAlgo, ndarray, Any, …], ndarray]], Callable[[BaseMLSupervisedAlgo, ndarray, Any, …], ndarray]]