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!

Metadata

Release files for fpqr 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fpqr 1.0.0
File Size Uploaded
fpqr-1.0.0.tar.gz 23.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fpqr 1.0.0
File Interpreter ABI Platform
fpqr-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 45.0 kB

Release files / fpqr-1.0.0.tar.gz

Download URL fpqr-1.0.0.tar.gz
Size 23.7 kB
Tags Source
SHA-256 checksum
How to use checksums
aa8256cb6bf05a4e527280a50b471a5420297fad88c9d40af842346340cd86b6
BLAKE2b-256 checksum
How to use checksums
ba6bb079be43e7c6546963ce7643e29b3468743f098bae7cf886f4d197155129
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / fpqr-1.0.0-py3-none-any.whl

Download URL fpqr-1.0.0-py3-none-any.whl
Size 21.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ab054ebe5087c0f33c99a49b2e68176f50fce43e8642a05b3dc0af7aa36196a
BLAKE2b-256 checksum
How to use checksums
86550ef031ff2b64de3546869f5fd918eac8f2b5a403b0af471fe50e19141063
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page