gemseo_mlearning / adaptive / distributions

kriging_distribution module

Distribution related to a Kriging-like regression model.

A Kriging-like regression model predicts both output mean and standard deviation while a standard regression model predicts only the output value.

class gemseo_mlearning.adaptive.distributions.kriging_distribution.KrigingDistribution(algo)[source]

Bases: MLRegressorDistribution

Distribution related to a Kriging-like regression model.

The regression model must be a Kriging-like regression model computing both mean and standard deviation.

# noqa: D205 D212 D415

Parameters:

algo (MLRegressionAlgo) – A regression model.

change_learning_set(learning_set)

Re-train the machine learning algorithm relying on the initial learning set.

Parameters:

learning_set (Dataset) – The new learning set.

Return type:

None

compute_confidence_interval(input_data, level=0.95)[source]

Predict the lower bounds and upper bounds from input data.

The user can specify the input data either as a NumPy array, e.g. array([1., 2., 3.]) or as a dictionary, e.g. {'a': array([1.]), 'b': array([2., 3.])}.

The output data type will be consistent with the input data type.

Parameters:
  • input_data (DataType) – The input data.

  • level (float) –

    A quantile level.

    By default it is set to 0.95.

Returns:

The lower and upper bound values.

Return type:

tuple[dict[str, ndarray], dict[str, ndarray], tuple[ndarray, ndarray]] | None

compute_expected_improvement(input_data, *args, **kwargs)

Evaluate ‘predict’ with either array or dictionary-based input data.

Firstly, the pre-processing stage converts the input data to a NumPy data array, if these data are expressed as a dictionary of NumPy data arrays.

Then, the processing evaluates the function ‘predict’ from this NumPy input data array.

Lastly, the post-processing transforms the output data to a dictionary of output NumPy data array if the input data were passed as a dictionary of NumPy data arrays.

Parameters:
  • input_data (Union[ndarray, Mapping[str, ndarray]]) – The input data.

  • *args – The positional arguments of the function ‘predict’.

  • **kwargs – The keyword arguments of the function ‘predict’.

Returns:

The output data with the same type as the input one.

Return type:

Union[ndarray, Mapping[str, ndarray]]

compute_mean(input_data, *args, **kwargs)

Evaluate ‘predict’ with either array or dictionary-based input data.

Firstly, the pre-processing stage converts the input data to a NumPy data array, if these data are expressed as a dictionary of NumPy data arrays.

Then, the processing evaluates the function ‘predict’ from this NumPy input data array.

Lastly, the post-processing transforms the output data to a dictionary of output NumPy data array if the input data were passed as a dictionary of NumPy data arrays.

Parameters:
  • input_data (Union[ndarray, Mapping[str, ndarray]]) – The input data.

  • *args – The positional arguments of the function ‘predict’.

  • **kwargs – The keyword arguments of the function ‘predict’.

Returns:

The output data with the same type as the input one.

Return type:

Union[ndarray, Mapping[str, ndarray]]

compute_standard_deviation(input_data, *args, **kwargs)

Evaluate ‘predict’ with either array or dictionary-based input data.

Firstly, the pre-processing stage converts the input data to a NumPy data array, if these data are expressed as a dictionary of NumPy data arrays.

Then, the processing evaluates the function ‘predict’ from this NumPy input data array.

Lastly, the post-processing transforms the output data to a dictionary of output NumPy data array if the input data were passed as a dictionary of NumPy data arrays.

Parameters:
  • input_data (Union[ndarray, Mapping[str, ndarray]]) – The input data.

  • *args – The positional arguments of the function ‘predict’.

  • **kwargs – The keyword arguments of the function ‘predict’.

Returns:

The output data with the same type as the input one.

Return type:

Union[ndarray, Mapping[str, ndarray]]

compute_variance(input_data, *args, **kwargs)

Evaluate ‘predict’ with either array or dictionary-based input data.

Firstly, the pre-processing stage converts the input data to a NumPy data array, if these data are expressed as a dictionary of NumPy data arrays.

Then, the processing evaluates the function ‘predict’ from this NumPy input data array.

Lastly, the post-processing transforms the output data to a dictionary of output NumPy data array if the input data were passed as a dictionary of NumPy data arrays.

Parameters:
  • input_data (Union[ndarray, Mapping[str, ndarray]]) – The input data.

  • *args – The positional arguments of the function ‘predict’.

  • **kwargs – The keyword arguments of the function ‘predict’.

Returns:

The output data with the same type as the input one.

Return type:

Union[ndarray, Mapping[str, ndarray]]

learn(samples=None)

Train the machine learning algorithm from the learning dataset.

Parameters:

samples (list[int] | None) – The indices of the learning samples. If None, use the whole learning dataset

Return type:

None

predict(input_data)

Predict the output of the original machine learning algorithm.

The user can specify the input data either as a NumPy array, e.g. array([1., 2., 3.]) or as a dictionary, e.g. {'a': array([1.]), 'b': array([2., 3.])}.

The output data type will be consistent with the input data type.

Parameters:

input_data (Union[ndarray, Mapping[str, ndarray]]) – The input data.

Returns:

The predicted output data.

Return type:

Union[ndarray, Mapping[str, ndarray]]

algo: MLRegressionAlgo

The regression model.

property input_names: list[str]

The names of the original machine learning algorithm inputs.

property learning_set: Dataset

The learning dataset used by the original machine learning algorithm.

property output_dimension: int

The dimension of the machine learning output space.

property output_names: list[str]

The names of the original machine learning algorithm outputs.