gemseo.mlearning.regression.algos.rbf module#

The RBF network for regression.

The radial basis function surrogate discipline expresses the model output as a weighted sum of kernel functions centered on the learning input data:

\[y = w_1K(\|x-x_1\|;\epsilon) + w_2K(\|x-x_2\|;\epsilon) + \ldots + w_nK(\|x-x_n\|;\epsilon)\]

and the coefficients \((w_1, w_2, \ldots, w_n)\) are estimated by least squares minimization.

Dependence#

The RBF model relies on the Rbf class of the scipy library.

class RBFRegressor(data, settings_model=None, **settings)[source]#

Bases: BaseRegressor

Regression based on radial basis functions (RBFs).

This model relies on the SciPy class scipy.interpolate.Rbf.

Parameters:
  • data (Dataset) -- The learning dataset.

  • settings_model (BaseMLAlgoSettings | None) -- The machine learning algorithm settings as a Pydantic model. If None, use **settings.

  • **settings (Any) -- The machine learning algorithm settings. These arguments are ignored when settings_model is not None.

Raises:

ValueError -- When both the variable and the group it belongs to have a transformer.

class RBFDerivatives[source]#

Bases: object

Derivatives of functions used in RBFRegressor.

For an RBF of the form \(f(r)\), \(r\) scalar, the derivative functions are defined by \(d(f(r))/dx\), with \(r=|x|/\epsilon\). The functions are thus defined by \(df/dx = \epsilon^{-1} x/|x| f'(|x|/\epsilon)\). This convention is chosen to avoid division by \(|x|\) when the terms may be cancelled out, as \(f'(r)\) often has a term in \(r\).

classmethod der_cubic(input_data, norm_input_data, eps)[source]#

Compute derivative w.r.t. \(x\) of the function \(f(r) = r^3\).

Parameters:
  • input_data (RealArray) -- The 1D input data.

  • norm_input_data (float) -- The norm of the input variable.

  • eps (float) -- The correlation length.

Returns:

The derivative of the function.

Return type:

RealArray

classmethod der_gaussian(input_data, norm_input_data, eps)[source]#

Compute derivative of \(f(r)=\exp(-r^2)\) w.r.t. \(x\).

Parameters:
  • input_data (RealArray) -- The 1D input data.

  • norm_input_data (float) -- The norm of the input variable.

  • eps (float) -- The correlation length.

Returns:

The derivative of the function.

Return type:

RealArray

classmethod der_inverse_multiquadric(input_data, norm_input_data, eps)[source]#

Compute derivative of \(f(r)=1/\sqrt{r^2 + 1}\) w.r.t. \(x\).

Parameters:
  • input_data (RealArray) -- The 1D input data.

  • norm_input_data (float) -- The norm of the input variable.

  • eps (float) -- The correlation length.

Returns:

The derivative of the function.

Return type:

RealArray

classmethod der_linear(input_data, norm_input_data, eps)[source]#

Compute derivative of \(f(r)=r\) w.r.t. \(x\).

If \(x=0\), return 0 (determined up to a tolerance).

Parameters:
  • input_data (RealArray) -- The 1D input data.

  • norm_input_data (float) -- The norm of the input variable.

  • eps (float) -- The correlation length.

Returns:

The derivative of the function.

Return type:

RealArray

classmethod der_multiquadric(input_data, norm_input_data, eps)[source]#

Compute derivative of \(f(r) = \sqrt{r^2 + 1}\) w.r.t. \(x\).

Parameters:
  • input_data (RealArray) -- The 1D input data.

  • norm_input_data (float) -- The norm of the input variable.

  • eps (float) -- The correlation length.

Returns:

The derivative of the function.

Return type:

RealArray

classmethod der_quintic(input_data, norm_input_data, eps)[source]#

Compute derivative w.r.t. \(x\) of the function \(f(r) = r^5\).

Parameters:
  • input_data (RealArray) -- The 1D input data.

  • norm_input_data (float) -- The norm of the input variable.

  • eps (float) -- The correlation length.

Returns:

The derivative of the function.

Return type:

RealArray

classmethod der_thin_plate(input_data, norm_input_data, eps)[source]#

Compute derivative of \(f(r) = r^2\log(r)\) w.r.t. \(x\).

If \(x=0\), return 0 (determined up to a tolerance).

Parameters:
  • input_data (RealArray) -- The 1D input data.

  • norm_input_data (float) -- The norm of the input variable.

  • eps (float) -- The correlation length.

Returns:

The derivative of the function.

Return type:

RealArray

TOL = 2.220446049250313e-16#
Settings#

alias of RBFRegressor_Settings

EUCLIDEAN: Final[str] = 'euclidean'#
LIBRARY: ClassVar[str] = 'SciPy'#

The name of the library of the wrapped machine learning algorithm.

SHORT_ALGO_NAME: ClassVar[str] = 'RBF'#

The short name of the machine learning algorithm, often an acronym.

Typically used for composite names, e.g. f"{algo.SHORT_ALGO_NAME}_{dataset.name}" or f"{algo.SHORT_ALGO_NAME}_{discipline.name}".

der_function: Callable[[RealArray], RealArray]#

The derivative of the radial basis function.

property function: str#

The name of the kernel function.

The name is possibly different from self.parameters['function'], as it is mapped (scipy). Examples:

'inverse' -> 'inverse_multiquadric' 'InverSE MULtiQuadRIC' -> 'inverse_multiquadric'

y_average: RealArray#

The mean of the learning output data.