emulators.glm
Generalized Linear Model (GLM) emulator.
Extends linear regression to non-Gaussian responses via a link function (currently Gaussian/'linear' or 'poisson'), built on statsmodels. Useful when outputs are counts or otherwise not well modeled by plain OLS.
Classes
| Name | Description |
|---|---|
| GLM | Generalized Linear Model (GLM) emulator. |
GLM
emulators.glm.GLM(x=None, y=None, test_fraction=0.25, link='linear')Generalized Linear Model (GLM) emulator.
Fits a generalized linear model with a configurable link function ('linear' for a Gaussian family, 'poisson' for count data), allowing non-Gaussian output distributions while keeping the model fast and interpretable.
Example
import numpy as np, pandas as pd
from historymatching.emulators.glm import GLM
x = pd.DataFrame({'beta': np.random.rand(40), 'gamma': np.random.rand(40)})
y = pd.DataFrame({'cases': (50 * x['beta']).round()})
em = GLM(x, y, link='poisson')
em.train()
pred = em.predict(x)Methods
| Name | Description |
|---|---|
| get_hyperparameters | Return GLM hyperparameters as a JSON-serializable dict. |
| predict | Predict an output using the trained emulator. |
| print_emulator_description | Display detailed specifications (for example, emulator coefficients) |
| train | Fits a Generalised Linear Model. |
get_hyperparameters
emulators.glm.GLM.get_hyperparameters()Return GLM hyperparameters as a JSON-serializable dict.
predict
emulators.glm.GLM.predict(x)Predict an output using the trained emulator.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| x | pd.DataFrame | Input data. Pandas dataframe with columns representing parameter values. | required |
Returns
| Name | Type | Description |
|---|---|---|
| EmulationResults | EmulationResults with predicted values and uncertainty intervals. |
print_emulator_description
emulators.glm.GLM.print_emulator_description()Display detailed specifications (for example, emulator coefficients) for the trained emulator.
train
emulators.glm.GLM.train()Fits a Generalised Linear Model.