Code Monkey home page Code Monkey logo

kernreg's Introduction

KernReg

PyPI Python Versions Read the Docs 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 using the Gaussian density function as kernel weights. 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.

kernreg's People

Contributors

segsell avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.