Create plots and graphs for your Machine Learning projects.
Project description
Plots and graphs
Save your time. Create plots and graphs that look nice.
The repository will contain a collection of useful, useable, and reuseable plots and graphs.
I know, ChatGPT is your friend and helper and with the right prompt can create any graph you would like to have. However, it is very helpful to configure everything once and properly and only finetune the detail is necessary.
So there is a collection for different types of plots and graphs. Some might be great for visualizing data in general such as raincloud graphs or ridgeline plots while others might be more suitable for specific use cases. These could include visualizing the results for a binary classifier, for which plots such as a confusion matrix or a callibration plot can be created.
Overview of graphs and plots
TBD!
-
binary classifier
- Accuracy
- Calibration Curve
- Classification Report
- Confusion Matrix
- ROC curve (AUROC)
- y_prob histogram
-
comparing distributions
- raincloud plot
Gallery
TBD! Here, each new plot should be rendered and included as a small reference.
Calibration Curve | Classification Report | Confusion Matrix |
ROC Curve (AUROC) with bootstrapping | Precision-Recall Curve | y_prob histogram |
Raincloud |
Other resources
Why create everything from scratch, if some things exist already? Here are some helpful resources.
- Python Graph Gallery - great collection of graphs. First look at their gallery, then check out their 'BEST' collection for inspiration.
- Scientific Visualization Book - definitely check out the first part for essential tips for good graphs. And deep dive further to improve your visualization game.
- CHARTIO - must read on how to choose colors and color palettes.
Install
Install the package via pip.
pip install plotsandgraphs
Alternatively install the package from git.
git clone https://github.com/joshuawe/plots_and_graphs
cd plots_and_graphs
pip install -e .
Usage
Example usage of results from a binary classifier for a calibration curve.
import matplotlib.pyplot as plt
import numpy as np
import plotsandgraphs as pandg
# create some predictions of a hypothetical binary classifier
n_samples = 1000
y_true = np.random.choice([0,1], n_samples, p=[0.4, 0.6]) # the true class labels 0 or 1, with class imbalance 40:60
y_prob = np.zeros(y_true.shape) # a model's probability of class 1 predictions
y_prob[y_true==1] = np.random.beta(1, 0.6, y_prob[y_true==1].shape)
y_prob[y_true==0] = np.random.beta(0.5, 1, y_prob[y_true==0].shape)
# show prob distribution
fig_hist = pandg.binary_classifier.plot_y_prob_histogram(y_prob, y_true, save_fig_path=None)
# create calibration curve
fig_auroc = pandg.binary_classifier.plot_calibration_curve(y_prob, y_true, save_fig_path=None)
# --- OPTIONAL: Customize figure ---
# get axis of figure and change title
axes = fig_auroc.get_axes()
ax0 = axes[0]
ax0.set_title('New Title for Calibration Plot')
fig_auroc.show()
Requirements
Show all requirements
Contributors
- DALL-E 3 created the project logo on 17th October 2023. Prompt used: Illustration of a stylized graph with colorful lines and bars, representing data visualization, suitable for a project logo named 'plots and graphs'.
Reference
Of course we are happy to be mentioned in any way, if our repository has helped you. You can also share this repository with your friends and collegues to make their lives easier. Cheers!
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
File details
Details for the file plotsandgraphs-0.1.2b0.tar.gz
.
File metadata
- Download URL: plotsandgraphs-0.1.2b0.tar.gz
- Upload date:
- Size: 26.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bd29b789dc655c2c0c11253f1ae76f94600d7eacee40f9aa57cc00c93320b5f |
|
MD5 | 5099cd994681c9b5871327a85ef8743e |
|
BLAKE2b-256 | 44854099dbe320225eba78e49423ff4cf49e495d307cb8e0acedceda113f78f2 |
Provenance
File details
Details for the file plotsandgraphs-0.1.2b0-py3-none-any.whl
.
File metadata
- Download URL: plotsandgraphs-0.1.2b0-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 393002d7ce32b774ec879d6f8012a16ae0cefcac9cd58b3d4c4ead78610386ae |
|
MD5 | c1cb13c0f7936fe689a7a694df919969 |
|
BLAKE2b-256 | 694d092d708764d492868a4f4b72404e8e5eeba228527f5367a9de23e9f99ceb |