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.
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for regressor-1.0.9-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e3af9eb41484f0d351ff3f907f1325f557bb2f2357ca284e6e169a4c9118d0e |
|
MD5 | 153d537b41b3aed027eee09966cd9f6a |
|
BLAKE2b-256 | d444c307046870a39bf3d43cb2d5d9bac27493ce436c7b903a731ab7e44bf511 |
Hashes for regressor-1.0.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 772194f324b9c495f6fed9e34126fcf1ad62a502dca30207619b58dc849e8c29 |
|
MD5 | fd43c728f73b8bb9843a2c6de2a2432f |
|
BLAKE2b-256 | c121503fb81057c98485e7c8d8e54df244bf7ba6526424c45b1547b9566b20a0 |
Hashes for regressor-1.0.9-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e0baee6fd611ae937b9de7b18cd517ff5a11c458c454cfead5b596f81a51775 |
|
MD5 | 5d1dc1ec5916b80fa2b5b58ba881f99e |
|
BLAKE2b-256 | 44395b2bbdc489915cb0f00659204fcbfe3fdc257593aaf90be1d6ca552e9213 |
Hashes for regressor-1.0.9-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 821770b3a7ea562f2db2f0336b755d3167d5cbeebfd25a4d2e36dbc69bb4beda |
|
MD5 | e7e4a757c7fa76eee438fae4aa40da58 |
|
BLAKE2b-256 | a8b30ca7bc275a35cdbdc1ed0670ea333ab36a2cc9aa165d6612700ae86f7849 |
Hashes for regressor-1.0.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70cda3cfbb9303fde92d4d83381304fd13e0b99839e2328bee63845108d98049 |
|
MD5 | 419c543298baf536342fd1eab78a9a81 |
|
BLAKE2b-256 | 7e950c8d633760441408ea760699a92e2c35f1b0636bd7e4a51ed8b56a3e8eb1 |
Hashes for regressor-1.0.9-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67de2eb8d4174911956bc071077a7f65062ec0c41829d4a95849c564a458c026 |
|
MD5 | 10870746f16346207a04f6c2744404b2 |
|
BLAKE2b-256 | abceb7643791dea23008f81ee82b971790821834e8346b6bb39dd9d09b88cb27 |
Hashes for regressor-1.0.9-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f4d9310c0573ca37dd0ec988ae000cb731af51a36ca47e8b67a8461c0abc23a |
|
MD5 | f1c30d2e0b11e320fac2745b01eeb8cf |
|
BLAKE2b-256 | 69eb57f260a85f3d00709cfa588cfc2b79eecc904cfdfec755970e2fd7fa0bd8 |
Hashes for regressor-1.0.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0fccb6e9672310253713e2683ca02a97765b5edee1bc926034ff4208634eeb2 |
|
MD5 | b6e871f391f19bf55bf729db92bb9424 |
|
BLAKE2b-256 | 7e60e3a05be15723c7cf75388a7e3da7b0cb5ce6a49fda17d0e2e351c987dbd5 |
Hashes for regressor-1.0.9-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a54d5ac25f54c82deaf526f1451c1e070ddbf873b3625ec9c11158e110940c2 |
|
MD5 | 659c715d419ba83b095cdd16952df589 |
|
BLAKE2b-256 | 49b9b1e34c7e93212e50183c0235e8c52cf77f10c4d49033d0fbae57524e30c8 |
Hashes for regressor-1.0.9-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68dc3de38e7ed93a0975a12fe9d47e1ae41eb19179cd7c176825813d23ce5c87 |
|
MD5 | 813ceeb6b383a15d2e46ed7c4b21cfd3 |
|
BLAKE2b-256 | 0ef7b7ee78e0be1bc229d1c040ee2a09d61418644457bb0e5b2b4c4a24b2460a |
Hashes for regressor-1.0.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8e19196efb2febf1188cdd16a3117664fc7543ef88bc4b385fe50ecfeb7a2d6 |
|
MD5 | a51b4491cc5d5617e18c3dec9c27236e |
|
BLAKE2b-256 | 422b009200d379ca781284ae1abca71a026173d76d6abc5c5341303df54d0664 |
Hashes for regressor-1.0.9-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9dcbfe96a26dd361aa96966c2a4642c297b908651f70fe4d332cb2d219ac8cee |
|
MD5 | 8e957b28e8c851ead80dd9d8a84c5090 |
|
BLAKE2b-256 | 59b94c16cb810005b2eb8a8d7ae55793381b18bcc9a4086cded0114fb1581be4 |
Hashes for regressor-1.0.9-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2dc72be4b36f1913b135cdf465c5e364882d63bf5f1dd19e708b91d6b44fbecf |
|
MD5 | e7d2e7e5be920427a19094d173229fec |
|
BLAKE2b-256 | 6d06b1a74f54b4f6d4c85d023b41371cee65dcf3b6ea4035abc8c3c6eb244b61 |
Hashes for regressor-1.0.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83379a1634bd8f362ff6d7cea66f35984b472d8e518083056c2fae7ff4b9229e |
|
MD5 | 545affeaeb1634cd6f11493431878245 |
|
BLAKE2b-256 | 459e9beebc3beaca512deaacd811c41146739c68ed5ca2025a2f5e6df283fa0e |
Hashes for regressor-1.0.9-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75a18a17acaa5fd8bc8756a346923f7d7d3ed075605821990c1111c8b7a108c1 |
|
MD5 | f808c02151e6a6b0bacd20dd29243c31 |
|
BLAKE2b-256 | 0b22ded9b4ea6b2003bbbdf8327049352b4a347aba72e8a395b71dddba38d997 |