adelie.diagnostic.objective#

adelie.diagnostic.objective(X: ndarray | MatrixNaiveBase32 | MatrixNaiveBase64, glm: GlmBase32 | GlmBase64 | GlmMultiBase32 | GlmMultiBase64, betas: ndarray | csr_matrix, intercepts: ndarray, lmdas: ndarray, *, groups: ndarray | None = None, alpha: float = 1, penalty: ndarray | None = None, offsets: ndarray | None = None, relative: bool = True, add_penalty: bool = True, n_threads: int = 1)[source]#

Computes the group elastic net objective.

See adelie.solver.grpnet() for details.

Parameters:
X(n, p) Union[ndarray, MatrixNaiveBase32, MatrixNaiveBase64]

Feature matrix \(X\). It is typically one of the matrices defined in adelie.matrix submodule or numpy.ndarray.

glmUnion[GlmBase32, GlmBase64, GlmMultiBase32, GlmMultiBase64]

GLM object. It is typically one of the GLM classes defined in adelie.glm submodule.

betas(L, p) or (L, p*K) Union[ndarray, csr_matrix]

Coefficient vectors \(\beta\).

intercepts(L,) or (L, K) ndarray

Intercepts \(\beta_0\).

lmdas(L,) ndarray

Regularization parameters \(\lambda\). It is only used when add_penalty=True. Otherwise, the user may pass None.

groups(G,) ndarray, optional

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. If glm is of multi-response type, then groups[i] is the starting feature index of the i th group. In either case, groups[i] must then be a value in the range \(\{1,\ldots, p\}\). Default is None, in which case it is set to np.arange(p).

alphafloat, optional

Elastic net parameter \(\alpha\). It must be in the range \([0,1]\). It is only used when add_penalty=True. Otherwise, the user may pass None. Default is 1.

penalty(G,) ndarray, optional

Penalty factor for each group in the same order as groups. It must be a non-negative vector. It is only used when add_penalty=True. Default is None, in which case, it is set to np.sqrt(group_sizes).

offsets(n,) or (n, K) ndarray, optional

Observation offsets \(\eta^0\). Default is None, in which case, it is set to np.zeros(n) if y is single-response and np.zeros((n, K)) if multi-response.

relativebool, optional

If True, then the full loss, \(\ell(\eta^\star)\), is computed at the saturated model and the difference \(\ell(\eta)-\ell(\eta^\star)\) is provided, which will always be non-negative. This effectively computes loss relative to the saturated model. Default is True.

add_penaltybool, optional

If False, the regularization term is removed so that only the loss part is calculated. Default is True.

n_threadsint, optional

Number of threads. Default is 1.

Returns:
obj(L,) ndarray

Group elastic net objectives.