Challenge: Another Normality Test
Opgave
Swipe to start coding
Now, let's do the Shapiro test for our columns with the metric 'Average Earnings per Click'. Are the metrics normally distributed?
- Define the metric.
- Do the Shapiro test.
Løsning
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Import libraries
from scipy.stats import shapiro
import pandas as pd
# Read .csv files
df_control = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c3b98ad3-420d-403f-908d-6ab8facc3e28/ab_control.csv', delimiter=';')
df_test = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c3b98ad3-420d-403f-908d-6ab8facc3e28/ab_test.csv', delimiter=';')
# Define the metric
df_test['Average Earnings per Click'] = df_test['Earning'] / df_test['Click']
df_control['Average Earnings per Click'] = df_control['Earning'] / df_control['Click']
# Testing normality
stat_control, p_control = shapiro(df_control['Average Earnings per Click'])
print("Control group: ")
print("Stat: %.4f, p-value: %.4f" % (stat_control, p_control))
if p_control > 0.05:
print('Control group is likely to normal distribution')
else:
print('Control group is NOT likely to normal distribution')
stat_control, p_control = shapiro(df_test['Average Earnings per Click'])
print("Test group: ")
print("Stat: %.4f, p-value: %.4f" % (stat_control, p_control))
if p_control > 0.05:
print('Test group is likely to normal distribution')
else:
print('Test group is NOT likely to normal distribution')
Var alt klart?
Tak for dine kommentarer!
Sektion 5. Kapitel 3
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Import libraries
from scipy.stats import ___
import pandas as pd
# Read .csv files
df_control = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c3b98ad3-420d-403f-908d-6ab8facc3e28/ab_control.csv', delimiter=';')
df_test = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c3b98ad3-420d-403f-908d-6ab8facc3e28/ab_test.csv', delimiter=';')
# Define the metric
df_test['Average Earnings per Click'] = df_test['Earning'] / df_test['Click']
df_control['Average Earnings per Click'] = df_control['Earning'] / df_control['Click']
# Testing normality
stat_control, p_control = ___(df_control['Average Earnings per Click'])
print("Control group: ")
print("Stat: %.4f, p-value: %.4f" % (stat_control, p_control))
if p_control > 0.05:
print('Control group is likely to normal distribution')
else:
print('Control group is NOT likely to normal distribution')
stat_control, p_control = ___(df_test['Average Earnings per Click'])
print("Test group: ")
print("Stat: %.4f, p-value: %.4f" % (stat_control, p_control))
if p_control > 0.05:
print('Test group is likely to normal distribution')
else:
print('Test group is NOT likely to normal distribution')
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat