<jupyter_start><jupyter_text>HANDLING CATEGORICAL VARIABLES<jupyter_code>train.area_code = train.area_code.map({'area_code_415':415,'area_code_408':408,'area_code_510':510})
test.area_code = test.area_code.map({'area_code_415':415,'area_code_408':408,'area_code_510':510})
train = train.replace({'voice_mail_plan':{'yes':1,'no':0}})
test = test.replace({'voice_mail_plan':{'yes':1,'no':0}})
train = train.replace({'international_plan':{'yes':1,'no':0}})
test = test.replace({'international_plan':{'yes':1,'no':0}})
train = train.replace({'churn':{'yes':1,"no":0}})
test = test.replace({'churn':{'yes':1,"no":0}})
train.state = train.state.astype('category')
test.state = test.state.astype('category')
train.info()
train.head()<jupyter_output><empty_output><jupyter_text>EXPLORATORY DATA ANALYSIS<jupyter_code>sns.countplot(x = 'churn',data = train)
fig,ax = plt.subplots(figsize = (18,10)) 
x = train.groupby('state')[['churn']].size()
x.plot.bar()
train.groupby('churn')['number_customer_service_calls'].count()
def facet(data,y):
    g = sns.FacetGrid(data,col = 'churn',size = 5)
    g.map(plt.hist,y,alpha = 0.5)
    g.add_legend()
    plt.show()
facet(train,'number_customer_service_calls')
facet(train,'total_day_calls')
facet(train,'total_eve_calls')
facet(train,'voice_mail_plan')<jupyter_output><empty_output><jupyter_text>Checking Correlation between different variables<jupyter_code>corr_matrix = train.corr()
corr_matrix<jupyter_output><empty_output><jupyter_text>Deleting the variables which has high correlation with other variables<jupyter_code>col_drop = ['total_day_minutes','total_night_minutes','total_eve_minutes','total_intl_minutes']
train = train.drop(columns = col_drop,axis = 1)
test = test.drop(columns = col_drop,axis = 1)
train.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18582589285714285, 'fraction_numerical': 0.03180803571428571, 'mean_word_length': 10.493589743589743, 'pattern_counts': {'":': 2, '<': 17, '<?xml version=': 0, '>': 17, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '54972', 'license': 'Apache-2.0', 'n_tokens_mistral': 721, 'n_tokens_neox': 680, 'n_words': 74, 'path': 'Exploratory Analysis and Data Preprocessing/Customer Churn Prediction Data Analysis and Data PreProcessing.ipynb', 'repo_name': 'prasaadhsrinivasan/Customer-Churn-Prediction-Using-Random-Forest', 'size': '1792'}