Skip to content

Estimators

Online GAMLSS

rolch.OnlineGamlss

The online/incremental GAMLSS class.

__init__

__init__(distribution, forget: float = 0.0, method: str = 'ols', do_scale: Union[Dict, bool] = True, expect_intercept: Union[Dict, bool] = True, estimation_kwargs: Optional[Dict] = None, max_it_outer: int = 30, max_it_inner: int = 30, abs_tol_outer: float = 0.001, abs_tol_inner: float = 0.001, rel_tol_outer: float = 1e-05, rel_tol_inner: float = 1e-05, rss_tol_inner: float = 1.5)

Initialise the online GAMLSS Model

Parameters:

Name Type Description Default
distribution Distribution

The parametric distribution

required
forget float

The forget factor. Defaults to 0.0.

0.0
method str

The estimation method. Defaults to "ols".

'ols'
do_scale Optional[Dict]

Whether to scale the input matrices. Defaults to None, which implies that all inputs will be scaled. Note that the scaler assumes that the first column of each \(X\) contains the intercept.

True
estimation_kwargs Optional[Dict]

Dictionary of estimation method kwargs. Defaults to None.

None
max_it_outer int

Maximum outer iterations for the RS algorithm. Defaults to 30.

30
max_it_inner int

Maximum inner iterations for the RS algorithm. Defaults to 30.

30
abs_tol_outer float

Absolute tolerance on the Deviance in the outer fit. Defaults to 1e-3.

0.001
abs_tol_inner float

Absolute tolerance on the Deviance in the inner fit. Defaults to 1e-3.

0.001
rel_tol_outer float

Relative tolerance on the Deviance in the outer fit. Defaults to 1e-20.

1e-05
rel_tol_inner float

Relative tolerance on the Deviance in the inner fit. Defaults to 1e-20.

1e-05
rss_tol_inner float

Tolerance for increasing RSS in the inner fit. Defaults to 1.5.

1.5

fit

fit(y: np.ndarray, x0: np.ndarray, x1: Optional[np.ndarray] = None, x2: Optional[np.ndarray] = None, x3: Optional[np.ndarray] = None, sample_weights: Optional[np.ndarray] = None, beta_bounds: Dict[int, Tuple] = None)

Fit the online GAMLSS model.

Note

The user is only required to provide the design matrix \(X\) for the first distribution parameters. If for some distribution parameter no design matrix is provided, ROLCH will model the parameter using an intercept.

Note

The provision of bounds for the coefficient vectors is only possible for LASSO/coordinate descent estimation.

Parameters:

Name Type Description Default
y ndarray

Response variable \(Y\).

required
x0 ndarray

Design matrix for the 1st distribution parameter \(X_\mu\)

required
x1 Optional[ndarray]

Design matrix for the 2nd distribution parameter \(X_\sigma\). Defaults to None.

None
x2 Optional[ndarray]

Design matrix for the 3rd distribution parameter \(X_\nu\). Defaults to None.

None
x3 Optional[ndarray]

Design matrix for the 4th distribution parameter \(X_\tau\). Defaults to None.

None
sample_weights Optional[ndarray]

User-defined sample weights. Defaults to None.

None
beta_bounds Dict[int, Tuple]

Bounds for the \(eta\) in the coordinate descent algorithm. The user needs to provide a dict with a mapping of tuples to distribution parameters 0, 1, 2, and 3 potentially. Defaults to None.

None

predict

predict(x0: np.ndarray, x1: Optional[np.ndarray] = None, x2: Optional[np.ndarray] = None, x3: Optional[np.ndarray] = None, what: str = 'response', return_contributions: bool = False) -> np.ndarray

Predict the distibution parameters given input data.

Parameters:

Name Type Description Default
x0 ndarray

Design matrix for the 1st distribution parameter \(X_\mu\)

required
x1 Optional[ndarray]

Design matrix for the 2nd distribution parameter \(X_\sigma\). Defaults to None.

None
x2 Optional[ndarray]

Design matrix for the 3rd distribution parameter \(X_\nu\). Defaults to None.

None
x3 Optional[ndarray]

Design matrix for the 4th distribution parameter \(X_\tau\). Defaults to None.

None
what str

Predict the response or the link. Defaults to "response".

'response'
return_contributions bool

Whether to return a Tuple[prediction, contributions] where the contributions of the individual covariates for each distribution parameter's predicted value is specified. Defaults to False.

False

Raises:

Type Description
ValueError

Raises if what is not in ["link", "response"].

Returns:

Type Description
ndarray

np.ndarray: Predicted values for the distribution.

update

update(y: np.ndarray, x0: np.ndarray, x1: Optional[np.ndarray] = None, x2: Optional[np.ndarray] = None, x3: Optional[np.ndarray] = None, sample_weights: Optional[np.ndarray] = None)

Update the fit for the online GAMLSS Model.

Warning

Currently, the algorithm only takes single-step updates. Batch updates are planned for the first stable version.

Note

The beta_bounds from the initial fit are still valid for the update.

Parameters:

Name Type Description Default
y ndarray

Response variable \(Y\).

required
x0 ndarray

Design matrix for the 1st distribution parameter \(X_\mu\)

required
x1 Optional[ndarray]

Design matrix for the 2nd distribution parameter \(X_\sigma\). Defaults to None.

None
x2 Optional[ndarray]

Design matrix for the 3rd distribution parameter \(X_\nu\). Defaults to None.

None
x3 Optional[ndarray]

Design matrix for the 4th distribution parameter \(X_\tau\). Defaults to None.

None
sample_weights Optional[ndarray]

User-defined sample weights. Defaults to None.

None