Registry / ai-ml / glum
library3.4.1pypypi✓ verified 84d ago

glum is a Python library providing high-performance implementations of Generalized Linear Models (GLMs), including various distributions and link functions. It focuses on speed and feature richness, supporting regularized fitting (L1, L2, ElasticNet) and cross-validation. The current version is 3.3.0, and it maintains an active release cadence with multiple updates throughout the year.

pip install glum
INSTALL
IMPORT
SIG · GLUM
G
glum
ai-mlpythonv3.4.1
Install
17.6s avg
Import
4508ms
Disk
518MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.4.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
build_error
glibc
py 3.103.910 runs
installs and imports cleanly · install 17.6s · import 3.606s · 537MB
518MB installed
● package 518MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GeneralizedLinearRegressor
from glum import GeneralizedLinearRegressor
GeneralizedLinearRegressorCV
from glum import GeneralizedLinearRegressorCV
PoissonDistribution
from glum import PoissonDistribution
GammaDistribution
from glum import GammaDistribution
LogLink
from glum import LogLink

This quickstart demonstrates how to fit a Poisson GLM with a log link using `glum.GeneralizedLinearRegressor`. It generates synthetic data, then initializes and fits the model, finally printing the intercept, coefficients, deviance, and predictions for the first few samples.

import numpy as np import pandas as pd from glum import GeneralizedLinearRegressor, PoissonDistribution, LogLink # Generate some synthetic data np.random.seed(42) n_samples = 100 X = pd.DataFrame({ 'feature_1': np.random.rand(n_samples) * 10, 'feature_2': np.random.rand(n_samples) * 5 }) # True coefficients beta_0 = 1.0 beta_1 = 0.5 beta_2 = 0.2 # Generate Poisson-distributed target variable using a log link linear_predictor = beta_0 + beta_1 * X['feature_1'] + beta_2 * X['feature_2'] mu = np.exp(linear_predictor) y = np.random.poisson(mu) # Create and fit the GLM glm = GeneralizedLinearRegressor( distribution=PoissonDistribution(), link=LogLink(), fit_intercept=True ) glm.fit(X, y) print(f"Intercept: {glm.intercept_:.4f}") print(f"Coefficients: {glm.coef_}") print(f"Deviance: {glm.deviance_:.4f}") print("Predictions (first 5 samples):\n", glm.predict(X.head()).round(2))
Debug
Known issues
breakingIn v3.3.0, the `trust-constr` solver's default Hessian calculation changed from `hess="2-point"` (finite-difference) to `SR1()` (quasi-Newton). While improving performance, this might lead to slightly different numerical results for models that previously relied on the finite-difference Hessian.
fix
If exact reproducibility with older versions is critical, explicitly set `solver_params={'hess': '2-point'}` when initializing `GeneralizedLinearRegressor` or `GeneralizedLinearRegressorCV` if using `solver='trust-constr'`, though `SR1()` is generally superior.
affects: >=3.3.0
gotchaPrior to v3.2.3, `InverseGaussianDistribution.log_likelihood` contained an incorrect call, causing it to always return NaN. Models using `InverseGaussianDistribution` would fail or produce invalid results.
fix
Upgrade to `glum>=3.2.3` to ensure correct calculations for the `InverseGaussianDistribution`.
affects: <3.2.3
gotchaVersions before 3.2.1 had an error when predicting at a specific `alpha` with categorical features, potentially leading to incorrect or failed predictions.
fix
Upgrade to `glum>=3.2.1` to resolve prediction issues when working with categorical features and L1/ElasticNet regularization (`alpha_search`).
affects: <3.2.1
gotchaIn `GeneralizedLinearRegressorCV`, the `deviance_path_` attribute was incorrectly scaled by `n_folds` in versions prior to 3.1.3, leading to misinterpretation of cross-validation deviance values.
fix
Upgrade to `glum>=3.1.3` for correct `deviance_path_` values in cross-validation.
affects: <3.1.3
Errors
Common errors & fixes
ValueError: Input contains NaN, infinity or a value too large for dtype('float64').
Using `InverseGaussianDistribution` with `glum` versions prior to 3.2.3 would cause `log_likelihood` to return NaN, propagating through the model fitting process.
fix
Upgrade your `glum` installation to version 3.2.3 or newer: `pip install --upgrade glum`.
TypeError: 'numpy.float64' object cannot be interpreted as an integer
In `glum` versions before 3.1.3, the `theta` setter for `NegativeBinomialDistribution` incorrectly rejected `numpy.number` types, leading to errors when attempting to assign a `theta` value derived from NumPy operations.
fix
Upgrade `glum` to version 3.1.3 or later: `pip install --upgrade glum`.
Predictions are inconsistent or incorrect when using alpha_search with categorical features.
A bug in `glum` versions prior to 3.2.1 caused incorrect predictions when specifying a particular `alpha` value after fitting with `alpha_search=True` and having categorical features in the dataset.
fix
Ensure you are using `glum` version 3.2.1 or newer. Upgrade using `pip install --upgrade glum`.
The `deviance_path_` attribute in `GeneralizedLinearRegressorCV` shows unexpectedly low values.
Before version 3.1.3, `deviance_path_` was incorrectly scaled down by a factor of `n_folds`, leading to underestimated deviance values.
fix
Upgrade your `glum` library to version 3.1.3 or newer to get correctly scaled `deviance_path_`: `pip install --upgrade glum`.
Upgrade
Version history
3.4.1latest on PyPI · released May 6, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
16
OpenAI (training)
1
Resources
glum — pip install glum · libregistry