Skip to main content

Regressio is a python module for univariate regression, interpolation, and smoothing.

The available models are:

  • Linear regression
  • Ridge regression
  • Linear spline
  • Isotonic regression
  • Bin regression
  • Cubic spline
  • Natural cubic spline
  • Exponential moving average
  • Kernel functions (Gaussian, KNN, Weighted average)

There are also functions implemented to generate data samples.

The available data generators are:

  • Random walk
  • Isotonic sample

Installation

Regressio is supported in Python 3.8+ and requires only NumPy and Matplotlib.

pip install regressio --upgrade

or

pip install git+https://github.com/brendanartley/Regressio

Example Usage

Cubic spline.

# Import modules + classes
from regressio.models import cubic_spline
from regressio.datagen import generate_random_walk
import numpy as np
import matplotlib.pyplot as plt

# Set figsize and seed
plt.rcParams['figure.figsize'] = (10, 5)
np.random.seed(0)

# Generate data sample
x, y = generate_random_walk(150)

# Fit model and plot result
model = cubic_spline(pieces=15)
model.fit(x, y, plot=True, confidence_interval=0.99)
Cubic spline

Linear regression.

# Import modules + classes
from regressio.models import linear_regression
from regressio.datagen import generate_random_walk
import numpy as np
import matplotlib.pyplot as plt

# Set figsize and seed
plt.rcParams['figure.figsize'] = (10, 5)
np.random.seed(1)

# Generate data sample
x, y = generate_random_walk(100)

# Fit model and plot result
model = linear_regression(degree=5)
model.fit(x, y, plot=True, confidence_interval=0.95)
Linear regression

Exponential moving average.

# Import modules + classes
from regressio.models import exp_moving_average
from regressio.datagen import generate_isotonic_sample
import numpy as np
import matplotlib.pyplot as plt

# Set figsize and seed
plt.rcParams['figure.figsize'] = (10, 5)
np.random.seed(6)

# Generate data sample
x, y = generate_isotonic_sample(100)

# Fit model and plot result
model = exp_moving_average(alpha=0.2)
model.fit(x, y, plot=True, confidence_interval=0.90)
Exponential moving average

For more examples, navigate to the examples.ipynb file in this repository.

Contributions

We welcome all to contribute their expertise to the Regressio library. If you are new to open source contributions, this guide gives some great tips on how to get started.

If you have a complex feature in mind or find a large bug in the code, please create a detailed issue and we will get to work on it.

References

  • Hyndman, R.J., & Athanasopoulos, G. (2021) Forecasting: principles and practice, 3rd edition, OTexts: Melbourne, Australia. OTexts.com/fpp3. Accessed July 2022.

  • Kong, Qingkai, et al. Python Programming and Numerical Methods: A Guide for Engineers and Scientists. Academic Press, an Imprint of Elsevier, pythonnumericalmethods.berkeley.edu, Accessed July 2022.

  • Li, Bao, (2022). Stat 508: Applied Data Mining, Statistical Learning: Stat Online. PennState: Statistics Online Courses, online.stat.psu.edu/stat508, Accessed July 2022.

  • Brett, M. (2014, October 26). An introduction to smoothing. Tutorials on imaging, computing and mathematics. matthew-brett.github.io/teaching, Accessed July 2022.

Release files for regressio 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for regressio 1.0.1
File Size Uploaded
regressio-1.0.1.tar.gz 15.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for regressio 1.0.1
File Interpreter ABI Platform
regressio-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 30.4 kB

Release files / regressio-1.0.1.tar.gz

Download URL regressio-1.0.1.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
eea3c778dc7f1db582a19ee1f08ce95247d73292d442104c71ceab8fd334801c
BLAKE2b-256 checksum
How to use checksums
dd57af15215cb2bab3e0af4dc66fd8bcbd974b4313c6efe849d94e39cd842784
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.3

Release files / regressio-1.0.1-py3-none-any.whl

Download URL regressio-1.0.1-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
608a187630306a608cb9399739bba53d312d363d987480686bb2cdac54b6aea3
BLAKE2b-256 checksum
How to use checksums
85399e03202f8ea74ab33c53ab88d6e02aed7fdeae20b1970968049a16bee140
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.3

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page