Browse Source

feat(visualizations): clarify exercise 7

pull/2304/head
nprimo 6 months ago committed by Niccolò Primo
parent
commit
d87d5a5df4
  1. 7
      subjects/ai/visualizations/README.md
  2. 25
      subjects/ai/visualizations/audit/README.md
  3. BIN
      subjects/ai/visualizations/w1day03_ex7_plot1.png

7
subjects/ai/visualizations/README.md

@ -247,9 +247,10 @@ https://plotly.com/python/time-series/
# Exercise 7: Plotly Box plots
The goal of this exercise is to learn to use Plotly to plot Box Plots. It is t is a method for graphically depicting groups of numerical data through their quartiles and values as min, max. It allows to compare quickly some variables.
The goal of this exercise is to learn to use Plotly to plot Box Plots. It is a method for graphically depicting groups of numerical data through their quartiles and values as min, max. It allows comparing quickly some variables.
Let us generate 3 random arrays from a normal distribution. And for each array add respectively 1, 2 to the normal distribution.
Generate 3 random arrays from a normal distribution. Keep one as it is and for
the other two arrays add respectively 1 and 2 to the normal distribution.
```python
y0 = np.random.randn(50)
@ -257,7 +258,7 @@ y1 = np.random.randn(50) + 1 # shift mean
y2 = np.random.randn(50) + 2
```
1. Plot in the same Figure 2 box plots as shown in the image. In this exercise the style is not important.
1. In the same figure, plot the 3 distributions as box plots as shown in the image. In this exercise the style is not important.
![alt text][logo_ex7]

25
subjects/ai/visualizations/audit/README.md

@ -145,29 +145,14 @@ https://matplotlib.org/gallery/api/two_scales.html
#### Exercise 7: Plotly Box plots
###### For question 1, does the plot reproduce the plot in the image and respect those criteria? The code below shows a solution.
###### For question 1, does the plot reproduce the plot in the image as asked in the subject?
###### Does it have a title?
###### Does the figure as 3 box plots?
###### Does the 3 box plots show normal distributions around 0, 1 and 2 respectively?
###### Does it have a legend?
Due to the random nature of the distributions, the two graphs do not require a perfect match
![alt text][logo_ex7]
[logo_ex7]: ../w1day03_ex7_plot1.png "Box plot ex7"
```python
import plotly.graph_objects as go
import numpy as np
y0 = np.random.randn(50)
y1 = np.random.randn(50) + 1 # shift mean
y2 = np.random.randn(50) + 2
fig = go.Figure()
fig.add_trace(go.Box(y=y0, name='Sample A',
marker_color = 'indianred'))
fig.add_trace(go.Box(y=y1, name = 'Sample B',
marker_color = 'lightseagreen'))
fig.show()
```

BIN
subjects/ai/visualizations/w1day03_ex7_plot1.png

diff.bin_not_shown

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Loading…
Cancel
Save