Skip to content

Artificial Neural Network

Shraddha Kulkarni edited this page May 21, 2017 · 2 revisions

Artificial Neural Networks to solve a Customer Churn problem

Steps to be Performed :

  1. Data Preprocessing
  2. Adding Input Layers, Hidden Layers and Output Layers
  3. Time to Compile
  4. Once compiled, one must fit the training dataset
  5. Predict
  6. Improving and Parameter Tuning of the ANN

All the Steps performed in Python using the Spyder IDE.

*Rectifier Function used for the HIDDEN layers and Sigmoid function used for the OUTPUT Layer. *Standardization Function used for Feature Scaling

CODE SECTION

Make an object of Sequential class, which will be our ANN
classifier = Sequential()

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

Adding the second hidden layer same for all, only input not required
classifier.add(Dense(units=6, kernel_initializer = "uniform", activation = "relu"))

Adding the final layer or Output layer
classifier.add(Dense(units=1, kernel_initializer = "uniform", activation = "sigmoid"))

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

Fitting the data
classifier.fit(X_train,y_train, batch_size=10 ,epochs = 100)

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

Outputs

accuracy