GC.OS Logo
GC.OS Brandmark

pyGAM

pyGAM is an open-source Python library for building Generalized Additive Models.

Back to Projects

pyGAM is an open-source Python library for building Generalized Additive Models (GAMs) with a strong emphasis on modularity, performance, and interpretability. Its API is designed to feel familiar to users of scikit-learn and SciPy, making GAMs accessible without sacrificing statistical rigor.

The library provides a flexible framework for regression, classification, and distributional modeling using smooth, interpretable functions.

Purpose

Generalized Additive Models offer a powerful middle ground between linear models and fully black-box machine learning approaches. pyGAM was created to make GAMs easy to use in practice while retaining their core strengths: interpretability, flexibility, and solid statistical foundations.

It is suitable for exploratory data analysis, applied modeling, and research-focused workflows.

Core Features

  • Generalized Additive Models for regression and classification

  • Familiar, scikit-learn–like API

  • Modular design for terms, penalties, and distributions

  • Automatic smoothing and model tuning

  • High-performance numerical optimization

  • Strong focus on model interpretability

Generalized Additive Models

Additive Modeling

pyGAM models relationships as a sum of smooth functions, allowing non-linear effects while keeping each feature’s influence interpretable.

Terms and Interactions

The library supports:

  • Smooth terms for continuous variables

  • Factor terms for categorical variables

  • Interaction terms between features

  • Custom model specifications

This enables flexible model construction without opaque representations.

Supported Modeling Tasks

Regression

pyGAM supports regression with multiple distributions, including Gaussian and Poisson, making it suitable for continuous, count, and rate data.

Classification

Binary and multi-class classification are supported through appropriate link functions and distributions.

Distributional Modeling

Advanced use cases include:

  • Poisson regression and histogram smoothing

  • Expectile regression

  • Custom likelihoods and link functions

Optimization and Constraints

Penalties and Constraints

pyGAM includes built-in support for smoothness penalties and constraints, allowing users to:

  • Control model complexity

  • Enforce monotonicity or shape constraints

  • Improve generalization and stability

Automatic Tuning

Models can automatically tune smoothing parameters, reducing manual trial-and-error and improving usability.

Performance and Dependencies

pyGAM is optimized for performance using NumPy and SciPy and supports optional acceleration through sparse linear algebra libraries for large or constrained models.

The library is tested on modern Python versions and integrates cleanly into scientific Python environments.

Use Cases

  • Interpretable regression and classification

  • Exploratory data analysis

  • Modeling non-linear relationships with transparency

  • Statistical learning in applied research

  • Alternatives to black-box machine learning models

Scientific Foundation

pyGAM is academically grounded and citable via Zenodo. It is used in research and applied settings where model interpretability and statistical validity are essential.

Open Source

pyGAM is released under the Apache License 2.0 and developed openly on GitHub. The project welcomes contributions, bug reports, and feature ideas from the community.

GC.OS supports pyGAM as an open-source project that enables transparent, interpretable, and statistically sound machine learning.

Team

Daniel Servén

Daniel Servén