himalaya.kernel_ridge.solve_multiple_kernel_ridge_random_search¶
- himalaya.kernel_ridge.solve_multiple_kernel_ridge_random_search(Ks, Y, n_iter=100, concentration=[0.1, 1.0], alphas=1.0, score_func=<function l2_neg_loss>, cv=5, fit_intercept=False, return_weights=None, Xs=None, local_alpha=True, jitter_alphas=False, random_state=None, n_targets_batch=None, n_targets_batch_refit=None, n_alphas_batch=None, progress_bar=True, Ks_in_cpu=False, conservative=False, Y_in_cpu=False, diagonalize_method='eigh', return_alphas=False)[source]¶
Solve multiple kernel ridge regression using random search.
- Parameters
- Ksarray of shape (n_kernels, n_samples, n_samples)
Input kernels.
- Yarray of shape (n_samples, n_targets)
Target data.
- n_iterint, or array of shape (n_iter, n_kernels)
Number of kernel weights combination to search. If an array is given, the solver uses it as the list of kernel weights to try, instead of sampling from a Dirichlet distribution. Examples:
n_iter=np.eye(n_kernels) implement a winner-take-all strategy over kernels.
n_iter=np.ones((1, n_kernels))/n_kernels solves a (standard) kernel ridge regression.
- concentrationfloat, or list of float
Concentration parameters of the Dirichlet distribution. If a list, iteratively cycle through the list. Not used if n_iter is an array.
- 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, Ks should be centered (see KernelCenterer), and Y must be zero-mean over samples. Only available if return_weights == ‘dual’.
- return_weightsNone, ‘primal’, or ‘dual’
Whether to refit on the entire dataset and return the weights.
- Xsarray of shape (n_kernels, n_samples, n_features) or None
Necessary if return_weights == ‘primal’.
- local_alphabool
If True, alphas are selected per target, else shared over all targets.
- jitter_alphasbool
If True, alphas range is slightly jittered for each gamma.
- random_stateint, or None
Random generator seed. Use an int for deterministic search.
- 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.
- progress_barbool
If True, display a progress bar over gammas.
- Ks_in_cpubool
If True, keep Ks in CPU memory to limit GPU memory (slower). This feature is not available through the scikit-learn API.
- 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).- diagonalize_methodstr in {“eigh”, “svd”}
Method used to diagonalize the kernel.
- return_alphasbool
If True, return the best alpha value for each target.
- Returns
- deltasarray of shape (n_kernels, n_targets)
Best log kernel weights for each target.
- refit_weightsarray or None
Refit regression weights on the entire dataset, using selected best hyperparameters. Refit weights are always stored on CPU memory. If return_weights == ‘primal’, shape is (n_features, n_targets), if return_weights == ‘dual’, shape is (n_samples, n_targets), else, None.
- cv_scoresarray of shape (n_iter, n_targets)
Cross-validation scores per iteration, averaged over splits, for the best alpha. Cross-validation scores will always be on CPU memory.
- best_alphasarray of shape (n_targets, )
Best alpha value per target. Only returned if return_alphas is True.
- interceptarray of shape (n_targets,)
Intercept. Only returned when fit_intercept is True.