deepcave.utils.symbolic_regression

# Symbolic Regression

This module provides utilities for running symbolic regression with gplearn.

Functions

convert_symb(symb[, n_decimals, hp_names])

Convert a fitted symbolic regression to a simplified and rounded mathematical expression.

exp(x)

Get a safe exp function with a maximum value of 100000 to avoid overflow.

get_function_set()

Get a function set for symbolic regression with gplearn.

deepcave.utils.symbolic_regression.convert_symb(symb, n_decimals=None, hp_names=None)[source]

Convert a fitted symbolic regression to a simplified and rounded mathematical expression.

Warning: eval is used in this function, thus it should not be used on unsanitized input (see https://docs.sympy.org/latest/modules/core.html?highlight=eval#module-sympy.core.sympify).

Parameters:
  • symb (SymbolicRegressor) – Fitted symbolic regressor to find a simplified expression for.

  • n_decimals (Optional[int]) – If set, round floats in the expression to this number of decimals.

  • hp_names (Optional[List[str]]) – If set, replace X0 and X1 in the expression by the names given.

Returns:

Converted mathematical expression.

Return type:

str

deepcave.utils.symbolic_regression.exp(x)[source]

Get a safe exp function with a maximum value of 100000 to avoid overflow.

Parameters:

x (Union[float, np.ndarray]) – The value to calculate the exponential of.

Returns:

The safe exponential of x.

Return type:

Union[float, np.ndarray]

deepcave.utils.symbolic_regression.get_function_set()[source]

Get a function set for symbolic regression with gplearn.

Returns:

List of functions to use in symbolic regression.

Return type:

List[Union[str, _Function]]