<jupyter_start><jupyter_text>Data Preprocessing<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
dataset = pd.read_csv('Churn_Modelling.csv')
X = dataset.iloc[:,6:13]
X = pd.concat([X,dataset.CreditScore],axis=1)
y = dataset.iloc[:, -1]
dataset.columns
def encode(series, df=None):
    cols = pd.get_dummies(series.astype(str))
    if df is not None:
        df = pd.concat([df,cols],axis=1)
        return df
    return series
X = encode(dataset.Geography,X)
X = encode(dataset.Gender,X)
X = X.drop(['France','Female'], axis=1)
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X.values, y.values, test_size=0.2, random_state = 0)
from sklearn.preprocessing import StandardScaler
sc_X = StandardScaler()
X_train = sc_X.fit_transform(X_train)
X_test = sc_X.transform(X_test)
X_train<jupyter_output><empty_output><jupyter_text>Implementing Neural Networks  Importing Libraries<jupyter_code>import keras
from keras.models import Sequential
from keras.layers import Dense<jupyter_output><empty_output><jupyter_text>Initializing the ANN<jupyter_code>classifier = Sequential()<jupyter_output><empty_output><jupyter_text>Adding Layers  Input Layer and First Hidden Layer<jupyter_code>classifier.add(Dense(6, kernel_initializer='uniform', activation='relu', input_shape=(11,)))<jupyter_output><empty_output><jupyter_text>Second Hidden Layer<jupyter_code>classifier.add(Dense(6, kernel_initializer='uniform', activation='relu'))<jupyter_output><empty_output><jupyter_text>Adding Output Layer<jupyter_code>classifier.add(Dense(1, kernel_initializer='uniform', activation='sigmoid'))<jupyter_output><empty_output><jupyter_text>Compiling the ANN<jupyter_code>classifier.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])<jupyter_output><empty_output><jupyter_text>Fitting ANN to Training Set<jupyter_code>classifier.fit(X_train, y_train, batch_size=10, epochs=100)<jupyter_output>Epoch 1/100
8000/8000 [==============================] - 1s 126us/step - loss: 0.4832 - acc: 0.7959
Epoch 2/100
8000/8000 [==============================] - 1s 96us/step - loss: 0.4276 - acc: 0.7960
Epoch 3/100
8000/8000 [==============================] - 1s 104us/step - loss: 0.4218 - acc: 0.7999
Epoch 4/100
8000/8000 [==============================] - 1s 92us/step - loss: 0.4177 - acc: 0.8225
Epoch 5/100
8000/8000 [==============================] - 1s 92us/step - loss: 0.4160 - acc: 0.8272
Epoch 6/100
8000/8000 [==============================] - 1s 99us/step - loss: 0.4136 - acc: 0.8301
Epoch 7/100
8000/8000 [==============================] - 1s 97us/step - loss: 0.4126 - acc: 0.8310
Epoch 8/100
8000/8000 [==============================] - 1s 97us/step - loss: 0.4113 - acc: 0.8329
Epoch 9/100
8000/8000 [==============================] - 1s 103us/step - loss: 0.4104 - acc: 0.8345
Epoch 10/100
8000/8000 [==============================] - 1s 96us/step - loss: 0.4096 - acc: 0.8344
Epoch [...]<jupyter_text>Predicting Outcome  Predictions<jupyter_code>y_pred = classifier.predict(X_test)
y_pred
y_pred = (y_pred>0.5)
y_pred<jupyter_output><empty_output><jupyter_text>Accuracy<jupyter_code>from sklearn.metrics import confusion_matrix
cm = confusion_matrix(y_test, y_pred)
cm
from sklearn.metrics import accuracy_score as acc
accuracy = acc(y_test,y_pred)
accuracy<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2071407494836235, 'fraction_numerical': 0.08143995278843316, 'mean_word_length': 6.793103448275862, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 41, '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': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '243965', 'license': 'MIT', 'n_tokens_mistral': 1437, 'n_tokens_neox': 1204, 'n_words': 229, 'path': 'Implementations/Resuming ML Basics/Part 8 - Deep Learning/Artificial_Neural_Networks/Artificial Neural Networks.ipynb', 'repo_name': 'Vibhu-Agarwal/Deep-Learning-Basics', 'size': '3389'}