Module Quantile

operalib.quantile implements joint quantile regression with Operator-Valued Kernels.

class operalib.quantile.Quantile(kernel='DGauss', probs=0.5, lbda=1e-05, gamma=None, gamma_quantile=0.0, eps=0.0, tol=None, nc_const=False, kernel_params=None, verbose=False)[source]

Joint quantile regression with operator-valued kernels. Joint quantile regression enables to learn and predict simultaneously several conditional quantiles (for prescribed quantile levels). Following the seminal work by Koenker and Basset (1978), the method minimizes an empirical risk based on the pinball loss and a squared-norm regularization. The hypothesis space considered here is the reproducing kernel Hilbert space generated by an operator-valued kernel chosen by the practitioner.

References

  • R. Koenker and G. Bassett “Regression Quantiles”, Econometrica, 46(1):33-50, 1978.
  • R. Koenker “Quantile Regression”, Cambridge University Press, Cambridge, New York, 2005.
  • M. Sangnier, O. Fercoq and F. d’Alche-Buc “Joint quantile regression in vector-valued RKHSs.” In Advances in Neural
operalib.Ridge
Operator-Valued kernel ridge regression
sklearn.Ridge
Linear ridge regression.
sklearn.KernelRidge
Kernel ridge regression.
sklearn.SVR
Support Vector Regression implemented using libsvm.

Examples

>>> import operalib as ovk
>>> import numpy as np
>>> n_samples, n_features = 10, 5
>>> quantile_levels = [0.1, 0.5, 0.9]
>>> rng = np.random.RandomState(0)
>>> y = rng.randn(n_samples)
>>> X = rng.randn(n_samples, n_features)
>>> reg = ovk.Quantile('DGauss', lbda=1.0)
>>> reg.fit(X, y)  
Quantile(gamma=None, gamma_quantile=0.0, kernel='DGauss',
    kernel_params=None, lbda=1.0, nc_const=False, probs=0.5, tol=None,
    verbose=False)
Attributes:
model : dict
coefs : {array-like}, shape [n_samples*n_probs, 1]

Dual coefficients of the kernel machine

intercept : {array-like}, shape [n_probs]

Vector of intercepts

Methods

fit(X, y) Fit joint quantile regression model.
get_params([deep]) Get parameters for this estimator.
pinball_loss(y_true, y_pred, probs) Compute the pinball loss.
predict(X) Predict conditional quantiles.
score(X, y[, sample_weight]) Compute the pinball score for the given dataset.
set_params(**params) Set the parameters of this estimator.
fit(X, y)[source]

Fit joint quantile regression model.

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

Training data.

targets : {array-like}, shape = [n_samples]

Target values.

Returns:
self : returns an instance of self.
get_params(deep=True)

Get parameters for this estimator.

Parameters:
deep : boolean, optional

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
params : mapping of string to any

Parameter names mapped to their values.

static pinball_loss(y_true, y_pred, probs)[source]

Compute the pinball loss.

Parameters:
pred : {array-like}, shape = [n_quantiles, n_samples] or [n_samples]

Predictions.

y : {array-like}, shape = [n_samples]

Targets.

Returns:
l : {array}, shape = [n_quantiles]

Average loss for each quantile level.

predict(X)[source]

Predict conditional quantiles.

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

Samples.

Returns:
y : {array}, shape = [n_samples, n_quantiles]

Returns predicted values for each prescribed quantile level.

score(X, y, sample_weight=None)[source]

Compute the pinball score for the given dataset.

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

Training data.

y : {array-like}, shape = [n_samples]

Target values.

Returns:
l : {float}

Average pinball score (the higher, the better).

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Returns:
self