Quantco/glum
High performance Python GLMs with all the features!
What it solves
glum is a fast, Python-first library for Generalized Linear Models (GLM), providing a unified interface for common statistical methods like least-squares, Poisson, and logistic regression. It addresses the need for a broad range of distribution support, flexible regularization techniques, and high performance, particularly when the number of observations significantly exceeds the number of predictors (N >> K).
How it works
The library provides a scikit-learn-like API for fitting models. It supports various distributions (Normal, Poisson, Binomial, Gamma, Inverse Gaussian, Negative Binomial, and Tweedie) and customizable link functions. It integrates with formulaic for formula-based model specification and narwhals for compatibility with multiple dataframe backends like pandas and polars.
Who it’s for
Data scientists and statisticians who need a high-performance GLM implementation with support for L1, L2, and Elastic Net regularization, as well as classical statistical inference for unregularized models.
Highlights
- Broad Distribution Support: Includes Normal, Poisson, Binomial, Gamma, Inverse Gaussian, Negative Binomial, and Tweedie distributions.
- High Performance: Consistently faster than other modern libraries when N >> K.
- Flexible Regularization: Supports L1, L2 (including Tikhonov penalties), and Elastic Net regularization, with built-in cross-validation for optimal regularization paths.
- Formula-based Specification: Supports formulaic-based models with monotonic constraints.
- Backend Agnostic: Works with pandas, polars, and other dataframes via
narwhals.
Related
- Project
- Project
- Project
- Project
- Project