LeaveOneOutRLS - RLS with leave-one-out regularization parameter selection

class rlscore.learner.rls.LeaveOneOutRLS(X, Y, kernel='LinearKernel', basis_vectors=None, regparams=None, measure=None, **kwargs)

Bases: rlscore.predictor.predictor.PredictorInterface

Regularized least-squares regression/classification. Wrapper code that selects regularization parameter automatically based on leave-one-out cross-validation.

Parameters:
X : {array-like, sparse matrix}, shape = [n_samples, n_features]

Data matrix

Y : {array-like}, shape = [n_samples] or [n_samples, n_labels]

Training set labels

kernel : {‘LinearKernel’, ‘GaussianKernel’, ‘PolynomialKernel’, ‘PrecomputedKernel’, …}

kernel function name, imported dynamically from rlscore.kernel

basis_vectors : {array-like, sparse matrix}, shape = [n_bvectors, n_features], optional

basis vectors (typically a randomly chosen subset of the training data)

regparams : {array-like}, shape = [grid_size] (optional)

regularization parameter values to be tested, default = [2^-15,…,2^15]

measure : function(Y, P) (optional)

a performance measure from rlscore.measure used for model selection, default sqerror (mean squared error)

Other Parameters:
 
Typical kernel parameters include:
bias : float, optional

LinearKernel: the model is w*x + bias*w0, (default=1.0)

gamma : float, optional

GaussianKernel: k(xi,xj) = e^(-gamma*<xi-xj,xi-xj>) (default=1.0) PolynomialKernel: k(xi,xj) = (gamma * <xi, xj> + coef0)**degree (default=1.0)

coef0 : float, optional

PolynomialKernel: k(xi,xj) = (gamma * <xi, xj> + coef0)**degree (default=0.)

degree : int, optional

PolynomialKernel: k(xi,xj) = (gamma * <xi, xj> + coef0)**degree (default=2)

Notes

Computational complexity of training (model selection is basically free due to fast regularization and leave-one-out): m = n_samples, d = n_features, l = n_labels, b = n_bvectors, r=grid_size

O(m^3 + dm^2 + rlm^2): basic case

O(md^2 + rlmd): Linear Kernel, d < m

O(mb^2 + rlmb): Sparse approximation with basis vectors

Basic information about RLS, and a description of the fast leave-one-out method can be found in [1].

References

[1] Ryan Rifkin, Ross Lippert. Notes on Regularized Least Squares. Technical Report, MIT, 2007.

Attributes:
predictor : {LinearPredictor, KernelPredictor}

trained predictor

cv_performances : array, shape = [grid_size]

leave-one-out performances for each grid point

cv_predictions : array, shape = [grid_size, n_samples] or [grid_size, n_samples, n_labels]

leave-one-out predictions

regparam : float

regparam from grid with best performance

predict(X)

Predicts outputs for new inputs

Parameters:
X : {array-like, sparse matrix}, shape = [n_samples, n_features]

input data matrix

Returns:
P : array, shape = [n_samples, n_tasks]

predictions