pyseobnr.eob.fits.antisymmetric_modes.PredictorSparseFits

class pyseobnr.eob.fits.antisymmetric_modes.PredictorSparseFits(monomial_coefficients: ndarray, mean: ndarray, std: ndarray, intercept: float, dimension: int, max_degree: int, polynomials_contain_bias: bool = False)[source]

Bases: object

Helper class to calculate the predictions from the fits

As the coefficients are sparse, the implementation performs the calculations only on the active monomials (coefficients != 0).

The fitting pipeline is made of 3 stages in order:

  1. polynomial fit on the input data:

  2. scaling: mean and std

  3. matching pursuit: gives the coefficients and the intercept term

The scaling and matching pursuit will see the coefficients from the output of the polynomial, and the bias term of the polynomial will propagate further to the mean/std and coefficients of the matching pursuit

__init__(monomial_coefficients: ndarray, mean: ndarray, std: ndarray, intercept: float, dimension: int, max_degree: int, polynomials_contain_bias: bool = False)[source]

Methods

__init__(monomial_coefficients, mean, std, ...)

get_monomials_coefficients(dimension, max_degree)

Returns the sequence of monomials coefficients.

predict(input_features)

Applies the prediction of the fit from the feature vector

static get_monomials_coefficients(dimension: int, max_degree: int) list[dict[int, int]][source]

Returns the sequence of monomials coefficients.

The order follows the same as the one of the PolynomialFeatures from the scikit-learn package (used for producing the fits). Each monomial is described by a dictionary, where the keys are the feature dimension and the values are their corresponding power in the monomial: {0:3, 2:5} would mean \(x^3 + z^5\) if x identifies the first dimension (index 0) and z the third.

The intercept (constant term) is not returned.

predict(input_features: ndarray)[source]

Applies the prediction of the fit from the feature vector