<jupyter_start><jupyter_text><jupyter_code>import tensorflow as tf
tf.test.gpu_device_name()
import tensorflow 
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
from tesnsorflow.python.client import device_lib
device_lib.list_local_devices()
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 20 21:29:37 2020

@author: <NAME>
"""

#PART 1

#Importing Libraries

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

#Importing dataset

dataset = pd.read_csv("/content/drive/My Drive/Colab Notebooks/Churn_Modelling.csv");
X=dataset.iloc[:, 3:13].values
Y=dataset.iloc[:,13].values

#Encoding categorical data

from sklearn.preprocessing import LabelEncoder,OneHotEncoder
from sklearn.compose import ColumnTransformer
labelencoder_X1 = LabelEncoder()
X[:,1] = labelencoder_X1.fit_transform(X[:,1])
labelencoder_X2 = LabelEncoder()
X[:,2] = labelencoder_X2.fit_transform(X[:,2])
transform = ColumnTransformer([("countries", OneHotEncoder(), [1])], remainder="passthrough")
X = transform.fit_transform(X)
X=X[:, 1:]



#Splitting the dataset into training and testing dataset

from sklearn.model_selection import train_test_split
X_train,X_test,Y_train,Y_test = train_test_split(X,Y,test_size=0.2,random_state=0)

#Feature Scaling
from sklearn.preprocessing import StandardScaler
sc =StandardScaler()
X_train = sc.fit_transform(X_train)
X_test = sc.transform(X_test)


#PART 2: Make ANN
#Importing the keras library and packages

import tensorflow.keras

from tensorflow.keras.models import Sequential

from tensorflow.keras.layers import Dense

#Initializing the ANN
classifier = Sequential()

#Adding the input layer and first hidden layer
classifier.add(Dense(units = 6, kernel_initializer = 'uniform', activation = 'relu', input_dim = 11))

#Adding the second hidden layer
classifier.add(Dense(units = 6, kernel_initializer = 'uniform', activation = 'relu'))

#Adding the output layer

classifier.add(Dense(units=1, kernel_initializer = 'uniform', activation = 'sigmoid'))

#Compiling the ANN

classifier.compile(optimizer = 'adam',loss = 'binary_crossentropy',metrics = ['accuracy'])

#Fitting the ANN to the Training set

classifier.fit(X_train,Y_train,batch_size=10,nb_epoch =100)

#Predicting the test set results

y_pred = classifier.predict(X_test)
y_pred = (y_pred>0.5)


# Predicting a single new observation
""" Predict if the customer with following informations will leave the bank:
    Geography: France
    Credit Score: 600
    Gender: Male
    Age: 40
    Tenure: 3
    Balance:60000
    No. of products: 2
    Credit card? Yes
    Active Member: Yes
    Estimated Salary: 50000"""


new_prediction = classifier.predict(sc.transform(np.array([[0.0,0,600,1,40,3,60000,2,1,1,50000]])))
new_prediction= (new_prediction > 0.5)
#Making the confusion matrix

from sklearn.metrics import confusion_matrix
cm = confusion_matrix(Y_test, y_pred)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10908465244322092, 'fraction_numerical': 0.030626290433585685, 'mean_word_length': 6.021739130434782, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 8, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '600373', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 1034, 'n_tokens_neox': 967, 'n_words': 250, 'path': 'ANN.ipynb', 'repo_name': 'ab-5860/opensource.guide', 'size': '2914'}