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 ornumpy.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 passNone
.- 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 thei
th group. Ifglm
is of multi-response type, thengroups[i]
is the starting feature index of thei
th group. In either case,groups[i]
must then be a value in the range \(\{1,\ldots, p\}\). Default isNone
, in which case it is set tonp.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 passNone
. Default is1
.- 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 whenadd_penalty=True
. Default isNone
, in which case, it is set tonp.sqrt(group_sizes)
.- offsets(n,) or (n, K) ndarray, optional
Observation offsets \(\eta^0\). Default is
None
, in which case, it is set tonp.zeros(n)
ify
is single-response andnp.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 isTrue
.- add_penaltybool, optional
If
False
, the regularization term is removed so that only the loss part is calculated. Default isTrue
.- n_threadsint, optional
Number of threads. Default is
1
.
- Returns:
- obj(L,) ndarray
Group elastic net objectives.
See also