<jupyter_start><jupyter_text>Artifical Neural Networkinput --- >>> Hidden Layer --- >>> Outputto find accuracy of output  we will found cost function-- when hidden layer get more than 2 then we will call it as Deep Neural Network As we want cost function tendens to zero   so when output came we gave it to input or weight given to input not only input but intermeddite stages also this is called backprapogation -- So weight get change or cost function is applied to all layers so when we want to backtrace then we can   Activation Funciton it has 100+ typeIn neural most used are 4for error reduction we check it by activation funtion by each hidden layerINPUT -- H1--(AF1)--H2--(AF2)--H3--(AF3)--OUTPUTAF3-- mainly use Sigmoid funtion hereand remaining 3 is apply in middle in AF1 AF2Activation Function 1. Threshold -- -- function are in pdf2. Sigmoid -- -- function are in pdf3. Rectify -- -- function are in pdf4. Hyperbolic Tangent -- -- function are in pdf  To adjust weight we apply this method --@@  Gradient Decent @@----@@  Schocastic Gradient Decent @@--<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt


df=pd.read_csv('bank.csv')
df.head()<jupyter_output><empty_output><jupyter_text>we will find that column that give that customer stay in bank or notFEATURES-- so creditScore,Geography,Gender,Age,Tenure,Balance,NumberofProducts,HasCrCard,IsActiveMember,EstimatedSalaryLABEL-- Exited<jupyter_code>features=df.iloc[:,3:13].values
features
label=df.iloc[:,-1].values
label<jupyter_output><empty_output><jupyter_text>Categorical Data -- is Geography and GenderTo categorize into string into numeric data as processor do not understand<jupyter_code>from sklearn.preprocessing import LabelEncoder
country=LabelEncoder()   
features[:,1]=country.fit_transform(features[:,1])
features
gender=LabelEncoder()
features[:,2]=gender.fit_transform(features[:,2])
features<jupyter_output><empty_output><jupyter_text>as country has got 0,1,2 value so it split it into as 2 as best so we create dummy variable this is as if france is present then 1 0 0  -- -- it means france is present and spain and germany is absentthis is done threw ONEHOTENCODER<jupyter_code>from sklearn.preprocessing import OneHotEncoder
ohe=OneHotEncoder(categorical_features=[1])

features=ohe.fit_transform(features).toarray()
features.astype(int)
features.shape
features=features[:,1:]
pd.DataFrame(features).astype(int).head(5)
from sklearn.model_selection import train_test_split
train_fe,test_fe,train_la,test_la=train_test_split(features,label,test_size=.2)
# Applying Features Scaling
from sklearn.preprocessing import StandardScaler
sc=StandardScaler()
train_fe=sc.fit_transform(train_fe)
test_fe=sc.transform(test_fe)<jupyter_output><empty_output><jupyter_text>Apply Neural Networks1. take input as number of features and decide some reandom weights close to 0  is given such tha weight do not effect input -- input layers are 122. design 1st hidden layer  -- prefer to be avg of nurons in starting layer3. design or assume number of nodes for sec hidden layer with its activation function   -- Activation function is applied everywhere except input layer4. calculate predication with sigmoid activation function output and apply cost function to check the error5. If error found then apply back propagation and adjust weight accordingly to get more and better output6. Repeat 2 to 4 again if output is not acurrate-- Backprapotion --weight adjust   ANN<jupyter_code>import keras
# to create ANN model 

from keras.models import Sequential               # ANN initialize ----- Classifier Init
# to fill data in each layer 

from keras.layers import Dense                 # classifer fit data
# calling ANN model as classifier

clf=Sequential()
# Time for adding layers           ---- input go as input and first hidden layer

# Adding first input layer with hidden layer   ---  activation funcion is Rectify  -- kernel_initializer is for initialize it in one range
# input shape must be in tuple thats why we give (11,)
# units is avg of total coulumn   -- - -

clf.add(Dense(units=6,activation='relu',kernel_initializer='glorot_uniform',input_shape=(11,)))
clf.add(Dense(units=6,activation='relu',kernel_initializer='glorot_uniform'))
# we added 2 layer   now we finalizing output layer
clf.add(Dense(units=1,activation='sigmoid'))
# as all is in graph so we compile     now compile create model
# optimizer adam give backprapoagtion algo out of 2 
clf.compile(optimizer='adam',loss='binary_crossentropy',metrics=['accuracy'])

#loss=multiple output comapre
#metics=accuracy in 
len(train_fe[0])
# fitting features and label data
# batch_size === how much data you want to sent if 1000000 is data and you want to compute only 10   
# epochs === is from input to output 1 epoch is completed then it go to input and repeated 100 timees
clf.fit(train_fe,train_la,batch_size=10,epochs=10)
# now we are predicting the trained data
clf.predict(test_fe)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07933319943763809, 'fraction_numerical': 0.015464952801767424, 'mean_word_length': 5.021765417170496, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '663188', 'license': 'Apache-2.0', 'n_tokens_mistral': 1487, 'n_tokens_neox': 1410, 'n_words': 562, 'path': 'Neural Network/ANN.ipynb', 'repo_name': 'Siddhant231096/Deep-Learning', 'size': '4979'}