Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Shapiro Test | Normality Check
The Art of A/B Testing

book
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.

  1. Read files.
  2. Do the Shapiro test of the Click column for the control sample.
  3. Do the Shapiro test of the Click column for the test sample.

Løsning

# 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?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 2. Kapitel 8
single

single

# 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

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

We use cookies to make your experience better!
some-alt