gemseo / mlearning / regression

# rbf module¶

## RBF 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) + ... + w_nK(\|x-x_n\|;\epsilon)$

and the coefficients $$(w_1, w_2, ..., w_n)$$ are estimated by least square regression.

### Dependence¶

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

class gemseo.mlearning.regression.rbf.RBFRegression(data, transformer=None, input_names=None, output_names=None, function='multiquadric', der_function=None, epsilon=None, **parameters)[source]

Regression based on radial basis functions.

Constructor.

Parameters
• data (Dataset) – learning dataset

• transformer (dict(str)) – transformation strategy for data groups. If None, do not transform data. Default: None.

• input_names (list(str)) – names of the input variables. Default: None.

• output_names (list(str)) – names of the output variables. Default: None.

• der_function (callable) – derivative of radial basis function, only to be provided if function is callable and not str. The der_function should take three arguments (input_data, norm_input_data, eps). For a RBF of the form function($$r$$), der_function($$x$$, $$|x|$$, $$\epsilon$$) should return $$\epsilon^{-1} x/|x| f'(|x|/\epsilon)$$. Default: None.

• epsilon (float) – Adjustable constant for Gaussian or multiquadrics functions. Default: None.

• parameters – other RBF parameters (sklearn).

ABBR = 'RBF'
AVAILABLE_FUNCTIONS = ['multiquadric', 'inverse_multiquadric', 'gaussian', 'linear', 'cubic', 'quintic', 'thin_plate']
CUBIC = 'cubic'
EUCLIDEAN = 'euclidean'
GAUSSIAN = 'gaussian'
INVERSE_MULTIQUADRIC = 'inverse_multiquadric'
LIBRARY = 'scipy'
LINEAR = 'linear'
MULTIQUADRIC = 'multiquadric'
QUINTIC = 'quintic'
class RBFDerivatives[source]

Bases: object

Derivatives of functions used in RBFRegression.

For a 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$$.

TOL = 2.220446049250313e-16
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 (float) – Input variable (vector) $$x$$.

• norm_input_data (float) – Norm of input variable $$|x|$$.

Returns

Derivative of the function.

Return type

float

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

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

Parameters
• input_data (float) – Input variable (vector).

• norm_input_data (float) – Norm of input variable.

Returns

Derivative of the function.

Return type

float

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

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

Parameters
• input_data (float) – Input variable (vector).

• norm_input_data (float) – Norm of input variable.

Returns

Derivative of the function.

Return type

float

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

Compute derivative w.r.t. $$x$$ of the function $$f(r) = r$$. If $$x=0$$, return 0 (determined up to a tolerance).

Parameters
• input_data (float) – Input variable (vector).

• norm_input_data (float) – Norm of input variable.

Returns

Derivative of the function.

Return type

float

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

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

Parameters
• input_data (float) – Input variable (vector).

• norm_input_data (float) – Norm of input variable.

Returns

Derivative of the function.

Return type

float

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 (float) – Input variable (vector).

• norm_input_data (float) – Norm of input variable.

Returns

Derivative of the function.

Return type

float

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

Compute derivative w.r.t. $$x$$ of the function $$f(r) = r^2 \log(r)$$. If $$x=0$$, return 0 (determined up to a tolerance).

Parameters
• input_data (float) – Input variable (vector).

• norm_input_data (float) – Norm of input variable.

Returns

Derivative of the function.

Return type

float

THIN_PLATE = 'thin_plate'
property function

Kernel function name.

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

return: Name of kernel function. rtype: str

classmethod get_available_functions()[source]

Get available RBFs.

load_algo(directory)[source]