Skip to main content

Sklearn compatible implementation of the Locally Estimated Scatterplot Smoothing (LOESS) algorithm

Project description

skloess

PyPI version

scikit-learn compatible implementation of the Locally Estimated Scatterplot Smoothing (LOESS) algorithm .

The code for the python version of loess is based on https://github.com/joaofig/pyloess

References:

How to install

Install with pip:

pip install skloess

Dependencies

  • numpy
  • math
  • scikit-learn
  • matplotlib
  • pytest for running the test suite

How to use

Download, import and do as you would with any other scikit-learn method:

  • fit(X, y)
  • predict(X)

Keep in mind that the model requires 1-dimensional input, i.e. a list/array/pandas series for both X and y. X and y must have the same length.

Description

An excellent explanation of the pyloess code can be found at https://towardsdatascience.com/loess-373d43b03564. This package simply formats the pyloess code into a sklearn estimator.

Parameters

estimator : object

A supervised learning estimator, with a 'fit' and 'predict' method.

degree : int, default = 1

Degree of the polynomial. Default value of 1 is a linear implementation.

smoothing : float, default = 0.33

Smoothing value. This value is used to determine the number of closest points to use for the fitting and estimation process. For example, a value of 0.33 over 21 X values means that 7 closest points will be chosen. The smoothing parameter is a number between (λ + 1) / n and 1, with λ denoting the degree of the local polynomial and n denoting the total number of observations.

alt text

Examples

from skloess import LOESS

# load X and y

X = np.array(
    [
        0.5578196,
        2.0217271,
        2.5773252,
        3.4140288,
        4.3014084,
        4.7448394,
        5.1073781,
        6.5411662,
        6.7216176,
        7.2600583,
        8.1335874,
        9.1224379,
        11.9296663,
        12.3797674,
        13.2728619,
        14.2767453,
        15.3731026,
        15.6476637,
        18.5605355,
        18.5866354,
        18.7572812,
    ]
)
y = np.array(
    [
        18.63654,
        103.49646,
        150.35391,
        190.51031,
        208.70115,
        213.71135,
        228.49353,
        233.55387,
        234.55054,
        223.89225,
        227.68339,
        223.91982,
        168.01999,
        164.95750,
        152.61107,
        160.78742,
        168.55567,
        152.42658,
        221.70702,
        222.69040,
        243.18828,
    ]
)


# define estimator with default params
est = LOESS(degree=1, smoothing=0.33)

#fit the estimator
est.fit(X, y)

# predict the y values for the original X values
predicted=est.predict(X)

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

skloess-0.1.2.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

skloess-0.1.2-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file skloess-0.1.2.tar.gz.

File metadata

  • Download URL: skloess-0.1.2.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Linux/5.15.0-107-generic

File hashes

Hashes for skloess-0.1.2.tar.gz
Algorithm Hash digest
SHA256 2fcb5d6d467f6d76f72183484fc3878dcd32c049cf4e140e035fc687cf64b131
MD5 a652eef6f8e930b7626d3ed46675b007
BLAKE2b-256 d7a1a61ca6d682686b528c4faf4f51fc48afb94b1e785718ebee66a09b05a2ab

See more details on using hashes here.

File details

Details for the file skloess-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: skloess-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Linux/5.15.0-107-generic

File hashes

Hashes for skloess-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ac2ab602bdc34f2a6f699a04a707379abd8263fd102e86bc068a5584d206730d
MD5 896a5f8e7109b17e946ad63c53334e14
BLAKE2b-256 0d39488d6f30b20cdd434ec45bc0db3a1bb762575804ce7853b488ced33f572d

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