adelie.state.gaussian_pin_cov#

adelie.state.gaussian_pin_cov(*, A: MatrixCovBase32 | MatrixCovBase64, constraints: list[ConstraintBase32 | ConstraintBase64], groups: ndarray, alpha: float, penalty: ndarray, screen_set: ndarray, lmda_path: ndarray, rsq: float, screen_beta: ndarray, screen_grad: ndarray, screen_is_active: ndarray, active_set_size: int, active_set: ndarray, max_active_size: int | None = None, max_iters: int = 100000, tol: float = 1e-07, rdev_tol: float = 0.0001, newton_tol: float = 1e-12, newton_max_iters: int = 1000, n_threads: int = 1)[source]#

Creates a Gaussian, pin, covariance method state object.

Define the following quantities:

  • \(X_c\) as \(X\) if intercept is False and otherwise the column-centered version.

  • \(y_c\) as \(y - \eta^0\) if intercept is False and otherwise the centered version.

Parameters:
AUnion[MatrixCovBase32, MatrixCovBase64]

Covariance matrix \(X_c^\top W X_c\). It is typically one of the matrices defined in adelie.matrix submodule.

constraints(G,) list[Union[ConstraintBase32, ConstraintBase64]]

List of constraints for each group. constraints[i] is the constraint object corresponding to group i. If constraints[i] is None, then the i th group is unconstrained. If None, every group is unconstrained.

groups(G,) ndarray

List of starting indices to each group where G is the number of groups. groups[i] is the starting index of the i th group.

alphafloat

Elastic net parameter. It must be in the range \([0,1]\).

penalty(G,) ndarray

Penalty factor for each group in the same order as groups. It must be a non-negative vector.

screen_set(s,) ndarray

List of indices into groups that correspond to the screen groups. screen_set[i] is i th screen group. screen_set must contain at least the true (optimal) active groups when the regularization is given by lmda.

lmda_path(L,) ndarray

The regularization path to solve for. It is recommended that the path is sorted in decreasing order.

rsqfloat

The change in unnormalized \(R^2\) given by \(\|y_c-X_c\beta_{\mathrm{old}}\|_{W}^2 - \|y_c-X_c\beta_{\mathrm{curr}}\|_{W}^2\). Usually, \(\beta_{\mathrm{old}} = 0\) and \(\beta_{\mathrm{curr}}\) is given by screen_beta.

screen_beta(ws,) ndarray

Coefficient vector on the screen set. screen_beta[b:b+p] is the coefficient for the i th screen group where k = screen_set[i], b = screen_begins[i], and p = group_sizes[k]. The values can be arbitrary but it is recommended to be close to the solution at lmda.

screen_grad(ws,) ndarray

Gradient \(X_{c,k}^\top W (y_c-X_c\beta)\) on the screen groups \(k\) where \(\beta\) is given by screen_beta. screen_grad[b:b+p] is the gradient for the i th screen group where k = screen_set[i], b = screen_begins[i], and p = group_sizes[k].

screen_is_active(s,) ndarray

Boolean vector that indicates whether each screen group in groups is active or not. screen_is_active[i] is True if and only if screen_set[i] is active.

active_set_sizeint

Number of active groups. active_set[i] is only well-defined for i in the range [0, active_set_size).

active_set(G,) ndarray

List of indices into screen_set that correspond to active groups. screen_set[active_set[i]] is the i th active group. An active group is one with non-zero coefficient block, that is, for every i th active group, screen_beta[b:b+p] == 0 where j = active_set[i], k = screen_set[j], b = screen_begins[j], and p = group_sizes[k].

max_active_sizeint, optional

Maximum number of active groups allowed. The function will return a valid state and guarantees to have active set size less than or equal to max_active_size. If None, it will be set to the total number of groups. Default is None.

max_itersint, optional

Maximum number of coordinate descents. Default is int(1e5).

tolfloat, optional

Coordinate descent convergence tolerance. Default is 1e-7.

rdev_tolfloat, optional

Relative percent deviance explained tolerance. If the difference of the last two training percent deviance explained exceeds the last training percent deviance explained scaled by this quantity, then the solver terminates. Default is 1e-4.

newton_tolfloat, optional

Convergence tolerance for the BCD update. Default is 1e-12.

newton_max_itersint, optional

Maximum number of iterations for the BCD update. Default is 1000.

n_threadsint, optional

Number of threads. Default is 1.

Returns:
wrap

Wrapper state object.