Skip to main content

Tool for non-parametric curve fitting using local polynomials.

Project description

KernReg

PyPI Continuous Integration Codecov Codacy Badge Black

Introduction

KernReg provides a pure-Python routine for local polynomial kernel regression based on Wand & Jones (1995) and their accompanying R package KernSmooth. In addition, KernReg comes with an automatic bandwidth selection procedure that minimizes the residual squares criterion proposed by Fan & Gijbels (1996).

KernReg allows for the estimation of a regression function as well as their vth derivatives. The degree of the polynomial p must be equal to v + 1, v + 3, v + 5, or v + 7.

Local polynomial fitting provides a simple way of finding a functional relationship between two variables (where X typically denotes the predictor, and Y the response variable) without the imposition of a parametric model. It is a natural extension of local mean smoothing, as described by Nadaraya (1964) and Watson (1964). Instead of fitting a local mean, local polynomial smooting involves fitting a local pth-order polynomial via locally weighted least-squares. The Nadaraya–Watson estimator is thus equivalent to fitting a local polynomial of degree zero. Local polynomials of higher order have better bias properties and, in general, do not require bias adjustment at the boundaries of the regression space.

Installation

Install KernReg via PyPI.

$ pip install kernreg

Quick-Start

import kernreg as kr

motorcycle = kr.get_example_data()
x, y = motorcycle["time"], motorcycle["accel"]

# By default, only x and y need to be provided.
# Derivative = 0 is chosen by default
# and hence the polynomial degree = 0 + 1.
rslt_default = kr.locpoly(x, y)
kr.plot(x, y, rslt_default, "motorcycle_default_fit.png")

default fit

# We can improve on the default specification by
# choosing a higher order polynomial
rslt_user = kr.locpoly(x, y, degree=3)
kr.plot(x, y, rslt_user, "motorcycle_user_fit.png")

user fit

References

Fan, J. and Gijbels, I. (1996). Local Polynomial Modelling and Its Applications. Monographs on Statistics and Applied Probability, 66. Chapman & Hall.

Wand, M.P. & Jones, M.C. (1995). Kernel Smoothing. Monographs on Statistics and Applied Probability, 60. Chapman & Hall.

Wand, M.P. and Ripley, B. D. (2015). KernSmooth: Functions for Kernel Smoothing for Wand and Jones (1995). R package version 2.23-18.


* The image is taken from futurist illustrator Arthur Radebaugh's (1906–1974) Sunday comic strip Closer Than We Think!, which was published by the Chicago Tribune - New York News Syndicate from 1958 to 1963.

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

kernreg-0.0.4.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

kernreg-0.0.4-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file kernreg-0.0.4.tar.gz.

File metadata

  • Download URL: kernreg-0.0.4.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.6 Linux/5.4.0-1032-azure

File hashes

Hashes for kernreg-0.0.4.tar.gz
Algorithm Hash digest
SHA256 3f71d01b189a6e57407ea1e2a8b228e4885d7389468676da13db15670da9baaf
MD5 48d5f6d2ec434de26444874e9fc18346
BLAKE2b-256 5e3311655f6324816710fbb0c88aa977c3f9afb02e89f9df9cda8a677934a88e

See more details on using hashes here.

File details

Details for the file kernreg-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: kernreg-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.6 Linux/5.4.0-1032-azure

File hashes

Hashes for kernreg-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1448c7d5c07ace526bd67ba009de34f9afc24da0473f681abcb235f9f1bcf843
MD5 854ab71dcffc6f5200fb9cfb9acb4a8b
BLAKE2b-256 eeb90eff8c6d5d4ded24355622f83e348fc0ba2aa5f9fe47007e26b0d4948947

See more details on using hashes here.

Supported by

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