INRIA / INRIA/scikit-learn-mooc

Explain how to read a boxplot

Open
#453 0 comments 0 reactions 0 assignees View on GitHub
video
Dominant language
Jupyter Notebook
Stars
1.4k
Forks
600
Avg merge
6d 20h
Merged PRs (30d)
2

Description

Box-plots are frequently used during the MOOC but a person without a minimal formation in statistics might not understand how to read them.
I think the soon-to-be-added notebook on score distributions gives us a good opportunity to add a brief explanation/illustration on how to do so.

Using the same example as presented in #416 to illustrate overlapping score distribution, I propose adding both the following code and figures:

```python
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

plt.rcParams["figure.figsize"] = (10,7)
plt.rcParams.update({'font.size': 16})
np.random.seed(12)

model_1 = pd.DataFrame([0.65,0.7,0.71,0.73,0.78],columns=['model_1'])
model_2 = list(np.random.normal(0.74, 0.07, 5))
model_2 = pd.DataFrame(model_2,columns=['model_2'])
models = pd.concat([model_1,model_2], axis=1)

bins=[0.6,0.64,0.68,0.72,0.76,0.8,0.84]
fig, ax1 = plt.subplots()
ax1.hist(models, bins=bins, label=['model_1', 'model_2'])
ax1.set_ylabel("frequency")
ax1.set_xlabel("test_score")
ax1.legend()
plt.tight_layout()
_ = plt.title("Overlapping score distributions")
```

![overlapping_plot](https://user-images.githubusercontent.com/86408019/132512499-3e05463f-97b6-4416-a479-7736d351e86a.png)

```python
color = {"whiskers": "black", "medians": "black", "caps": "black"}

models.plot.box(vert=False, color=color)
_ = plt.title("Computation of multiple scores using a boxplot")
```

![boxplot](https://user-images.githubusercontent.com/86408019/132512516-d39eba6d-03d6-4aa8-ad76-46662435eec4.png)

Having both things on the same notebook would show how useful a box-plot is when comparing several distributions at once.

What do you think?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.