Skip to main content

fpqr package fpqr hex logo

PyPI version Python Downloads License CI Code style: black

Introduction

fpqr is a Python package that solves fast partial quantile regression (fPQR) models. The fpqr is a new methodology suitable for solving high dimensional regression problems where the response can be either a vector or a full matrix (this means that the response can have more than one dimension). Also, this methodology can deal with colinearity and outliers. It can be seen as an extension of partial least squares (PLS) to the quantile regression framework, as it shares some of the nice properties of PLS: it is a dimension reduction technique that obtains uncorrelated scores maximizing a quantile covariance between predictors and responses. But oposed to PLS fPQR is based on quantile regression, which makes it a robust, quantile based methodology suitable for dealing with outliers, heteroscedastic or heavy tailed datasets. The median estimator of the fPQR algorithm is a robust alternative to PLS, while other quantile levels can be computed and can provide additional information on the tails of the responses. A full description of the methodology can be seen in this paper.

The current version of the package supports the computation of the fPQR algorithm based on three quantile metrics denoted here as 'li', 'dodge' and 'choi' (based on the main authors of the papers where the metrics were proposed). The best results both in terms of prediction and computation time are generally obtained with the 'li' metric, which is the default value.

Requirements

The package makes use of some basic functions from scikit-learn numpy and asgl.

Usage example:

In the following example we will solve a synthetic dataset where the response is multidimensional.

import fpqr
from sklearn.datasets import make_regression

# Generate a dataset with 1000 observations, 10 predictive variables and 2 response variables.
x, y, true_beta = make_regression(n_samples=1000, n_features=10, n_informative=10, n_targets=2,
                                  bias=10.0, noise=2.0, shuffle=True, coef=True, random_state=None)

fpqr_li = fpqr.FPQRegression(quantile=0.5, n_components=3, metric='li')
fpqr_li.fit(x, y)

print(fpqr_li.coef_)
print(fpqr_li.intercept_)

predictions = fpqr_li.predict(x)

Dimension reduction with transform

fPQR is also a dimension-reduction technique: like PLS it projects the predictors onto a small set of uncorrelated latent components (the X-scores). Use transform (or fit_transform) to obtain those scores, e.g. to feed a downstream model or to use fPQR inside a scikit-learn Pipeline.

import fpqr
from sklearn.datasets import make_regression

x, y = make_regression(n_samples=1000, n_features=10, n_informative=10, n_targets=2,
                       bias=10.0, noise=2.0, random_state=0)

model = fpqr.FPQRegression(quantile=0.5, n_components=3, metric='li')

# Fit and project X onto the 3 latent components in one step.
scores = model.fit_transform(x, y)   # shape (1000, 3)

# Equivalently, project new data after fitting.
new_scores = model.transform(x)      # shape (n_samples, n_components)

Citing


If you use fPQR for academic work, we encourage you to cite our paper. Thank you for your support and we hope you find this package useful!

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fpqr-1.0.0.tar.gz (23.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fpqr-1.0.0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file fpqr-1.0.0.tar.gz.

File metadata

  • Download URL: fpqr-1.0.0.tar.gz
  • Upload date:
  • Size: 23.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for fpqr-1.0.0.tar.gz
Algorithm Hash digest
SHA256 aa8256cb6bf05a4e527280a50b471a5420297fad88c9d40af842346340cd86b6
MD5 aaa55e47b37c02b701ba1ba099035a3f
BLAKE2b-256 ba6bb079be43e7c6546963ce7643e29b3468743f098bae7cf886f4d197155129

See more details on using hashes here.

File details

Details for the file fpqr-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: fpqr-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for fpqr-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1ab054ebe5087c0f33c99a49b2e68176f50fce43e8642a05b3dc0af7aa36196a
MD5 6894c02d3ca843689210ed70b1068d9f
BLAKE2b-256 86550ef031ff2b64de3546869f5fd918eac8f2b5a403b0af471fe50e19141063

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page