<jupyter_start><jupyter_text>PurposeThis notebook will visualize the difference in likelihood of functionality depending on installer.  Import and processing<jupyter_code>%load_ext autoreload
%autoreload 2

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
X_train = pd.read_csv('../data/train_data.csv')
X_train.head()
y_train = pd.read_csv('../data/train_targets.csv')
y_train
df = X_train.merge(y_train, on='id')
df.info()
def compare(column, value, data):
    sample = data[data[column]==value]
    functional_sample = sample[sample['status_group']=='functional']
    percent_funct_sample = (len(functional_sample)/len(sample))*100

    funct_all = data[data['status_group']=='functional']
    percent_funct_all = (len(funct_all)/len(data))*100
    
    fig, ax = plt.subplots(1,1,figsize=(8,8))
    ax.set_ylim(0,100)
    sns.barplot(x=[f'{column} equal to {value}', 'All Management Types'], y=[percent_funct_sample, percent_funct_all])<jupyter_output><empty_output><jupyter_text>1. Installer<jupyter_code>df.installer.value_counts()[:15]
plt.style.use('ggplot')

government = df[(df['installer']=='Central government')|(df['installer']=='Government')]
functional_gov = government[government['status_group']=='functional']
percent_funct_gov = (len(functional_gov)/len(government))*100

community = df[(df['installer']=='Commu')|(df['installer']=='Community')]
functional_com = community[community['status_group']=='functional']
percent_funct_com = (len(functional_com)/len(community))*100
y=[percent_funct_gov, percent_funct_com]

fig, ax = plt.subplots(1,1,figsize=(12,12))

ax.set_title('Difference in Likelihood of Well Functionality\nBetween Government and Community Installed Wells\n', fontsize = 30)
ax.set_xlabel('Well Installer', fontsize=30)
ax.set_ylabel('% Likelihood of Functionality', fontsize=30)
ax.set_ylim(0,100)
ax.tick_params(labelsize=30)

for i in range(2):
    plt.text(x = i-.15 , y =y[i]+.8, s = str(round(y[i], 2))+'%', size = 30)

sns.barplot(x=[f'Government', 'Community'], y=y)
plt.savefig('../reports/figures/installer.png', transparent=True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16286644951140064, 'fraction_numerical': 0.02280130293159609, 'mean_word_length': 7.4980237154150196, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '177741', 'license': 'MIT', 'n_tokens_mistral': 825, 'n_tokens_neox': 754, 'n_words': 133, 'path': 'notebooks/06_mef_EDA_references.ipynb', 'repo_name': 'sydroth/tanzaniawellclassification', 'size': '2149'}