Home

Awesome

plot_utils

Plotting library for conformal prediction metrics, intended to facilitate fast testing in e.g. notebooks.

Examples

Example usage can be found in the User Guide Classification notebook, User Guide Regression notebook and Nonconformist+plot_utils notebook.

Package dependencies

See requirements.txt for package dependencies used in our development. Here are links to the libraries:

API

Data format

The code internally use numpy ndarrays for matrices and vectors, but tries to be agnostic about input being either list, arrays or Pandas equivalents. But for performance reasons it is recommended that conversion to numpy format is done when using several of the methods in this library, as a new conversion would be performed for each function call.

Rendering backends

Internally this library requires matplotlib and (optionally) Seaborn. Only the plot_confusion_matrix_heatmap has a hard requirement for seaborn to be available, otherwise this library only interacts with the matplotlib classes/functions and use seaborn-settings for generating somewhat nicer plots (in our opinion). Styling and colors can always be changed through the matplotlib API.

Data loading

To simplify loading and conversions of data the plot_utils library now has some utility functions for loading CSV files with predictions or validation metrics (typically generated using CPSign. For regression we require predictions to be the same as used in nonconformist, using 2D or 3D tensors in numpy ndarrays of shape (num_examples,2) or (num_examples,2,num_significance_levels), where the second dimension contains the lower and upper limits of the prediction intervals.

Supported plots

Classification

Regression

Set up

To use this package you clone this repo and add the <base-path>/python/src/ directory to your $PYTHONPATH.

Developer notes

We should aim at supplying proper docstrings, following the numpy docstring guide.

Testing

All python-tests are located in the tests folder and are meant to be run using pytest. Test should be started from standing in the python folder and can be run "all at once" (python -m pytest), "per file" (python -m pytest tests/pharmbio/cp/metrics/clf_metrics_test.py), or a single test function (python -m pytest tests/pharmbio/cp/metrics/clf_metrics_test.py::TestConfusionMatrix::test_with_custom_labels).

TODOs:

Add/finish the following plots:

Change log: