Challenge: Second Levene's Test
Tehtävä
Swipe to start coding
This task is related to the previous task. As you remember from the graphs for the 'Earning'
columns, you might think that the variances are different. Is it really so?
- Import
levene
test. - Do the Levene's test.
Ratkaisu
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Import libraries
import pandas as pd
from scipy.stats import levene
# 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 Levene's test
statistic, p_value = levene(df_control['Earning'], df_test['Earning'])
# Print result of Levene's test
print('Statistic:', statistic)
print('p-value:', p_value)
# Determine whether the variances are similar
if p_value > 0.05:
print('The variances of the two groups are NOT statistically different')
else:
print('The variances of the two groups are statistically different')
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 3. Luku 6
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Import libraries
import pandas as pd
from ___ import ___
# 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 Levene's test
statistic, p_value = ___(___['Earning'], ___['Earning'])
# Print result of Levene's test
print('Statistic:', statistic)
print('p-value:', p_value)
# Determine whether the variances are similar
if p_value > 0.05:
print('The variances of the two groups are NOT statistically different')
else:
print('The variances of the two groups are statistically different')
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme