gemseo / mlearning / data_formatters

Hide inherited members

regression_data_formatters module

Data formatters for regression algorithms.

class gemseo.mlearning.data_formatters.regression_data_formatters.RegressionDataFormatters[source]

Bases: SupervisedDataFormatters

Data formatters for regression algorithms.

classmethod format_dict(func)

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

Parameters:

func (Callable[[MLSupervisedAlgo, 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[[MLSupervisedAlgo, DataType, Any, …], DataType]

classmethod format_dict_jacobian(func)[source]

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

Parameters:

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

Returns:

The wrapped func function, callable with either a NumPy data array or a dictionary of numpy data arrays indexed by variables names. The return value will have the same type as the input data.

Return type:

Callable[[MLRegressionAlgo, DataType, Any, …], DataType]

classmethod format_input_output(func)

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

Parameters:

func (Callable[[MLSupervisedAlgo, 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[[MLSupervisedAlgo, DataType, Any, …], DataType]

classmethod format_samples(func)

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

Parameters:

func (Callable[[MLSupervisedAlgo, 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[[MLSupervisedAlgo, ndarray, Any, …], ndarray]

classmethod format_transform(transform_inputs=True, transform_outputs=True)

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[[MLSupervisedAlgo, ndarray, Any, …], ndarray]], Callable[[MLSupervisedAlgo, ndarray, Any, …], ndarray]]

classmethod transform_jacobian(func)[source]

Apply transformation to inputs and inverse transformation to outputs.

Parameters:

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

Returns:

A function evaluating the function func, after transforming its input data and/or before transforming its output data.

Return type:

Callable[[MLRegressionAlgo, ndarray, Any, …], ndarray]