Q#53: Testing user conversion

Given the following dataset, can you see if there’s a significant difference between the conversion rate of users between the test and control group? The relevant columns in the table are conversion and test. The conversion column has values of 0 and 1 which represent if the user converted (1) or not (0). The test table has values of 0 and 1 as well, 0 for the control group and 1 for the test group.

TRY IT YOURSELF

ANSWER

This question tests our ability to gather in the data, wrangle it, and use statistics to draw a conclusion. Specifically, we are going to use a T-test to determine if the test group is significantly different from the control group.

To read up on the T-test visit this link T Test (Student’s T-Test): Definition and Examples — Statistics How To. In short, it is a significance test that compares distributions to a standard T distribution.

First, we need to load in the data and look at it. To do this we will use the pandas library and the .read_csv() function to gather the data from the link and .head() to observe the first 5 rows.

import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/erood/interviewqs.com_code_snippets/master/Datasets/test_table_truncated.csv')
df.head()

From this data, we see that we will need to split the flag feature test so we can get the conversion data for both control and test groups. To do this we will utilize the .groupby() function and list comprehension so that we will have two separate series of conversion for the control and test.

a = [j for i, j in df.groupby('test').conversion]

Finally, we will implement the T-test in python using the scipy library. From its stats module we can use the ttest_ind() function with the two series arguments.

from scipy import stats as st
st.ttest_ind(a[0], a[1], equal_var=True)
Ttest_indResult(statistic=3.631934592190223,
pvalue=0.0002817140924484168)

From the T-statistic and the p-value, we can conclude there is a significant difference between the control and test groups.

--

--