skillfed

polars-ols

Polars Least Squares Extension

polars-ols v0.3.5 102.9K downloads/30d#12,841 on PyPI
License unclear DORMANT released

What it is and what it does

Polars OLS is a Rust-based extension that adds least-squares regression capabilities directly to Polars DataFrames. It implements common linear regression variants—ordinary least squares, weighted least squares, Ridge, Elastic Net, non-negative least squares, and recursive least squares—and exposes them as Polars expressions that integrate seamlessly into Polars' lazy evaluation and grouping workflows.

Instead of converting data to NumPy or scikit-learn, you chain regression calls like any other Polars expression, supporting sample weighting, L1/L2 regularization, non-negativity constraints, and a patsy-style formula API. It can compute predictions, residuals, coefficients, or statistical summaries (for OLS/WLS/Ridge), and scales across groups via `.over()` or `.group_by()` with native Rust parallelism.

Use it for:

  • Fit OLS or Ridge models within a Polars pipeline without leaving lazy evaluation or converting to NumPy
  • Compute per-group regression coefficients using `.group_by()` or `.over()` in parallel
  • Build weighted least-squares models with sample weights directly from a Polars column
  • Extract statistical summaries (R², MAE, MSE, p-values) for OLS/WLS/Ridge models in one expression
  • Use patsy formula syntax (e.g., 'y ~ x1 + x2 + x1:x2') to specify models without manual feature engineering

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Polars OLS provides Rust-optimized linear regression models (OLS, WLS, Ridge, Elastic Net, non-negative least squares, recursive least squares) as Polars expressions, enabling efficient least-squares estimation within Polars workflows.

Yes, if you are already using Polars and need to fit linear models without leaving the Polars ecosystem or converting to external libraries. No, if the package is dormant (last release 719 days ago, no visible recent commits) and you need active maintenance or bug fixes. Verify the license before use in proprietary projects.

Install

polars-ols on PyPI

pip

pip install polars-ols

uv

uv add polars-ols

poetry

poetry add polars-ols

Installing polars-ols

Before you install

Medium install friction due to compiled wheels for multiple platforms (cp38-abi3 across macOS, Linux, Windows architectures). Single runtime dependency on polars. Maintenance status is dormant: last release was 719 days ago with no recent commits visible.

License in practice

License treatment is unclear—no SPDX identifier or raw license text provided in metadata. Verify the actual license before adopting in proprietary or restricted-license projects.

Quickstart

pip install polars-ols

import polars as pl
import polars_ols as pls

df = pl.DataFrame({"y": [1.16, -2.16], "x1": [0.72, -2.43], "x2": [0.24, 0.18]})
predictions = df.with_columns(
    pl.col("y").least_squares.ols(pl.col("x1", "x2"), add_intercept=True).alias("pred")
)

Requires polars to be installed first. Python >= 3.8.

Verify before relying

  • Whether the package is actively maintained or seeking new maintainers (dormant status, no recent commits)
  • Actual license terms and compatibility with your project's licensing constraints
  • Performance benchmarks relative to scikit-learn or statsmodels for your specific use case
  • Whether formula API (patsy syntax) is fully documented and stable

Package facts

License not declared (unclear)
Python support supports the current Python release (>=3.8)
Install friction medium — platform-specific wheel
Runtime dependencies 1 — polars
Maintenance dormant — 719 days since the last release
First released
Downloads 102,855/month — #12,841 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: polars_ols-0.3.5-cp38-abi3-macosx_10_12_x86_64.whl; polars_ols-0.3.5-cp38-abi3-macosx_11_0_arm64.whl; polars_ols-0.3.5-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; polars_ols-0.3.5-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl; polars_ols-0.3.5-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl; polars_ols-0.3.5-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; polars_ols-0.3.5-cp38-abi3-win32.whl; polars_ols-0.3.5-cp38-abi3-win_amd64.whl

Keywords: polars-extension, linear-regression

Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyProgramming Language :: Rust

Tags

polars linear regressionleast squares polars extensionols regression polarspolars statistical modelingridge regression polarsweighted least squares polarspolars formula api regression
polars-extensionlinear-regressionrust-accelerated

More Mathematics packages