3

I have built a classical ANN using keras which provides probability (using sigmoid function) of the outcomes (0 or 1). While the accuracy of the model is high when the model is fit ~90%, the outcome probability of the test set results is very poor. How can I interpret this?

# Build ANN

```
classifier = Sequential()
classifier.add(Dense(activation="relu",input_dim=7,kernel_initializer="uniform", units = 4))
classifier.add(Dense(activation="relu",kernel_initializer="uniform", units = 4))
classifier.add(Dense(activation="sigmoid", kernel_initializer="uniform", units = 1))
classifier.compile(optimizer="adam", loss="binary_crossentropy",metrics=['accuracy'])
classifier.fit(X_train,y_train, batch_size=10,epochs=100)
```

# Predict results:

```
y_pred = classifier.predict(X_test)
```

I have attached the test set results where result probabilities can be seen with respect to frequency. blue shows probabilities for 1 and orange for 0

Is this a case of overfitting? How can I tweak an ann to avoid overfitting?

Thank you for the detailed explanation. You have correctly identified that the 0 and 1 dataset are not balanced and are in the ratio of 80%-20%. I will try out the suggestions you have made. – Ankur Bansal – 2018-09-14T09:31:15.897

I tried balancing the dataset for 0 and 1. This has resulted in much better test results and seems like the it is trained on the data. I will keep on tweaking it using other methods, but this is great. A big thank you @n1k31t4 ! – Ankur Bansal – 2018-09-14T09:52:10.810

@AnkurBansal - you're welcome! :-) – n1k31t4 – 2018-09-14T10:17:52.757