Skip to main content

Implementation of Kernel Ridge Regression Predictive Machine

Project description

KRRPM (Repository under construction)

Kernel Ridge Regression Predictive Machine

This repository contains an implementation of a Kernel Ridge Regression Predictive Machine, a non-parametric method for the probabilistic prediction of continuous values.

The implementation is available as a package that can be installed with pip

pip install krrpm

KRRPM

KRRPM[1] is a form of Conformal Predictive Distribution[2] which is a framework for non-parametric prior-free probabilistic prediction. The prediction for a test object is provided in the form of Cumulative Distribution Function for the label of test objects.

Predictive Distribution

A key advantage is that, under minimal assumptions, the KRRPM produces calibrated predictions, i.e. the probabilities assigned to events correspond to the relative frequencies of those events, within statistical fluctuation. The only assumption is that training data and test data be i.i.d., that is, independent and identically distributed.

A gentle introduction to Conformal Predictive Distributions can be found in the Tutorial at [https://cml.rhul.ac.uk/people/ptocca/HomePage/COPA2020___Tutorial_on_Predictive_Distributions.pdf]

KRRPM Implementation

The KRRPM.py file implements the Kernel Ridge Regression Predictive Machine. The API it exposes has been kept as similar as possible to that of scikit-learn regressors. This makes it interoperable with the scikit-learn framework, allowing in particular the use of its parameter optimization facilities (e.g. GridSearchCV).

An instance of the KRRPM regressor is first created with the constructor KRRPM(), which takes a scalar a as regularization parameter and a choice of kernel. The regression can be then fit() on the training data. The predictions are obtained with the predict() method; in keeping with the scikit-learn conventions, the predict() method returns a vector with one scalar (as opposed to a distribution) for each supplied test object. The value corresponds to the median in the distribution computed for the test object. The predictive distributions are in a data attribute (predicted_distributions) of the regressor, which is populated when the predict() method is called. Each predictive distribution (which corresponds in a sense to a Cumulative Distribution Function, as mentioned above) is expressed as a step-wise function specified by an array of 'n' floats. The steps have all "height" 1/n and the elements of the array specify their location.

The implementation uses O(n^2) memory and O(n^3) time.

Some effort has been put into minimizing the use of memory. As a reference, a training set of 80,000 objects was used successfully to train a KRRPM model on a server with 132GB of RAM.

KRRPM Example

The notebook KRRPM-Example.ipynb in this repository provides a complete example of the application of KRRPM. It can be run by clicking on the badge below.

Binder

Acknowledgements

This implementation was developed while at the Centre for Reliable Machine Learning, Royal Holloway, University of London. The author is grateful to AstraZeneca for the grant R10911 "Automated Chemical Synthesis".

References

[1]: "Conformal Predictive Distributions with Kernels", V. Vovk et al., 2018 [https://link.springer.com/chapter/10.1007/978-3-319-99492-5_4]
[2]: "Nonparametric Predictive Distributions Based on Conformal Prediction", V. Vovk, 2019, [https://doi.org/10.1007/s10994-018-5755-8]

Project details


Download files

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

Source Distribution

krrpm-1.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

krrpm-1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file krrpm-1.0.tar.gz.

File metadata

  • Download URL: krrpm-1.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.6

File hashes

Hashes for krrpm-1.0.tar.gz
Algorithm Hash digest
SHA256 f922953a031d7a7585619e26bfabedcdee1d04838cedb8bfbef45ce3e7bb614c
MD5 338751f91607795dc277434dc0456ecd
BLAKE2b-256 4611ae04bb1e2a1bea872d6c7cdd66eacee7b47f39ec679129274908908468cb

See more details on using hashes here.

File details

Details for the file krrpm-1.0-py3-none-any.whl.

File metadata

  • Download URL: krrpm-1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.6

File hashes

Hashes for krrpm-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9bbcf94fe1f32e91f0ab50163e4c9a2fd6eaa080ab1dbfad57f46334b62d242
MD5 9d6c3b9344011e73545503871e01c37a
BLAKE2b-256 ca1c9f0c69f6fb89b0f9d30c882016be6ca7711f61cd3e8fd6eacae7fdcff030

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 Pingdom Monitoring Sentry Error logging StatusPage Status page