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
muslpy 3.10–3.910 runs
build_error
glibcpy 3.10–3.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))
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.
fixUpgrade 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.
fixUpgrade `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.
fixEnsure 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.
fixUpgrade 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.