Basis¶
Fourier¶
-
class
mushroom_rl.features.basis.fourier.
FourierBasis
(low, delta, c, dimensions=None)[source]¶ Bases:
object
Class implementing Fourier basis functions. The value of the feature is computed using the formula:
\[\sum \cos{\pi(X - m)/\Delta c}\]where X is the input, m is the vector of the minumum input values (for each dimensions) , Delta is the vector of maximum
-
__init__
(low, delta, c, dimensions=None)[source]¶ Constructor.
Parameters: - low (np.ndarray) – vector of minimum values of the input variables;
- delta (np.ndarray) – vector of the maximum difference between two values of the input variables, i.e. delta = high - low;
- c (np.ndarray) – vector of weights for the state variables;
- dimensions (list, None) – list of the dimensions of the input to be considered by the feature.
-
static
generate
(low, high, n, dimensions=None)[source]¶ Factory method to build a set of fourier basis.
Parameters: - low (np.ndarray) – vector of minimum values of the input variables;
- high (np.ndarray) – vector of maximum values of the input variables;
- n (int) – number of harmonics to consider for each state variable
- dimensions (list, None) – list of the dimensions of the input to be considered by the features.
Returns: The list of the generated fourier basis functions.
-
Gaussian RBF¶
-
class
mushroom_rl.features.basis.gaussian_rbf.
GaussianRBF
(mean, scale, dimensions=None)[source]¶ Bases:
object
Class implementing Gaussian radial basis functions. The value of the feature is computed using the formula:
\[\sum \dfrac{(X_i - \mu_i)^2}{\sigma_i}\]where X is the input, mu is the mean vector and sigma is the scale parameter vector.
-
__init__
(mean, scale, dimensions=None)[source]¶ Constructor.
Parameters: - mean (np.ndarray) – the mean vector of the feature;
- scale (np.ndarray) – the scale vector of the feature;
- dimensions (list, None) – list of the dimensions of the input to be
considered by the feature. The number of dimensions must match
the dimensionality of
mean
andscale
.
-
static
generate
(n_centers, low, high, dimensions=None)[source]¶ Factory method to build uniformly spaced gaussian radial basis functions with a 25% overlap.
Parameters: - n_centers (list) – list of the number of radial basis functions to be used for each dimension.
- low (np.ndarray) – lowest value for each dimension;
- high (np.ndarray) – highest value for each dimension;
- dimensions (list, None) – list of the dimensions of the input to be
considered by the feature. The number of dimensions must match
the number of elements in
n_centers
andlow
.
Returns: The list of the generated radial basis functions.
-
Polynomial¶
-
class
mushroom_rl.features.basis.polynomial.
PolynomialBasis
(dimensions=None, degrees=None)[source]¶ Bases:
object
Class implementing polynomial basis functions. The value of the feature is computed using the formula:
\[\prod X_i^{d_i}\]where X is the input and d is the vector of the exponents of the polynomial.
-
__init__
(dimensions=None, degrees=None)[source]¶ Constructor. If both parameters are None, the constant feature is built.
Parameters: - dimensions (list, None) – list of the dimensions of the input to be considered by the feature;
- degrees (list, None) – list of the degrees of each dimension to be
considered by the feature. It must match the number of elements
of
dimensions
.
-
static
_compute_exponents
(order, n_variables)[source]¶ Find the exponents of a multivariate polynomial expression of order
order
andn_variables
number of variables.Parameters: - order (int) – the maximum order of the polynomial;
- n_variables (int) – the number of elements of the input vector.
Yields: The current exponent of the polynomial.
-
static
generate
(max_degree, input_size)[source]¶ Factory method to build a polynomial of order
max_degree
based on the firstinput_size
dimensions of the input.Parameters: - max_degree (int) – maximum degree of the polynomial;
- input_size (int) – size of the input.
Returns: The list of the generated polynomial basis functions.
-