Challenge: Shapiro Test
Opgave
Swipe to start coding
In this exercise, your goal will be to determine the normality of the distribution using the Shapiro test. Along with visual analysis, this test allows you to verify that your distribution is indeed normal. This knowledge is key in controlled experiments.
- Read files.
- Do the Shapiro test of the Click column for the control sample.
- Do the Shapiro test of the Click column for the test sample.
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
29
# Import libraries
import pandas as pd
from scipy.stats import shapiro
# 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=';')
# Do the Shapiro test for the control sample
stat_control, p_control = shapiro(df_control['Click'])
print("Control group: ")
print("Stat: %.4f, p-value: %.4f" % (stat_control, p_control))
# Define the distribution form
if p_control > 0.05:
print('Control group is likely to normal distribution')
else:
print('Control group is NOT likely to normal distribution')
# Do the Shapiro test for the test sample
stat_test, p_test = shapiro(df_test['Click'])
print("Test group: ")
print("Stat: %.4f, p-value: %.4f" % (stat_test, p_test))
# Define the distribution form
if p_test > 0.05:
print('Control group is likely to normal distribution')
else:
print('Control group is NOT likely to normal distribution')
Var alt klart?
Tak for dine kommentarer!
Sektion 2. Kapitel 8
single
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
29
# Import libraries
import pandas as pd
from scipy.stats import shapiro
# Read .csv files
df_control = pd.___('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c3b98ad3-420d-403f-908d-6ab8facc3e28/ab_control.csv', delimiter=';')
df_test = pd.___('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c3b98ad3-420d-403f-908d-6ab8facc3e28/ab_test.csv', delimiter=';')
# Do the Shapiro test for the control sample
stat_control, p_control = ___(df_control['___'])
print("Control group: ")
print("Stat: %.4f, p-value: %.4f" % (stat_control, p_control))
# Define the distribution form
if p_control > 0.05:
print('Control group is likely to normal distribution')
else:
print('Control group is NOT likely to normal distribution')
# Do the Shapiro test for the test sample
stat_test, p_test = ___(df_test['___'])
print("Test group: ")
print("Stat: %.4f, p-value: %.4f" % (stat_test, p_test))
# Define the distribution form
if p_test > 0.05:
print('Control group is likely to normal distribution')
else:
print('Control group is NOT likely to normal distribution')
Spørg AI
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