0
$\begingroup$

I am building a tensorflow model for Heart Disease Prediction data-set. It has a binary outcome (0, 1). Though I am struck with such a low accuracy which is not changing with epochs.

model = keras.Sequential([
    keras.layers.Flatten(input_shape=(13,)),
    keras.layers.Dense(64, activation='relu'),
    keras.layers.Dense(64, activation='relu'),
    keras.layers.Dense(1, activation=tf.nn.sigmoid)
])

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


model.fit(train_data, train_label, epochs=100)

The accuracy and the Loss is not changing with the Epochs

WARNING:tensorflow:Falling back from v2 loop because of error: Failed to find data adapter that can handle input: <class 'pandas.core.frame.DataFrame'>, <class 'NoneType'>
Train on 227 samples
Epoch 1/100
227/227 [==============================] - 0s 312us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 2/100
227/227 [==============================] - 0s 68us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 3/100
227/227 [==============================] - 0s 72us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 4/100
227/227 [==============================] - 0s 74us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 5/100
227/227 [==============================] - 0s 69us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 6/100
227/227 [==============================] - 0s 66us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 7/100
227/227 [==============================] - 0s 82us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 8/100
227/227 [==============================] - 0s 76us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 9/100
227/227 [==============================] - 0s 83us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 10/100
227/227 [==============================] - 0s 81us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 11/100
227/227 [==============================] - 0s 84us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 12/100
227/227 [==============================] - 0s 83us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 13/100
227/227 [==============================] - 0s 81us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 14/100
227/227 [==============================] - 0s 80us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 15/100
227/227 [==============================] - 0s 65us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 16/100
227/227 [==============================] - 0s 65us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 17/100
227/227 [==============================] - 0s 71us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 18/100
227/227 [==============================] - 0s 85us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 19/100
227/227 [==============================] - 0s 70us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 20/100
227/227 [==============================] - 0s 76us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 21/100
227/227 [==============================] - 0s 76us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 22/100
227/227 [==============================] - 0s 78us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 23/100
227/227 [==============================] - 0s 77us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 24/100
227/227 [==============================] - 0s 74us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 25/100
227/227 [==============================] - 0s 62us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 26/100
227/227 [==============================] - 0s 62us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 27/100
227/227 [==============================] - 0s 66us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 28/100
227/227 [==============================] - 0s 79us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 29/100
227/227 [==============================] - 0s 67us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 30/100
227/227 [==============================] - 0s 67us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 31/100
227/227 [==============================] - 0s 63us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 32/100
227/227 [==============================] - 0s 62us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 33/100
227/227 [==============================] - 0s 78us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 34/100
227/227 [==============================] - 0s 82us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 35/100
227/227 [==============================] - 0s 88us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 36/100
227/227 [==============================] - 0s 66us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 37/100
227/227 [==============================] - 0s 69us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 38/100
227/227 [==============================] - 0s 89us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 39/100
227/227 [==============================] - 0s 85us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 40/100
227/227 [==============================] - 0s 64us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 41/100
227/227 [==============================] - 0s 82us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 42/100
227/227 [==============================] - 0s 79us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 43/100
227/227 [==============================] - 0s 80us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 44/100
227/227 [==============================] - 0s 68us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 45/100
227/227 [==============================] - 0s 86us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 46/100
227/227 [==============================] - 0s 66us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 47/100
227/227 [==============================] - 0s 67us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 48/100
227/227 [==============================] - 0s 67us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 49/100
227/227 [==============================] - 0s 78us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 50/100
227/227 [==============================] - 0s 71us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 51/100
227/227 [==============================] - 0s 89us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 52/100
227/227 [==============================] - 0s 72us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 53/100
227/227 [==============================] - 0s 70us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 54/100
227/227 [==============================] - 0s 76us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 55/100
227/227 [==============================] - 0s 91us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 56/100
227/227 [==============================] - 0s 69us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 57/100
227/227 [==============================] - 0s 63us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 58/100
227/227 [==============================] - 0s 74us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 59/100
227/227 [==============================] - 0s 75us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 60/100
227/227 [==============================] - 0s 76us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 61/100
227/227 [==============================] - 0s 66us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 62/100
227/227 [==============================] - 0s 83us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 63/100
227/227 [==============================] - 0s 83us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 64/100
227/227 [==============================] - 0s 69us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 65/100
227/227 [==============================] - 0s 78us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 66/100
227/227 [==============================] - 0s 66us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 67/100
227/227 [==============================] - 0s 70us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 68/100
227/227 [==============================] - 0s 72us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 69/100
227/227 [==============================] - 0s 68us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 70/100
227/227 [==============================] - 0s 65us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 71/100
227/227 [==============================] - 0s 68us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 72/100
227/227 [==============================] - 0s 71us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 73/100
227/227 [==============================] - 0s 72us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 74/100
227/227 [==============================] - 0s 80us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 75/100
227/227 [==============================] - 0s 72us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 76/100
227/227 [==============================] - 0s 76us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 77/100
227/227 [==============================] - 0s 75us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 78/100
227/227 [==============================] - 0s 76us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 79/100
227/227 [==============================] - 0s 76us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 80/100
227/227 [==============================] - 0s 77us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 81/100
227/227 [==============================] - 0s 78us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 82/100
227/227 [==============================] - 0s 92us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 83/100
227/227 [==============================] - 0s 69us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 84/100
227/227 [==============================] - 0s 72us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 85/100
227/227 [==============================] - 0s 72us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 86/100
227/227 [==============================] - 0s 75us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 87/100
227/227 [==============================] - 0s 74us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 88/100
227/227 [==============================] - 0s 71us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 89/100
227/227 [==============================] - 0s 73us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 90/100
227/227 [==============================] - 0s 102us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 91/100
227/227 [==============================] - 0s 74us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 92/100
227/227 [==============================] - 0s 73us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 93/100
227/227 [==============================] - 0s 66us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 94/100
227/227 [==============================] - 0s 84us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 95/100
227/227 [==============================] - 0s 65us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 96/100
227/227 [==============================] - 0s 67us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 97/100
227/227 [==============================] - 0s 72us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 98/100
227/227 [==============================] - 0s 76us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 99/100
227/227 [==============================] - 0s 69us/sample - loss: 7.0925 - accuracy: 0.5374
Epoch 100/100
227/227 [==============================] - 0s 64us/sample - loss: 7.0925 - accuracy: 0.5374
<tensorflow.python.keras.callbacks.History at 0x7f374e3101d0>
$\endgroup$
1
$\begingroup$

There can be multiple reasons for low accuracy :

  • Your data is not balanced
  • Your data is not related to your output
  • Your model is very complex
  • Wrong selection of hyperparameters

Ideally you should do a feature correlation check in beginning. Instead, To rule out first 2 doubts, you can train a decision tree/Random forest. If you get decent accuracy then jump to neural networks.
Also check if your data is balanced and stratified across both classes.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.