Skip to main content

Implementation of the Robust Local Polynomial Regression with Similarity Kernel draft paper

Project description

Robust Local Polynomial Regression with Similarity Kernels

Downloads Tests phorm.ai Pyversions

TL;DR

This library is useful to perform robust locally weighted regression (similar to LOESS) in Python when:

  1. There are no particular assumptions on the underlying function except that it is "reasonably smooth". In particular, you don't know which parametric model to specify or if an appropriate model exists.
  2. There are no particular assumptions on the type and intensity of noise present.
  3. There are no particular assumptions on the presence of outliers and their extent.
  4. You may want to predict in locations not explicitly present in the dataset but also not too far from existing observations or far outside the areas where observations exist.
  5. The independent inputs are univariate or multivariate.
  6. The dependent variable is univariate.
  7. You want a straightforward hassle-free way to tune the model and the smoothness of fit.
  8. You may want to calculate confidence intervals.
  9. You may want to filter noise to recover the original underlying process.
  10. You may want to impute or resample the data.

If the above use cases hold then this library could be useful for you. Have a look at this notebook https://nbviewer.org/github/yaniv-shulman/rsklpr/tree/main/docs/usage.ipynb for an example of how to use this library to perform regression easily.

Installation

Install from PyPI using pip (preferred method):

pip install rsklpr

What's new?

  • Version 1.0.0 - Dropped support for Python 3.8 and added support for Python 3.12.
  • Version 0.7.0 - Metrics including local R-Squared and more efficient computation of WLS.
  • Version 0.6.0 - Bootstrap inference and confidence intervals

Details

Local polynomial regression (LPR) is a powerful and flexible statistical technique that has gained increasing popularity in recent years due to its ability to model complex relationships between variables. Local polynomial regression generalizes the polynomial regression and moving average methods by fitting a low-degree polynomial to a nearest neighbors subset of the data at the location. The polynomial is fitted using weighted ordinary least squares, giving more weight to nearby points and less weight to points further away. Local polynomial regression is however susceptible to outliers and high leverage points which may cause an adverse impact on the estimation accuracy. This library implements a variant of LPR presented in the Robust Local Polynomial Regression with Similarity Kernels draft paper which uses a generalized similarity kernel that assign robust weights to mitigate the adverse effect of outliers in the local neighborhood by estimating and utilizing the density at the local locations.

Experimental results

The experimental results and demonstration of the library for various experimental settings are available as interactive Jupyter notebooks at https://nbviewer.org/github/yaniv-shulman/rsklpr/tree/main/src/experiments/

KDE Implementation

KDE implementation is a copy of the code from statsmodels https://www.statsmodels.org/stable/index.html. The copy is done to remove statsmodels as a dependency of this package since statsmodels is quite heavy and pulls a lot of additional packages.

Contribution and feedback

The paper is work in progress and the library in early stages of development but both are in a useful state. Contributions and feedback are most welcome both to the paper and the code. Please see CONTRIBUTING.md for further details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rsklpr-1.1.0.tar.gz (32.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rsklpr-1.1.0-py3-none-any.whl (33.9 kB view details)

Uploaded Python 3

File details

Details for the file rsklpr-1.1.0.tar.gz.

File metadata

  • Download URL: rsklpr-1.1.0.tar.gz
  • Upload date:
  • Size: 32.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.8.10 Linux/5.15.0-126-generic

File hashes

Hashes for rsklpr-1.1.0.tar.gz
Algorithm Hash digest
SHA256 d9af24c74f9865a3bf5f15f27b39c3193ccfacf7c9fb9d6716a170b429882a80
MD5 98c9a2648f5eff89547b53ac11116eac
BLAKE2b-256 94f66b86f501128551c126db001b0c0c231e5d7b4b5c8d4db4773051bcda714d

See more details on using hashes here.

File details

Details for the file rsklpr-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: rsklpr-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 33.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.8.10 Linux/5.15.0-126-generic

File hashes

Hashes for rsklpr-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c4c56dfa9a8d0ac402aea363e7bd4b639aaa5e097f9594e9844c70f33955156
MD5 8863064930c7ff3bf51edc5ff01e5e50
BLAKE2b-256 76d0f4f1795b416198435973d44eb9c12573b38758a91edd2d33cddca2b62840

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page