Skip to content

Implementation of an ordinary regression

Damar Wicaksono requested to merge dev-regression-abc into dev

This MR implements an ordinary polynomial regression for minterpy (Issues #61 (closed) and #57 (closed)); both weighted and unweighted are supported, but not regularized (this is, after all, an ordinary regression). Being an extra, this feature uses the functionalities of minterpy but does not directly affect minterpy itself. The class is a concrete implementation of RegressionABC abstract base class.

Following discussion with @thekke48, the following parameters are exposed in the default constructor: multi_index, grid, and origin_poly. origin_poly denotes the polynomial basis on which the regression is carried out; it affects the construction of the regression matrix as well as the least square solution. Constructing the regression matrix based on different polynomial bases is currently done separately for each supported bases. However, this may be changed (and much simplified) if each of minterpy polynomials supports eval_monomials_on (Issue #84).

Computing the regression coefficients is carried out via least squares. Different least squares solvers either via NumPy or SciPy are supported. By default, the selected solver is scipy.linalg.lstsq().

Cleanup Note

Two legacy files are still in this draft merge request:

  • src/minterpy/differentiation/derivation.py
  • src/minterpy/extras/regression/regression.py

Before creating this merge request, I've merged the current dev to this branch. This branch includes old version of polynomial differentiation that is now available in dev albeit in different implementation (or locations). Because apparently the Windowed regression still calls some functionalities of the old differentiation, I collect them all to src/minterpy/differentiation/derivation.py (not available in dev) not to break anything.

@thekke48: Please have a look whether functions in that module are still required, if not (all are included in the dev) we can delete them all.

Additionally, the old implementation of the regression is located in src/minterpy/extras/regression/regression.py. The ordinary regression is a much simplified version of that old implementation, many attributes/properties/methods are now excluded; however, if some attributes/properties/methods are deemed important we can discuss about including them. That's why I kept the file here for review purposes.

Edited by Damar Wicaksono

Merge request reports