Desafio: Definir métrica
Tarefa
Swipe to start coding
Nesta tarefa, você deve adicionar a métrica 'Média de Ganhos por Clique'
às amostras de controle e teste. Após isso, você deve plotar os histogramas das novas colunas e marcar os valores médios das métricas no gráfico.
- Importe as bibliotecas.
- Leia os arquivos.
- Defina a métrica
'Média de Ganhos por Clique'
e adicione-a a ambas as amostras. - Adicione uma linha com o valor da média.
Solução
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 matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
# 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 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']
# Ploting hist
sns.histplot(df_control['Average Earnings per Click'], color="#1e2635", label="AEC of Control Group")
sns.histplot(df_test['Average Earnings per Click'], color="#ff8a00", label="AEC of Test Group")
# Add mean line
plt.axvline(df_control['Average Earnings per Click'].mean(), color="#1e2635", linestyle='dashed', linewidth=1, label='Mean Control Group')
plt.axvline(df_test['Average Earnings per Click'].mean(), color="#ff8a00", linestyle='dashed', linewidth=1, label='Mean Test Group')
# Sign the axes
plt.xlabel('Average Earnings per Click')
plt.ylabel('Frequency')
plt.legend()
plt.title('Histogram of Average Earnings per Click')
# Show the result
plt.show()
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 5. Capítulo 2
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
___ ___ as plt
___ ___ as pd
___ ___ as sns
# 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=';')
# Define metric
df_test['Average Earnings per Click'] = df_test['___'] / df_test['___']
df_control['Average Earnings per Click'] = df_control['___'] / df_control['___']
# Ploting hist
sns.histplot(df_control['Average Earnings per Click'], color="#1e2635", label="AEC of Control Group")
sns.histplot(df_test['Average Earnings per Click'], color="#ff8a00", label="AEC of Test Group")
# Add mean line
plt___(df_control['Average Earnings per Click']___, color="#1e2635", linestyle='dashed', linewidth=1, label='Mean Control Group')
plt___(df_test['Average Earnings per Click']___, color="#ff8a00", linestyle='dashed', linewidth=1, label='Mean Test Group')
# Sign the axes
plt.xlabel('Average Earnings per Click')
plt.ylabel('Frequency')
plt.legend()
plt.title('Histogram of Average Earnings per Click')
# Show the result
plt.show()
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo