Skip to main content

A python library for preference based learning using pairwise comparisons.

Project description


Actions Status Documentation Status Binder

A python library for preference based learning using pairwise comparisons.


If we want to recommend a personalised list of items to an individual. We could consider the following:

  1. Ask the individual to manually rank all items.
  2. Ask the individual to provide weights based on their preferences of different features (size, cost, weight etc), and calculate the weighted value of each item.
  3. Find similar people and base recommendations on what these people also like.
  4. Ask the individual to compare a small number of alternatives, and derive feature weights from those comparisons.

Option 1 quickly becomes an enormous burden on the user as the number of items increases.

Option 2 is difficult for the user to do and replicate. What exactly does it mean if the weight assigned to one feature is double the weight assigned to another?

Option 3 requires lots of data, a way to determine similarity between individuals, and may not be fully personalised.

Option 4 is enabled by preference based learning using pairwise comparisons.


pip install pypbl


Dependencies and packaging is managed using Poetry.

Install poetry and clone the repository

To create a virtual environment and install dependencies

poetry install

To run tests

poetry run pytest --cov=src --cov-branch --cov-fail-under=90 tests/

To run linting

poetry run flake8 src/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics


This project is licensed under the MIT License - see the file for details



  • Improve suggestion engine as using entropy is expensive to compute.
  • Include dynasty sampling algorithm and PyMC3 or perhaps pyMC4
  • Include preference elicitation using Gaussian Processes see gp_pref_elicit for non-linear utility functions.

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

pypbl-0.3.1.tar.gz (8.8 kB view hashes)

Uploaded source

Built Distribution

pypbl-0.3.1-py3-none-any.whl (8.3 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page