Skip to content

Commit c5a72df

Browse files
committed
update readme
1 parent b80c009 commit c5a72df

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

README.md

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,41 +75,50 @@ Why create everything from scratch, if some things exist already? Here are some
7575
+ [CHARTIO](https://chartio.com/learn/charts/how-to-choose-colors-data-visualization/) - must read on how to choose colors and color palettes.
7676

7777

78-
# How to use
79-
> TBD: How to use the functions. What is their standardization? How can a figure be altered?
78+
# Install
8079

81-
Install the package (currently).
80+
Install the package via pip.
8281
```bash
83-
pip install -e .
82+
pip install plotsandgraphs
8483
```
8584

86-
Install the package (in the future).
85+
Alternativelynstall the package from git.
8786
```bash
88-
pip install plotsandgraphs
87+
git clone https://github.com/joshuawe/plots_and_graphs
88+
cd plots_and_graphs
89+
pip install -e .
8990
```
9091

91-
Example usage for a calibration curve.
92+
# Usage
93+
94+
Example usage of results from a binary classifier for a calibration curve.
9295

9396
```python
94-
import plotsandgraphs
9597
import matplotlib.pyplot as plt
9698
import numpy as np
99+
import plotsandgraphs as pandg
97100

98-
# create some data
101+
# create some predictions of a hypothetical binary classifier
99102
n_samples = 1000
100-
y_prob = np.random.uniform(0, 1, n_samples) # the probability of class 1 predictions
101-
y_true = np.random.choice([0,1], n_samples) # the actually corresponding class labels
103+
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
102104

103-
# create figure
104-
fig_auroc = plotsandgraphs.binary_classifier.plot_calibration_curve(y_prob, y_true, save_fig_path=None)
105+
y_prob = np.zeros(y_true.shape) # a model's probability of class 1 predictions
106+
y_prob[y_true==1] = np.random.beta(1, 0.6, y_prob[y_true==1].shape)
107+
y_prob[y_true==0] = np.random.beta(0.5, 1, y_prob[y_true==0].shape)
105108

106-
# customize figure
109+
# show prob distribution
110+
fig_hist = pandg.binary_classifier.plot_y_prob_histogram(y_prob, y_true, save_fig_path=None)
111+
112+
# create calibration curve
113+
fig_auroc = pandg.binary_classifier.plot_calibration_curve(y_prob, y_true, save_fig_path=None)
114+
115+
116+
# --- OPTIONAL: Customize figure ---
117+
# get axis of figure and change title
107118
axes = fig_auroc.get_axes()
108119
ax0 = axes[0]
109120
ax0.set_title('New Title for Calibration Plot')
110-
111-
# save figure
112-
fig.savefig('calibration_plot.png', bbox_inches='tight')
121+
fig_auroc.show()
113122
```
114123

115124
# Requirements

0 commit comments

Comments
 (0)