adelie.cv.CVGrpnetResult#

class adelie.cv.CVGrpnetResult(lmdas: ndarray, losses: ndarray, avg_losses: ndarray, best_idx: int)[source]#

Result of K-fold CV group elastic net.

Methods

__init__(lmdas, losses, avg_losses, best_idx)

fit(X, glm, **grpnet_params)

Fits group elastic net until the best CV \(\lambda\).

plot_loss()

Plots the average K-fold CV loss.

Attributes

lmdas

The common regularization path used for all folds.

losses

losses[k,i] is the CV loss when validating on fold k at lmdas[i].

avg_losses

avg_losses[i] is the average CV loss at lmdas[i].

best_idx

Argmin of avg_losses.

__init__(lmdas: ndarray, losses: ndarray, avg_losses: ndarray, best_idx: int) None[source]#
fit(X: ndarray | MatrixNaiveBase32 | MatrixNaiveBase64, glm: GlmBase32 | GlmBase64 | GlmMultiBase32 | GlmMultiBase64, **grpnet_params)[source]#

Fits group elastic net until the best CV \(\lambda\).

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.

glmUnion[GlmBase32, GlmBase64, GlmMultiBase32, GlmMultiBase64]

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

**grpnet_paramsoptional

Parameters to adelie.solver.grpnet().

Returns:
state

Result of calling adelie.solver.grpnet().

plot_loss()[source]#

Plots the average K-fold CV loss.

For each fitted \(\lambda\), the average K-fold CV loss as well as an error bar of one standard deviation (above and below) is plotted.

lmdas: ndarray#

The common regularization path used for all folds.

losses: ndarray#

losses[k,i] is the CV loss when validating on fold k at lmdas[i].

avg_losses: ndarray#

avg_losses[i] is the average CV loss at lmdas[i].

best_idx: int#

Argmin of avg_losses.