himalaya.kernel_ridge.solve_kernel_ridge_cv_eigenvalues

himalaya.kernel_ridge.solve_kernel_ridge_cv_eigenvalues(K, Y, alphas=1.0, score_func=<function l2_neg_loss>, cv=5, fit_intercept=False, local_alpha=True, n_targets_batch=None, n_targets_batch_refit=None, n_alphas_batch=None, conservative=False, Y_in_cpu=False)[source]

Solve kernel ridge regression with a grid search over alphas.

Parameters
Karray of shape (n_samples, n_samples)

Input kernel.

Yarray of shape (n_samples, n_targets)

Target data.

alphasfloat or array of shape (n_alphas, )

Range of ridge regularization parameter.

score_funccallable

Function used to compute the score of predictions versus Y.

cvint or scikit-learn splitter

Cross-validation splitter. If an int, KFold is used.

fit_interceptboolean

Whether to fit an intercept. If False, K should be centered (see KernelCenterer), and Y must be zero-mean over samples.

local_alphabool

If True, alphas are selected per target, else shared over all targets.

n_targets_batchint or None

Size of the batch for over targets during cross-validation. Used for memory reasons. If None, uses all n_targets at once.

n_targets_batch_refitint or None

Size of the batch for over targets during refit. Used for memory reasons. If None, uses all n_targets at once.

n_alphas_batchint or None

Size of the batch for over alphas. Used for memory reasons. If None, uses all n_alphas at once.

conservativebool

If True, when selecting the hyperparameter alpha, take the largest one that is less than one standard deviation away from the best. If False, take the best.

Y_in_cpubool

If True, keep the target values Y in CPU memory (slower).

Returns
best_alphasarray of shape (n_targets, )

Selected best hyperparameter alphas.

dual_weightsarray of shape (n_samples, n_targets)

Kernel ridge coefficients refit on the entire dataset, using selected best hyperparameters alpha. Always stored on CPU memory.

cv_scoresarray of shape (n_targets, )

Cross-validation scores averaged over splits, for the best alpha.