Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 42 additions & 12 deletions build.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,56 @@
def get_categorical_variables(df):
return []
import numpy as np
import pandas as pd
from scipy.stats import norm
import seaborn as sns
import matplotlib.pyplot as plt

df = pd.read_csv("data/conversion_data.csv")

def get_numerical_variables(df):
return []
def get_categorical_variables(df):
return df[['country','new_user','source','converted']]

def get_numerical_variables(df):
numerical = df._get_numeric_data().columns
return list(numerical)

def get_numerical_variables_percentile(df):
pass

final = df[get_numerical_variables(df)]
return final.describe()

def get_categorical_variables_modes(df):
pass

modes = get_categorical_variables(df).mode()
return modes

def get_missing_values_count(df):
pass
df1 = df.apply(lambda x: sum(x.isnull()), axis=0)
return pd.DataFrame(df1)


def plot_histogram_with_numerical_values(df):
pass

num_cols = get_numerical_variables(df)
plt.figure(figsize=(15,6))
plt.subplot(221)
plt.title(num_cols[0])
sns.distplot(df[num_cols[0]], color='yellow', fit=norm, kde=False)
plt.subplot(222)
plt.title(num_cols[1])
sns.distplot(df[num_cols[1]], color='yellow', fit=norm, kde=False)
plt.subplot(223)
plt.title(num_cols[2])
sns.distplot(df[num_cols[2]], color='yellow', fit=norm, kde=False)
plt.subplot(224)
plt.title(num_cols[3])
sns.distplot(df[num_cols[3]], color='yellow', fit=norm, kde=False)
plt.tight_layout()
plt.show()

def plot_facet_box(df):
pass
plt.figure(figsize=(10,10))
plt.subplot(221)
plt.title('Age')
sns.boxplot('converted','age',data=df)
plt.subplot(222)
plt.title('Total Pages Visited')
sns.boxplot('converted','total_pages_visited',data=df)
plt.tight_layout()
plt.show()
Binary file added build.pyc
Binary file not shown.
Binary file added tests/__init__.pyc
Binary file not shown.
Binary file added tests/test_get_categorical_variables.pyc
Binary file not shown.