fastlr: fast(er) logistic regression
This package aims to estimate a logistic regression model in a fast(er)
way using the iteratively reweighted least squares (IRLS) algorithm.
This is implemented using the C++ library
armadillo. The package provides
R-bindings through
Rcpp in the
R package fastlr and Python-bindings through
pybind11 in the
Python package fastlr; the Python package also provides a pure Python
implementation of the IRLS algorithm.
Usage
Python
from fastlr import fastlr, generate_data
X, y = generate_data(N=10_000, k=10, seed=0)
print(py_res := fastlr(X, y))
FastLrResult(coefficients=array([-0.19547786, 0.26833757, -0.1303476 , -0.03979692, -0.15035753,
-0.26321948, 0.33105813, -0.19471808, 0.12025924, 0.11202108]), iterations=4, converged=True, time=0.051200235)
# Alternatively, use the pure Python implementation
print(py_res_simple := fastlr(X, y, method="python"))
FastLrResult(coefficients=array([-0.19547786, 0.26833757, -0.1303476 , -0.03979692, -0.15035753,
-0.26321948, 0.33105813, -0.19471808, 0.12025924, 0.11202108]), iterations=4, converged=True, time=0.002805208001518622)
import numpy as np
np.allclose(py_res.coefficients, py_res_simple.coefficients)
True
R
library(fastlr)
library(reticulate)
m <- fastlr(py$X, py$y) # py from reticulate; reticulate nice
print(m)
$coefficients
[1] -0.19547786 0.26833757 -0.13034760 -0.03979692 -0.15035753 -0.26321948
[7] 0.33105813 -0.19471808 0.12025924 0.11202108
$iterations
[1] 4
$time
[1] 0.00205007
$converged
[1] TRUE
Thanks reticulate!
py_estimates <- py$py_res$coefficients |> as.numeric()
r_estimates <- m$coefficients
print(py_estimates)
[1] -0.19547786 0.26833757 -0.13034760 -0.03979692 -0.15035753 -0.26321948
[7] 0.33105813 -0.19471808 0.12025924 0.11202108
print(r_estimates)
[1] -0.19547786 0.26833757 -0.13034760 -0.03979692 -0.15035753 -0.26321948
[7] 0.33105813 -0.19471808 0.12025924 0.11202108
all.equal(py_estimates, r_estimates, tolerance = 1e-6)
[1] TRUE
Installation
Python
git clone https://github.com/jsr-p/fastlr
cd fastlr
uv sync
pip install .
or from pypi
pip install fastlr
R
git clone https://github.com/jsr-p/fastlr
cd fastlr
Rscript -e 'devtools::install_local(".")'
Benchmarks
To reproduce the benchmarks install the development versions of both packages and run:
just bench
Benchmark against fastglm
This benchmark shows the same results as shown in the fastglm
package
with the fastlr (Rcpp) implementation added to
the figure (run on my laptop).
See scripts/fastglm_bm.R and the Justfile.
For the sessionInfo() see here.
BTW:
grep 'Running under' output/sessioninfo.txt
Running under: Arch Linux
Benchmark against Python packages
A benchmark study of this package’s two implementations
- Python implementation of the
IRLSalgorithm - C++ implementation of the
IRLSalgorithm with Python bindings through pybind11
against:
- glum
- statsmodels logit
- minimal
newton-cgminimize implementation from scipy
for varying sample size $N$ and number of covariates $k$.
See the generate_data function
here.
Benchmark Python implementations
Interestingly, as seen from the figure, the pure Python implementation is quite fast and comparable to the C++ version!
Benchmark R implementations on same setup as above
Benchmark results as tables
- See here for the benchmark results as a table.
Development
Metadata
Release files for fastlr 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastlr-0.1.0.tar.gz | 9.5 kB | With provenance | Details for fastlr-0.1.0.tar.gz |
Built distributions (wheels)
Total release size: 190.3 MB
Release files / fastlr-0.1.0.tar.gz
| Download URL | fastlr-0.1.0.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b95464c797946131eea68d9e22c70b1d849e7d3ac391fdb3d4daf1889d84327e
|
|
BLAKE2b-256 checksum How to use checksums |
0ea6ee6522c4ed888789b68dbd3760a4c9078ede63d84c58fe6c21f9565aed88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 11, 2025.
Transparency logRelease files / fastlr-0.1.0-cp313-cp313-win_amd64.whl
| Download URL | fastlr-0.1.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 7.6 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
d3e2253254f85f563f50c84256d9595a9fbf32f18fe77c3b605eb9153d64007c
|
|
BLAKE2b-256 checksum How to use checksums |
4888fce5a9b0832f51bbd5d12a28dca6abb6fa3ffe57674c29d3551acad1b42d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 11, 2025.
Transparency logRelease files / fastlr-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | fastlr-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 43.1 MB |
| Tags | CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
543a3bfe2a7c86fa52c6b0f031aafa7a98c4389984a1ecb2504e9c7e3d99b54c
|
|
BLAKE2b-256 checksum How to use checksums |
396c2c222cd6698b2b439fef14b55c0d5394401113fbe7bdae11692a96f8f2fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 11, 2025.
Transparency logRelease files / fastlr-0.1.0-cp313-cp313-macosx_14_0_arm64.whl
| Download URL | fastlr-0.1.0-cp313-cp313-macosx_14_0_arm64.whl |
|---|---|
| Size | 12.7 MB |
| Tags | CPython 3.13 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b3fbddb2c08c09df281d1f4803b5a6ac2d0d75acce52429b0cb0296f3c9b338e
|
|
BLAKE2b-256 checksum How to use checksums |
78754ad7e0b0868c5a8ea573540f10f96bd5ec0db9134faefdbb08d8cd9f0ab5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 11, 2025.
Transparency logRelease files / fastlr-0.1.0-cp312-cp312-win_amd64.whl
| Download URL | fastlr-0.1.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 7.6 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
4a2cf8f0b836946453ef2283b00e427fd6fbbd7914ea547ccd6a80049e65a355
|
|
BLAKE2b-256 checksum How to use checksums |
5b50d274b46186ddb8a87b17d32a6aeb872cedeb20ca5441d781765fda723707
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 11, 2025.
Transparency logRelease files / fastlr-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | fastlr-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 43.1 MB |
| Tags | CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
ef2b0dddaeaaac2e0d01f868abd008a256ef7910a0c63a905f3cdcd5dd343465
|
|
BLAKE2b-256 checksum How to use checksums |
20368834a7805ee8c6c55834ec102189248a017d17a6324aab47c17f6609f292
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 11, 2025.
Transparency logRelease files / fastlr-0.1.0-cp312-cp312-macosx_14_0_arm64.whl
| Download URL | fastlr-0.1.0-cp312-cp312-macosx_14_0_arm64.whl |
|---|---|
| Size | 12.7 MB |
| Tags | CPython 3.12 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
90e93f42032ca9f28d5a9feeeacb1a41614b3a332c46954beab4d06489479af1
|
|
BLAKE2b-256 checksum How to use checksums |
f398bcaab0bd93e0ac9cdffe3793f9c6db537ebf03ba7869f48ee18a7ef330ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 11, 2025.
Transparency logRelease files / fastlr-0.1.0-cp311-cp311-win_amd64.whl
| Download URL | fastlr-0.1.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 7.6 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c1d533763a010bfb6e6d39371ef4781d8ffaedadd1a3fae0989f53888f40c74a
|
|
BLAKE2b-256 checksum How to use checksums |
7dd324c2cb1706f63ddc143a953ab7ce68e65292d75db55e6a32eabcb5b75f81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 11, 2025.
Transparency logRelease files / fastlr-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
| Download URL | fastlr-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 43.1 MB |
| Tags | CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
cc81d9b20d9be29de1f73ccb77a0e9af74355bb6cb3e1c16899d2461a29f179e
|
|
BLAKE2b-256 checksum How to use checksums |
8c4b0f394d4d0064fc280aecf3600205adadba73b8d442972cdeeee1a7c0c010
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 11, 2025.
Transparency logRelease files / fastlr-0.1.0-cp311-cp311-macosx_14_0_arm64.whl
| Download URL | fastlr-0.1.0-cp311-cp311-macosx_14_0_arm64.whl |
|---|---|
| Size | 12.7 MB |
| Tags | CPython 3.11 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d9b8255082e7c676a5b93dba8d1eeffadba3570b8a67f15f39194567c07ba572
|
|
BLAKE2b-256 checksum How to use checksums |
ef1b773ce9a8fec3f3fd5739288d5215f0503d2d259d3919137270bfc4463dbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 11, 2025.
Transparency logSecurity for fastlr 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 10 files in this release have been uploaded with provenance metadata.
Attestation for fastlr-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 11, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.