Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Desafío: Violín y Gráficos de Enjambre (Parte 1) | Variaciones en las Pruebas A/B
El Arte del A/B Testing

book
Desafío: Violín y Gráficos de Enjambre (Parte 1)

Tarea

Swipe to start coding

En esta tarea, usted necesita construir un violin y un swarm plot en el mismo lienzo. Estos gráficos deben construirse para la columna 'Compra'. Compare las varianzas: ¿son similares?

    1. Importe las bibliotecas.
  1. Concatene los marcos de datos.
  2. Construya las parcelas de violín.
    1. Construir los plots de enjambre.

Solución

# 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 colors for graphs
colors_list = ['#ff8a00', '#33435c']

# Add to the dataframes columns-labels, which mean belonging to either the control or the test group
df_control['group'] = 'Contol group'
df_test['group'] = 'Test group'

# Concat control and test dataframes
df_combined = pd.concat([df_control, df_test])

# Plotting violin plots
sns.violinplot(data=df_combined, x='group', y='Purchase', color="r", alpha=0.8)

# Plotting swarm plots
sns.swarmplot(data=df_combined, x='group', y='Purchase', palette=colors_list)

# Sign the axes
plt.xlabel('')
plt.ylabel('Purchase')
plt.title('Comparison of Purchase')

# Show the results
plt.show()
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 3. Capítulo 2
# Import libraries
___ ___ as plt
___ ___ as pd
___ ___ 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 colors for graphs
colors_list = ['#ff8a00', '#33435c']

# Add to the dataframes columns-labels, which mean belonging to either the control or the test group
df_control['group'] = 'Contol group'
df_test['group'] = 'Test group'

# Concat control and test dataframes
df_combined = pd.___([___, ___])

# Plotting violin plots
sns.___(data=df_combined, x='group', y='Purchase', color="r", alpha=0.8)

# Plotting swarm plots
sns.___(data=df_combined, x='group', y='Purchase', palette=colors_list)

# Sign the axes
plt.xlabel('')
plt.ylabel('Purchase')
plt.title('Comparison of Purchase')

# Show the results
plt.show()

Pregunte a AI

expand
ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

some-alt