# whittaker > A next-generation Generalized Additive Model (GAM) library for Python. ## Docs ### API Reference #### Core model > The primary GAM interface for fitting, predicting, and inspecting models. - [GAM](https://rich-iannone.github.io/whittaker/reference/GAM.html): Generalized Additive Model with automatic smoothness selection - [PredictionResult](https://rich-iannone.github.io/whittaker/reference/PredictionResult.html): Container returned by `GAM.predict()` for `type="response"` or `type="link"` - [TermsPredictionResult](https://rich-iannone.github.io/whittaker/reference/TermsPredictionResult.html): Container returned by `GAM.predict(type="terms")` - [PosteriorPredictResult](https://rich-iannone.github.io/whittaker/reference/PosteriorPredictResult.html): Container returned by `GAM.posterior_predict()` - [GoodnessOfFit](https://rich-iannone.github.io/whittaker/reference/GoodnessOfFit.html): Goodness-of-fit statistics returned by `GAM.goodness_of_fit()` - [GamCheckResult](https://rich-iannone.github.io/whittaker/reference/GamCheckResult.html): Container returned by `GAM.gam_check()`, bundling residual diagnostics with fit summary - [CheckDataResult](https://rich-iannone.github.io/whittaker/reference/CheckDataResult.html): Structured diagnostic data underlying `check()` plots - [SensitivityResult](https://rich-iannone.github.io/whittaker/reference/SensitivityResult.html): Result of a smoothing-parameter sensitivity analysis - [PartialDependenceResult](https://rich-iannone.github.io/whittaker/reference/PartialDependenceResult.html): Partial dependence data for one smooth term - [SimultaneousCIResult](https://rich-iannone.github.io/whittaker/reference/SimultaneousCIResult.html): Simultaneous confidence band for a smooth term #### Inference > Result types from parametric and smooth tests, concurvity, influence diagnostics, derivatives, marginal effects, and contrasts. - [ParametricTestResult](https://rich-iannone.github.io/whittaker/reference/ParametricTestResult.html): Result of a Wald test for a parametric coefficient - [SmoothTestResult](https://rich-iannone.github.io/whittaker/reference/SmoothTestResult.html): Result of an approximate test for H_0: f_j = 0 - [ConcurvityResult](https://rich-iannone.github.io/whittaker/reference/ConcurvityResult.html): Concurvity diagnostics for smooth terms - [KCheckResult](https://rich-iannone.github.io/whittaker/reference/KCheckResult.html): Result of basis dimension adequacy check for a single smooth - [InfluenceResult](https://rich-iannone.github.io/whittaker/reference/InfluenceResult.html): Observation-level influence diagnostics - [DispersionTestResult](https://rich-iannone.github.io/whittaker/reference/DispersionTestResult.html): Result of a dispersion test - [VIFResult](https://rich-iannone.github.io/whittaker/reference/VIFResult.html): Variance inflation factor for a parametric term - [DerivativeResult](https://rich-iannone.github.io/whittaker/reference/DerivativeResult.html): Result of smooth derivative estimation - [MarginalEffectResult](https://rich-iannone.github.io/whittaker/reference/MarginalEffectResult.html): Result of marginal effect estimation for one smooth term - [ContrastResult](https://rich-iannone.github.io/whittaker/reference/ContrastResult.html): Result of a pairwise comparison between two conditions #### Formula > Formula parsing and term specifications for model construction. - [Formula](https://rich-iannone.github.io/whittaker/reference/Formula.html): A parsed model formula: the structured representation of a `GAM`'s right-hand side - [SmoothTerm](https://rich-iannone.github.io/whittaker/reference/SmoothTerm.html): A smooth term, e.g. `s(x1, bs='cr', k=10)` or `te(x1, x2)` - [LinearTerm](https://rich-iannone.github.io/whittaker/reference/LinearTerm.html): A plain linear (parametric) term, e.g. `x1` or `group` - [InteractionTerm](https://rich-iannone.github.io/whittaker/reference/InteractionTerm.html): A two-way parametric interaction between two bare covariates, e.g. `x1 * x2` - [OffsetTerm](https://rich-iannone.github.io/whittaker/reference/OffsetTerm.html): An offset term, e.g. `offset(log_exposure)` - [parse_formula](https://rich-iannone.github.io/whittaker/reference/parse_formula.html): Parse *formula* into a `~whittaker.formula.terms.Formula` #### Response families > Distributions and link functions for the response variable. Each family specifies a conditional distribution and a link function relating the linear predictor to the conditional mean. - [Family](https://rich-iannone.github.io/whittaker/reference/Family.html): Abstract family defining the response distribution and link function - [Gaussian](https://rich-iannone.github.io/whittaker/reference/Gaussian.html): Gaussian (Normal) family with identity link - [Poisson](https://rich-iannone.github.io/whittaker/reference/Poisson.html): Poisson family with log (canonical) link - [Binomial](https://rich-iannone.github.io/whittaker/reference/Binomial.html): Binomial family with logit (canonical) link - [Gamma](https://rich-iannone.github.io/whittaker/reference/Gamma.html): Gamma family with log link - [NegativeBinomial](https://rich-iannone.github.io/whittaker/reference/NegativeBinomial.html): Negative Binomial family with log link (NB2 parameterization) - [Beta](https://rich-iannone.github.io/whittaker/reference/Beta.html): Beta regression family with logit link - [Tweedie](https://rich-iannone.github.io/whittaker/reference/Tweedie.html): Tweedie family with log link - [TweedieEstimated](https://rich-iannone.github.io/whittaker/reference/TweedieEstimated.html): Tweedie family with variance power estimated by profile likelihood - [tw](https://rich-iannone.github.io/whittaker/reference/tw.html): Create a Tweedie family with estimated variance power - [InverseGaussian](https://rich-iannone.github.io/whittaker/reference/InverseGaussian.html): Inverse Gaussian family with log link - [CoxPH](https://rich-iannone.github.io/whittaker/reference/CoxPH.html): Cox proportional hazards family for survival analysis - [OrderedCategorical](https://rich-iannone.github.io/whittaker/reference/OrderedCategorical.html): Ordered categorical (proportional odds / cumulative logit) family - [Multinomial](https://rich-iannone.github.io/whittaker/reference/Multinomial.html): Multinomial logistic family for unordered categorical responses #### Distributional families (GAMLSS) > Location-scale-shape families for distributional regression, where multiple distribution parameters are modeled as smooth functions. - [GAMLSSFamily](https://rich-iannone.github.io/whittaker/reference/GAMLSSFamily.html): Abstract base class for GAMLSS distributional families - [GaussianLS](https://rich-iannone.github.io/whittaker/reference/GaussianLS.html): Gaussian location-scale family for GAMLSS - [GammaLS](https://rich-iannone.github.io/whittaker/reference/GammaLS.html): Gamma location-scale family for GAMLSS - [BetaLS](https://rich-iannone.github.io/whittaker/reference/BetaLS.html): Beta family for GAMLSS with mean-precision parameterisation - [ZeroInflatedPoisson](https://rich-iannone.github.io/whittaker/reference/ZeroInflatedPoisson.html): Zero-inflated Poisson (ZIP) family for GAMLSS - [ZeroInflatedNegativeBinomial](https://rich-iannone.github.io/whittaker/reference/ZeroInflatedNegativeBinomial.html): Zero-inflated negative binomial (ZINB) family for GAMLSS #### Distributional regression > The GAMLSS fitting interface for distributional regression models. - [GAMLSS](https://rich-iannone.github.io/whittaker/reference/GAMLSS.html): Generalized Additive Model for Location, Scale, and Shape - [GAMLSSPrediction](https://rich-iannone.github.io/whittaker/reference/GAMLSSPrediction.html): Result of `GAMLSS.predict()` #### Smooth basis types > Basis constructors for smooth terms. Each basis type can be specified in a formula via `bs=` or constructed directly for advanced use. - [SmoothBasis](https://rich-iannone.github.io/whittaker/reference/SmoothBasis.html): Abstract base class for all smooth basis types - [TPRS](https://rich-iannone.github.io/whittaker/reference/TPRS.html): Thin Plate Regression Splines (TPRS) - [CRS](https://rich-iannone.github.io/whittaker/reference/CRS.html): Cubic Regression Splines (natural cubic splines with quantile knots) - [PSpline](https://rich-iannone.github.io/whittaker/reference/PSpline.html): P-Spline: B-spline basis with m-th order difference penalty - [CyclicCRS](https://rich-iannone.github.io/whittaker/reference/CyclicCRS.html): Cyclic Cubic Regression Spline (periodic natural cubic spline) - [CyclicPSpline](https://rich-iannone.github.io/whittaker/reference/CyclicPSpline.html): Cyclic P-Spline (periodic B-spline basis with circular difference penalty) - [ShrinkageTPRS](https://rich-iannone.github.io/whittaker/reference/ShrinkageTPRS.html): Shrinkage Thin Plate Regression Spline - [ShrinkageCRS](https://rich-iannone.github.io/whittaker/reference/ShrinkageCRS.html): Shrinkage Cubic Regression Spline - [DuchonSpline](https://rich-iannone.github.io/whittaker/reference/DuchonSpline.html): Duchon spline basis - [GaussianProcess](https://rich-iannone.github.io/whittaker/reference/GaussianProcess.html): Gaussian process (kriging) smooth basis - [SoapFilm](https://rich-iannone.github.io/whittaker/reference/SoapFilm.html): Soap film smooth for 2-D domains with complex boundaries - [MRFBasis](https://rich-iannone.github.io/whittaker/reference/MRFBasis.html): Markov random field basis for areal spatial data - [AdaptiveTPRS](https://rich-iannone.github.io/whittaker/reference/AdaptiveTPRS.html): Adaptive Thin Plate Regression Spline - [RandomEffectBasis](https://rich-iannone.github.io/whittaker/reference/RandomEffectBasis.html): Random effect basis (one-hot encoding with identity penalty) - [FactorSmoothBasis](https://rich-iannone.github.io/whittaker/reference/FactorSmoothBasis.html): Factor-smooth interaction basis (per-level smooth with shared penalties) - [TensorProductBasis](https://rich-iannone.github.io/whittaker/reference/TensorProductBasis.html): Tensor product of marginal smooth bases (`te()`-style interaction smooth) - [TensorInteractionBasis](https://rich-iannone.github.io/whittaker/reference/TensorInteractionBasis.html): Tensor product interaction basis (`ti()`-style pure interaction smooth) - [TensorProductBasisT2](https://rich-iannone.github.io/whittaker/reference/TensorProductBasisT2.html): Tensor product basis with full penalty decomposition (`t2()`-style interaction smooth) #### Shape-constrained smooths > Monotone, convex, and concave smooth basis types with built-in shape enforcement. - [MonotonePSpline](https://rich-iannone.github.io/whittaker/reference/MonotonePSpline.html): Shape-constrained P-spline: monotone increasing or decreasing - [ConvexPSpline](https://rich-iannone.github.io/whittaker/reference/ConvexPSpline.html): Shape-constrained P-spline: convex or concave #### Quantile regression > Quantile GAMs with optional non-crossing constraints. - [QuantileGAM](https://rich-iannone.github.io/whittaker/reference/QuantileGAM.html): Non-crossing quantile GAM - [QuantileGAMResult](https://rich-iannone.github.io/whittaker/reference/QuantileGAMResult.html): Result container for a fitted QuantileGAM - [QuantileFamily](https://rich-iannone.github.io/whittaker/reference/QuantileFamily.html): Quantile regression via the Extended Log-F (ELF) pseudo-family - [calibrate_sigma](https://rich-iannone.github.io/whittaker/reference/calibrate_sigma.html): Find the ELF bandwidth sigma that minimises out-of-sample ELF loss #### Conformal prediction > Distribution-free prediction intervals via split, CV+, and jackknife+ conformal methods. - [conformal_fit](https://rich-iannone.github.io/whittaker/reference/conformal_fit.html): Fit a GAM with conformal calibration - [conformal_coverage](https://rich-iannone.github.io/whittaker/reference/conformal_coverage.html): Compute empirical coverage of conformal intervals on held-out data - [ConformalPredictor](https://rich-iannone.github.io/whittaker/reference/ConformalPredictor.html): A calibrated conformal predictor ready to produce intervals - [ConformalResult](https://rich-iannone.github.io/whittaker/reference/ConformalResult.html): Result of conformal prediction #### Causal inference > Causal GAMs using double/debiased machine learning (DML), heterogeneous treatment effect estimation (CATE), and mediation analysis. - [CausalGAM](https://rich-iannone.github.io/whittaker/reference/CausalGAM.html): Causal GAM for treatment effect estimation - [TreatmentEffect](https://rich-iannone.github.io/whittaker/reference/TreatmentEffect.html): Average treatment effect estimate with inference - [CATEResult](https://rich-iannone.github.io/whittaker/reference/CATEResult.html): Conditional average treatment effect estimates - [mediation_analysis](https://rich-iannone.github.io/whittaker/reference/mediation_analysis.html): Causal mediation analysis with GAM nuisance models - [MediationResult](https://rich-iannone.github.io/whittaker/reference/MediationResult.html): Mediation analysis results #### Streaming and online GAMs > Incremental fitting via sufficient statistics for data that arrives in batches. - [StreamingGAM](https://rich-iannone.github.io/whittaker/reference/StreamingGAM.html): Streaming / online GAM - [StreamingSnapshot](https://rich-iannone.github.io/whittaker/reference/StreamingSnapshot.html): A snapshot of streaming GAM state at a point in time #### Multi-response GAMs > Joint fitting of multiple response variables with optional residual correlation modeling. - [MultiResponseGAM](https://rich-iannone.github.io/whittaker/reference/MultiResponseGAM.html): Multi-response GAM - [MultiResponseResult](https://rich-iannone.github.io/whittaker/reference/MultiResponseResult.html): Prediction result for multiple responses - [ResidualCorrelation](https://rich-iannone.github.io/whittaker/reference/ResidualCorrelation.html): Estimated residual correlation structure #### Functional regression > Scalar-on-function regression where predictors include functional covariates (curves). - [FunctionalGAM](https://rich-iannone.github.io/whittaker/reference/FunctionalGAM.html): Scalar-on-function GAM - [FunctionalTerm](https://rich-iannone.github.io/whittaker/reference/FunctionalTerm.html): Specification for a functional covariate - [CoefficientFunction](https://rich-iannone.github.io/whittaker/reference/CoefficientFunction.html): Estimated coefficient function beta(t) for a functional term #### Large datasets > Scalable GAM fitting for datasets that exceed memory or benefit from parallel computation. - [BigGAM](https://rich-iannone.github.io/whittaker/reference/BigGAM.html): GAM for large datasets using discretized fitting - [PolarsGAM](https://rich-iannone.github.io/whittaker/reference/PolarsGAM.html): GAM that reads data from Polars LazyFrames, DataFrames, or files - [DuckDBGAM](https://rich-iannone.github.io/whittaker/reference/DuckDBGAM.html): GAM that reads data directly from DuckDB via SQL #### Cross-validation > K-fold cross-validation for GAMs with deviance, MSE, and MAE scoring. - [cross_validate](https://rich-iannone.github.io/whittaker/reference/cross_validate.html): K-fold cross-validation for a GAM specification - [CVResult](https://rich-iannone.github.io/whittaker/reference/CVResult.html): Result of `cross_validate()` #### scikit-learn integration > GAM estimators compatible with the scikit-learn API for use in pipelines and grid search. - [GAMRegressor](https://rich-iannone.github.io/whittaker/reference/GAMRegressor.html): Scikit-learn compatible GAM regressor - [GAMClassifier](https://rich-iannone.github.io/whittaker/reference/GAMClassifier.html): Scikit-learn compatible GAM classifier (binary) #### Serialization > Save and load fitted GAMs, and convert to/from mgcv-compatible dictionaries. - [save_gam](https://rich-iannone.github.io/whittaker/reference/save_gam.html): Save a fitted GAM to a `.npz` archive - [load_gam](https://rich-iannone.github.io/whittaker/reference/load_gam.html): Load a fitted GAM from a `.npz` archive created by `save_gam` - [from_mgcv_dict](https://rich-iannone.github.io/whittaker/reference/from_mgcv_dict.html): Import an mgcv `gam` object exported as a dictionary - [to_mgcv_dict](https://rich-iannone.github.io/whittaker/reference/to_mgcv_dict.html): Export a fitted GAM as an mgcv-compatible dictionary #### Datasets > Built-in synthetic datasets for testing and examples. - [load_dataset](https://rich-iannone.github.io/whittaker/reference/load_dataset.html): Load a built-in example dataset - [list_datasets](https://rich-iannone.github.io/whittaker/reference/list_datasets.html): Return a list of all built-in datasets with their metadata #### Model comparison > Compare fitted GAMs by information criteria, LOO-CV, WAIC, and stacking weights. - [compare](https://rich-iannone.github.io/whittaker/reference/compare.html): Compare multiple fitted GAMs in a summary table - [ComparisonResult](https://rich-iannone.github.io/whittaker/reference/ComparisonResult.html): Result of comparing multiple fitted GAMs - [ComparisonRow](https://rich-iannone.github.io/whittaker/reference/ComparisonRow.html): One row of a model comparison table - [loo_compare](https://rich-iannone.github.io/whittaker/reference/loo_compare.html): Compare two PSIS-LOO results computed on the same observations - [LOOResult](https://rich-iannone.github.io/whittaker/reference/LOOResult.html): Result of PSIS-LOO cross-validation on a fitted GAM - [LOOComparison](https://rich-iannone.github.io/whittaker/reference/LOOComparison.html): Comparison of two PSIS-LOO results on the same data - [waic_compare](https://rich-iannone.github.io/whittaker/reference/waic_compare.html): Compare two WAIC results computed on the same observations - [WAICResult](https://rich-iannone.github.io/whittaker/reference/WAICResult.html): Result of WAIC computation on a fitted GAM - [WAICComparison](https://rich-iannone.github.io/whittaker/reference/WAICComparison.html): Comparison of two WAIC results on the same data - [stacking](https://rich-iannone.github.io/whittaker/reference/stacking.html): Compute stacking weights for model averaging - [StackingResult](https://rich-iannone.github.io/whittaker/reference/StackingResult.html): Result of stacking weight optimization #### Posterior predictive checks > Simulate data from the posterior predictive distribution to assess model fit. - [PPCResult](https://rich-iannone.github.io/whittaker/reference/PPCResult.html): Result of a posterior predictive check on a fitted GAM #### Plotting > Diagnostic and partial-effect plotting functions. - [check](https://rich-iannone.github.io/whittaker/reference/check.html): Produce GAM diagnostic plots - [partial_effects](https://rich-iannone.github.io/whittaker/reference/partial_effects.html): Plot partial effects with confidence bands for each smooth term #### Model matrix > Low-level model matrix construction from formulas and data. - [build_model_matrix](https://rich-iannone.github.io/whittaker/reference/build_model_matrix.html): Assemble the full design matrix and penalty structure from a formula - [predict_matrix](https://rich-iannone.github.io/whittaker/reference/predict_matrix.html): Build the prediction design matrix for new data - [ModelMatrix](https://rich-iannone.github.io/whittaker/reference/ModelMatrix.html): Numeric design matrix, penalties, and metadata produced by :func:`build_model_matrix` - [SmoothInfo](https://rich-iannone.github.io/whittaker/reference/SmoothInfo.html): Metadata describing where one smooth term lives inside a `ModelMatrix`