Skip to main content

Extra plotting functionality for baycomp's Bayesian classifier comparison posteriors.

Project description

Baycomp Plotting

The baycomp_plotting is a python package for building good-looking plots of bayesian posteriors obtained with baycomp.

This package could be useful for scientific purposes, specially in the area of Machine Learning.

Author

Installation

This package can be installed using PIP.

pip install baycomp_plotting

Basic Usage

The package can be imported as follows:

import baycomp_plotting as bplt

Two plotting functions (tern, and dens), and one class with four matplotlib alternative colors (Color) are provided.

Colors

Four alternative colors to default matplotlib colors are provided:

Example:

import baycomp_plotting as bplt

print(bplt.Color.BLUE)

Output:

'#008ece'

Density plots

For plotting the comparison of two classifiers on a single dataset, dens function could be used. It's parameters are the following:

  • p: baycomp posterior.
  • label: label of the density function.
  • ls: line style (use a matplotlib line style) [default: -]
  • color: density function color [default: Color.BLUE]

Example:

import baycomp_plotting as bplt
import baycomp as bc

posterior = bc.CorrelatedTTest(left_classifier_acc, right_classifier_acc, rope=0.01)
fig = bplt.dens(posterior, label='C1', ls='-', color=bplt.Color.BLUE)

Output:

The output figure will have a new function named add_posterior so you can add more posteriors to the figure. The parameters are the same as for dens.

Example:

import baycomp_plotting as bplt
import baycomp as bc

posterior = bc.CorrelatedTTest(left_classifier_1_acc, right_classifier_acc, rope=0.01)
posterior_1 = bc.CorrelatedTTest(left_classifier_2_acc, right_classifier_acc, rope=0.01)
fig = bplt.dens(posterior, label='C1', ls='-', color=bplt.Color.BLUE)
fig.add_posterior(posterior_1, label='C2', ls=(0,(5,1)), color=bplt.Color.GRAY)
fig.legend() # you can show the legend

Output:

Ternary plots

For plotting the comparison of two classifiers on multiple datasets using a ternary plot, tern function could be used. It's parameters are the following:

  • p: baycomp posterior.
  • names: an array containing Left and Right region labels. [default: ["L", "R"]]

Example:

import baycomp_plotting as bplt
import baycomp as bc

posterior = bc.HierarchicalTest(left_classifier_acc, right_classifier_acc, rope=0.01)
fig = bplt.tern(posterior)

Output:

Comparison against baycomp default plots

Density:

Ternary:

Contribute

Feel free to submit any pull requests 😊

Acknowlegments

This work was supported by the pre-doctoral grant (EDU/1100/2017) of the Consejería de Educación of the Junta de Castilla y León, Spain, and the European Social Fund.

License

This work is licensed under GNU GPL v3.

Citation policy

Please, cite this work as:

@software{baycomp_plotting,
  author       = {Mario Juez-Gil},
  title        = {{mjuez/baycomp_plotting}},
  month        = nov,
  year         = 2020,
  publisher    = {Zenodo},
  version      = {v1.0},
  doi          = {10.5281/zenodo.4244542},
  url          = {https://doi.org/10.5281/zenodo.4244542}
}

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

baycomp_plotting-1.2.0.tar.gz (111.3 kB view details)

Uploaded Source

Built Distribution

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

baycomp_plotting-1.2.0-py3-none-any.whl (31.2 kB view details)

Uploaded Python 3

File details

Details for the file baycomp_plotting-1.2.0.tar.gz.

File metadata

  • Download URL: baycomp_plotting-1.2.0.tar.gz
  • Upload date:
  • Size: 111.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for baycomp_plotting-1.2.0.tar.gz
Algorithm Hash digest
SHA256 4d470b835a983493363245a577a032749067f7c2625b24910dbc4dcabb3ab79d
MD5 d78bd25151b3da5ef694844093c6a786
BLAKE2b-256 4dfdb9881a7eb0542ea7425452f756510b9786e7a8f25f79b1004691ec07801d

See more details on using hashes here.

Provenance

The following attestation bundles were made for baycomp_plotting-1.2.0.tar.gz:

Publisher: release.yml on mjuez/baycomp_plotting

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file baycomp_plotting-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for baycomp_plotting-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e3859d5c73c5523e32868e5b6a759acc7dbc216231eaee41cb4f93fdbd550594
MD5 d452a66ff3adc1f3f02dddf7053806d5
BLAKE2b-256 1d26ea9d85b6847944bedeeb0cfd6a6327d6c4b4302b99c859c63d8f080126dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for baycomp_plotting-1.2.0-py3-none-any.whl:

Publisher: release.yml on mjuez/baycomp_plotting

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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