Skip to main content

Compute the Pareto (non-dominated) set, i.e., skyline operator/query.

Project description

paretoset Build Status PyPI versionDownloads Black

paretoset operator/query for computing the Pareto (non-dominated) frontier.

There are two common ways to optimize a function of several variables:

  • Scalarization combines the variables using a weighted sum: this gives a linear ordering and single a minimum value.
  • paretoset query returns the Pareto (non-dominated) frontier: his gives a partial ordering and a set of minimal values.

The disadvantage of scalarization is that objectives must be weighted beforehand. The paretoset query returns every value that could be obtained by scalarization, but also values that could not have been found by scalarization.

Examples - paretoset queries for data analysis and insight

The folllowing example is from the paper "The paretoset Operator" by Börzsönyi et al.

Suppose you are going on holiday and you are looking for a hotel that is cheap and close to the beach. These two goals are complementary as the hotels near the beach tend to be more expensive.

The database system at your travel agents' is unable to decide which hotel is best for you, but it can at least present you all interesting hotels. Interesting are all hotels that are not worse than any other hotel in both dimensions. We call this set of interesting hotels the paretoset. From the paretoset, you can now your final decision, thereby weighing your personal preferences for price and distance to the beach.

from paretoset import paretoset
import pandas as pd

hotels = pd.DataFrame({"price": [50, 53, 62, 87, 83, 39, 60, 44], 
                       "distance_to_beach": [13, 21, 19, 13, 5, 22, 22, 25]})
mask = paretoset(hotels, sense=["min", "min"])
paretoset_hotels = hotels[mask]

Suppose you wish to query a database for salespeople that might be eligible for a raise. To find top performers (low salary, but high sales) for every department:

from paretoset import paretoset
import pandas as pd

salespeople = pd.DataFrame(
    {
        "salary": [94, 107, 67, 87, 153, 62, 43, 115, 78, 77, 119, 127],
        "sales": [123, 72, 80, 40, 64, 104, 106, 135, 61, 81, 162, 60],
        "department": ["c", "c", "c", "b", "b", "a", "a", "c", "b", "a", "b", "a"],
    }
)
mask = paretoset(salespeople, sense=["min", "max", "diff"])
top_performers = salespeople[mask]

Examples - Pareto efficient solutions (non-dominated front) in multiobjective optimization

Suppose you wish to query a database for salespeople that might be eligible for a raise. To find top performers (low salary, but high sales) for every department:

from paretoset import paretoset
import numpy as np
from collections import namedtuple

np.random.seed(42)

# Create Solution objects holding the problem solution and objective values
Solution = namedtuple("Solution", ["solution", "objective_values"])
solutions = [Solution(solution=object, objective_values=np.random.randn(2)) for _ in range(999)]

# Create an array of shape (solutions, objectives) and compute the non-dominated set
objective_values_array = np.vstack([s.objective_values for s in solutions])
mask = paretoset(objective_values_array, sense=[min, min])

# Filter the list of solutions, keeping only the non-dominated solutions
efficient_solutions = [solution for (solution, m) in zip(solutions, mask) if m]

Installation

The software is available through GitHub, and through PyPI. You may install the software using pip.

pip install paretoset

Contributing

You are very welcome to scrutinize the code and make pull requests if you have suggestions and improvements. Your submitted code must be PEP8 compliant, and all tests must pass.

Performance

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

paretoset-1.0.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

paretoset-1.0.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: paretoset-1.0.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for paretoset-1.0.0.tar.gz
Algorithm Hash digest
SHA256 254635423c557c383c2801680d6d8bf7de6134d5094f7613937446f02cee9885
MD5 0eb9cc5c2f615b57cd7a8e9695155acf
BLAKE2b-256 3c051fc518d160d374261e7052ba93af072db8ee8762e2d5aa78b14d72df3817

See more details on using hashes here.

File details

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

File metadata

  • Download URL: paretoset-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for paretoset-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 29d6478d8b8a566a7bcc8a3df405516b9fecfddf4774875129249328930b6cb6
MD5 f593d26dc16b414cc25f2e7b2ccbd692
BLAKE2b-256 ddb596b9072fd2379cfca42fcdc4acf06bfdeb2081b5c16899b07490588aef4c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page