Toolbox for model building and forecasting
Project description
greybox
Python port of the R greybox package — a toolbox for regression model building and forecasting.
Installation
pip install greybox
For more installation options, see the Installation wiki page.
Quick Example
import numpy as np
import pandas as pd
from greybox import ALM, formula
# Generate sample data
np.random.seed(42)
n = 200
data = pd.DataFrame({
"y": np.random.normal(10, 2, n),
"x1": np.random.normal(5, 1, n),
"x2": np.random.normal(3, 1, n),
})
data["y"] = 2 + 0.5 * data["x1"] - 0.3 * data["x2"] + np.random.normal(0, 1, n)
# Parse formula and fit model
result = formula("y ~ x1 + x2", data=data)
model = ALM(distribution="dnorm")
model.fit(result.data, result.formula)
# Summary
print(model.summary())
# Predict with intervals
pred = model.predict(result.data, interval="prediction", level=0.95)
print(pred.mean[:5])
# Include AR terms (ARIMA-like models)
# For example, ARIMA(1,1,0) model with Log-Normal distribution:
model = ALM(distribution="dlnorm", orders=(1, 1, 0))
model.fit(X, y)
Supported Distributions
| Category | Distributions |
|---|---|
| Continuous | dnorm, dlaplace, ds, dgnorm, dlgnorm, dfnorm, drectnorm, dt |
| Positive | dlnorm, dinvgauss, dgamma, dexp, dchisq |
| Count | dpois, dnbinom, dgeom |
| Bounded | dbeta, dlogitnorm, dbcnorm |
| CDF-based | pnorm, plogis |
| Other | dalaplace, dbinom |
Features
- ALM (Augmented Linear Model): Likelihood-based regression with 26 distributions
- Formula parser: R-style formulas (
y ~ x1 + x2,log(y) ~ .,y ~ 0 + x1) with support for backshift operator - stepwise(): IC-based variable selection with partial correlations
- CALM(): Combine ALM models based on IC weights
- Forecast error measures: MAE, MSE, RMSE, MAPE, MASE, MPE, sMAPE, and more
- Variable processing:
xreg_expander(lags/leads),xreg_multiplier(interactions),temporal_dummy - Distributions: 27 distribution families with density, CDF, quantile, and random generation
- Association: Partial correlations and measures of association
- Diagnostics: Model diagnostics and validation
Links
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file greybox-1.0.0.tar.gz.
File metadata
- Download URL: greybox-1.0.0.tar.gz
- Upload date:
- Size: 113.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
737e8001581fe1672a9fe8029be0c06815102ab6f01a0f2ea5b55eee4e9f59aa
|
|
| MD5 |
168a2317cc1afa4091179b578a2f7699
|
|
| BLAKE2b-256 |
4e3c0334a805bf916e48d19ae0b77c039e16d8a76c8786610dd5a2c458116793
|
Provenance
The following attestation bundles were made for greybox-1.0.0.tar.gz:
Publisher:
release.yml on config-i1/greybox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
greybox-1.0.0.tar.gz -
Subject digest:
737e8001581fe1672a9fe8029be0c06815102ab6f01a0f2ea5b55eee4e9f59aa - Sigstore transparency entry: 980772155
- Sigstore integration time:
-
Permalink:
config-i1/greybox@edd0e98a079dbce4b6c69af35cb5ad760fb608a7 -
Branch / Tag:
refs/tags/v2.0.8 - Owner: https://github.com/config-i1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@edd0e98a079dbce4b6c69af35cb5ad760fb608a7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file greybox-1.0.0-py3-none-any.whl.
File metadata
- Download URL: greybox-1.0.0-py3-none-any.whl
- Upload date:
- Size: 99.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a068e615441cd2f71ef657a3862db3ca9c35ea258f95e27edb1dd247fd282713
|
|
| MD5 |
d84001236cff64c492fe0f42391fb6bd
|
|
| BLAKE2b-256 |
5fd37473f7baaf5590f4940850de463c885d76f190646709d4918df1ee6fea8d
|
Provenance
The following attestation bundles were made for greybox-1.0.0-py3-none-any.whl:
Publisher:
release.yml on config-i1/greybox
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
greybox-1.0.0-py3-none-any.whl -
Subject digest:
a068e615441cd2f71ef657a3862db3ca9c35ea258f95e27edb1dd247fd282713 - Sigstore transparency entry: 980772195
- Sigstore integration time:
-
Permalink:
config-i1/greybox@edd0e98a079dbce4b6c69af35cb5ad760fb608a7 -
Branch / Tag:
refs/tags/v2.0.8 - Owner: https://github.com/config-i1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@edd0e98a079dbce4b6c69af35cb5ad760fb608a7 -
Trigger Event:
release
-
Statement type: