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

η^=Xβ+β01+η0

The multi-response linear prediction is given by

η^=(XIK)β+(1Ik)β0+η0

The single or multi-response is detected based on the shape of intercepts. If intercepts 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 or numpy.ndarray.

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

Coefficient vectors β.

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

Intercepts β0.

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

Observation offsets η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.

n_threadsint, optional

Number of threads. Default is 1.

Returns:
linear_preds(L, n) or (L, n, K) ndarray

Linear predictions.