adelie.diagnostic.predict#
- adelie.diagnostic.predict(X: ndarray | MatrixNaiveBase32 | MatrixNaiveBase64, betas: ndarray | csr_matrix, intercepts: ndarray, *, offsets: ndarray | None = None, n_threads: int = 1)[source]#
Computes the linear predictions.
The single-response linear prediction is given by
\[\begin{align*} \hat{\eta} = X\beta + \beta_0 \mathbf{1} + \eta^0 \end{align*}\]The multi-response linear prediction is given by
\[\begin{align*} \hat{\eta} = (X\otimes I_K) \beta + (\mathbf{1}\otimes I_k) \beta_0 + \eta^0 \end{align*}\]The single or multi-response is detected based on the shape of
intercepts
. Ifintercepts
one-dimensional, we assume single-response. Otherwise, we assume multi-response.- Parameters:
- X(n, p) Union[ndarray, MatrixNaiveBase32, MatrixNaiveBase64]
Feature matrix. It is typically one of the matrices defined in
adelie.matrix
submodule ornumpy.ndarray
.- betas(L, p) or (L, p*K) Union[ndarray, csr_matrix]
Coefficient vectors \(\beta\).
- intercepts(L,) or (L, K) ndarray
Intercepts \(\beta_0\).
- 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.- n_threadsint, optional
Number of threads. Default is
1
.
- Returns:
- linear_preds(L, n) or (L, n, K) ndarray
Linear predictions.