Skip to main content

Package for fast regression

Project description

regressor

This is a small library that tries to run simple linear regression quickly on modern x86 hardware. This uses vectorized operations to speed up calculating dot products and means. The input numpy arrays need to be 1D with 32-bit floats.

As a result, this is ~20X faster than scipy.stats.linregress, but only runs on x86-64 hardware with AVX extensions (most desktops and servers as of 2020).

Install

pip install regressor

Usage

>>> import numpy as np
>>> from regressor import linregress
>>> x = np.array([1.0, 2.0, 3.0, 4.0, 5.0], dtype=np.float32)
>>> y = np.array([5.0, 4.0, 3.0, 2.0, 1.0], dtype=np.float32)
>>> linregress(x, y)
LinregressResult(slope=-1.0, intercept=6.0, rvalue=-1.0, pvalue=1.2e-30, stderr=0.0)

Performance

The graph below compares the times required for simple linear regressions between this package and scipy.stats.linregress, starting from arrays with 10 elements up to arrays with 100 million elements. This was run on a 2.6 GHz Skylake CPU. In general, this package performs simple linear regression in about 1/20th of the time required by scipy.stats.linregress.

Performance

Reliability

The regression results from this package match scipy.stats.linregress to within 4 decimal places (for the slope, intercept, r-value, p-value and standard error). The graphs below demonstrate this consistency by comparing betas, r-values and p-values from this package vs scipy.stats.linregress. These used randomly sampled values with varying correlation between the X and Y arrays to assess reliability across a wide range of P-values.

Reliability

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

regressor-1.0.9.tar.gz (181.6 kB view hashes)

Uploaded Source

Built Distributions

regressor-1.0.9-cp312-cp312-win_amd64.whl (99.9 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

regressor-1.0.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (653.9 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

regressor-1.0.9-cp312-cp312-macosx_10_9_x86_64.whl (120.0 kB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

regressor-1.0.9-cp311-cp311-win_amd64.whl (102.2 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

regressor-1.0.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (614.2 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

regressor-1.0.9-cp311-cp311-macosx_10_9_x86_64.whl (121.7 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

regressor-1.0.9-cp310-cp310-win_amd64.whl (102.2 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

regressor-1.0.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (578.7 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

regressor-1.0.9-cp310-cp310-macosx_10_9_x86_64.whl (121.7 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

regressor-1.0.9-cp39-cp39-win_amd64.whl (102.3 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

regressor-1.0.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (578.8 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

regressor-1.0.9-cp39-cp39-macosx_10_9_x86_64.whl (122.1 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

regressor-1.0.9-cp38-cp38-win_amd64.whl (102.4 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

regressor-1.0.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (594.3 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

regressor-1.0.9-cp38-cp38-macosx_10_9_x86_64.whl (121.6 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

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