lpspline.optimizer.regressor.LpRegressor#

class lpspline.optimizer.regressor.LpRegressor(splines: Spline | List[Spline])[source]#

Bases: object

Algorithmic LpRegressor class fitting generalized additive spline models using convex optimization.

fit(X: DataFrame, y: Series, summary: bool = True) None[source]#

Compute basis coefficients mapping combinations within additive splines.

Minimizes the specified L2 norm determining the optimal linear composition evaluating structural distances. ||Sum(Spline_i(X)) - y||_2

Parameters:
  • X (pl.DataFrame) – The independent predictive training feature frame subset containing all modeled keys.

  • y (pl.Series) – Dependent observation labels associated mapping.

Raises:

ValueError – If no splines were initiated or structural dependencies are incorrectly verified.

get_spline(tag: str) Spline[source]#

Returns the spline component isolated utilizing its corresponding explicit identifier.

Parameters:

tag (str) – The explicit string tag name applied to a spline.

Returns:

The specified matching component spline instance.

Return type:

Spline

Raises:

ValueError – If the supplied specified tag isn’t contained within the current configuration splines.

static load(path: str | Path) LpRegressor[source]#

Load a model from a file.

Parameters:

path (Union[str, pathlib.Path]) – The path to the file from which the model will be loaded.

Returns:

The loaded model instance.

Return type:

LpRegressor

predict(X: DataFrame, return_components: bool = False) ndarray[source]#

Predict target sequential observations for new domain instances evaluating trained coefficients.

Parameters:
  • X (pl.DataFrame) – Unseen independent predictors formatted natively identical to initial modeling.

  • return_components (bool, default=False) – If True, calculates output sequentially isolated over all respective model components matrices.

Returns:

Numpy array mapping evaluations across sequential instances. Returns shape (n_samples, n_splines) if returning explicitly defined components. Else, computes overall predicted structure (n_samples, ).

Return type:

np.ndarray

Raises:

ValueError – If structural dataframe column dependencies aren’t accurately mirrored natively.

save(path: str | Path) None[source]#

Save the model to a file.

Parameters:

path (Union[str, pathlib.Path]) – The path to the file where the model will be saved.