QueryRankRLS - ranking regularized least-squares, query-structured data

class rlscore.learner.query_rankrls.QueryRankRLS(X, Y, qids, regparam=1.0, kernel='LinearKernel', basis_vectors=None, **kwargs)

Bases: rlscore.predictor.predictor.PredictorInterface

RankRLS algorithm for learning to rank

Implements the learning algorithm for learning from query-structured data.

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

qids : list of query ids, shape = [n_samples]

Training set qids

regparam : float, optional

regularization parameter, regparam > 0 (default=1.0)

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)

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: m = n_samples, d = n_features, l = n_labels, b = n_bvectors

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

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

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

RankRLS algorithm was first introduced in [1], extended version of the work and the efficient leave-query-out cross-validation method implemented in the method ‘holdout’ are found in [2].

References

[1] Tapio Pahikkala, Evgeni Tsivtsivadze, Antti Airola, Jorma Boberg and Tapio Salakoski Learning to rank with pairwise regularized least-squares. In Thorsten Joachims, Hang Li, Tie-Yan Liu, and ChengXiang Zhai, editors, SIGIR 2007 Workshop on Learning to Rank for Information Retrieval, pages 27–33, 2007.

[2] Tapio Pahikkala, Evgeni Tsivtsivadze, Antti Airola, Jouni Jarvinen, and Jorma Boberg. An efficient algorithm for learning to rank from preference graphs. Machine Learning, 75(1):129-165, 2009.

Attributes:
predictor : {LinearPredictor, KernelPredictor}

trained predictor

holdout(indices)

Computes hold-out predictions for a trained RLS.

Parameters:
indices : list of indices, shape = [n_hsamples]

list of indices of training examples belonging to the set for which the hold-out predictions are calculated. Should correspond to one query.

Returns:
F : array, shape = [n_hsamples, n_labels]

holdout query predictions

Notes

Computational complexity of holdout: m = n_samples, d = n_features, l = n_labels, b = n_bvectors, h=n_hsamples

O(h^3 + lmh): basic case

O(min(h^3 + lh^2, d^3 + ld^2) +ldh): Linear Kernel, d < m

O(min(h^3 + lh^2, b^3 + lb^2) +lbh): Sparse approximation with basis vectors

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

solve(regparam=1.0)

Trains the learning algorithm, using the given regularization parameter.

Parameters:
regparam : float (regparam > 0)

regularization parameter

Notes

Computational complexity of re-training: m = n_samples, d = n_features, l = n_labels, b = n_bvectors

O(lm^2): basic case

O(lmd): Linear Kernel, d < m

O(lmb): Sparse approximation with basis vectors