Extracting and plotting pareto fronts
Project description
sweet_pareto
Generate pareto fronts from pandas data frames
Usage
Best used inside a Jupyter Notebook. There are some quirks trying to make the plot and save natively with
matplotlib that I'm trying to sort out still.
Plot API
Install from pypi with pip or uv (or compliant tool of your choice) with pip install sweetpareto[plot].
Using the Palmer penguins dataset
import seaborn
import sweetpareto.vis as spv
df = seaborn.load_dataset("penguins")
>>> spv.pareto_plot(
... df,
... xs="flipper_length_mm",
... y="body_mass_g",
... maxx=False,
... maxy=True,
... col="sex",
... color="species",
... marker="species",
... height=4,
... aspect=1,
... theme="whitegrid",
... show_points=True,
... )
There is also spv.Pareto, a seaborn.objects.Stat
object that can be used to make your own plots with the seaborn.objects API
Core API
The sweetpareto module provides two functions: pareto_indices and pareto_index. The names are similar, but their purposes are slightly
different.
If you have a pandas.DataFrame, you can obtain a subsection of the index for the points that reside on the pareto front with pareto_index
>>> ix = sweetpareto.pareto_index(
... df,
... x="flipper_length_mm",
... y="body_mass_g",
... maxx=False,
... maxy=True,
... )
>>> ix
Index([28, 20, 122, 31, 29, 39, 7, 81, 109, 252, 259, 329, 233, 297, 237], dtype='int64')
This Index can be used to access the whole data set along the pareto front with df.loc[ix].
pareto_index uses pareto_indices behind the scenes. This function works on two equal sized
vectors x and y. The returned list contains the positions in x and y that make up the pareto front.
The core API can be installed with pip install sweetpareto, excluding the [plot] extras group.
Engines
For a little future proofing / YAGNI-as-a-service, everything discussed this far also accepts an engines argument. Presently,
the only engine that is supported is a pure numpy + python routine for finding the pareto front. The goal of this API
is to eventually ship some more performant engines
Dev
The dev environment is managed with hatch. I'm still learning this so if you see something that needs improvement, please
let me know.
Release
For a given version X.Y.Z,
hatch version "X.Y.Z"
will update the project version. This will need to be committed and, eventually, merged to main.
Once the new version has been merged to main,
- Make a tag with
git tag - Build with
hatch build - Publish with
hatch publish
Test images
Build the test images with
hatch run test:gen-test-images
and then, upon acceptable review of images in tests/baseline, stage and commit the new images.
License
This project is made available under the terms of the Mozilla Public License, version 2.0
Issues / features
If you find something doesn't work as expected, or you'd like to propose a feature, please consider creating an issue on the codeberg issue tracker.
This is a fun project for me to work on, and it's also an excuse for me to try out new (to me) Python things. So, be aware that I might not respond immediately, and may not take up your issue or feature request. That doesn't mean it's not worthwhile. Just that I've got a life outside of this project and will not be able to handle all requests.
Contributing
Thank you! I'm glad you found this project interesting enough to put some of your valuable time into a pull request. See the CONTRIBUTING.md file for advice.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sweetpareto-1.0.0rc0.tar.gz.
File metadata
- Download URL: sweetpareto-1.0.0rc0.tar.gz
- Upload date:
- Size: 189.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b92533dede0028a7c8fa7beb0fa79fbefd946d1e000908bd6da723d00cc5efd
|
|
| MD5 |
b4e2f3e5ae64c4a1c331f71cf6e0d678
|
|
| BLAKE2b-256 |
60f3a5758d4356072526ba4f948e1e7bcb70e25df72fb753c5f13a61524ee651
|
File details
Details for the file sweetpareto-1.0.0rc0-py3-none-any.whl.
File metadata
- Download URL: sweetpareto-1.0.0rc0-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63351b709fe6c4f8963fcc452a477d5b774b534e8ab72444d7c8e9a27796c14c
|
|
| MD5 |
085586e4adbe66d7e3998014af53df3d
|
|
| BLAKE2b-256 |
fc2599f5342436f864fd7e66b382a825fe6f491eb0705701386a51e5695cfaea
|