why the accuracy result and the loss result of an ANN model is inconsistent?

I trained a model based on an ANN and the accuracy is 94.65% almost every time while the loss result is 12.06%. Now my question is shouldn't the loss of the model be (100-94 = 6%) or near it? Why it is giving a result of 12% when the accuracy is 94%?

• ANN model specification:

  1. Trained and tested data= 96,465 (training data = 80%, testing data = 20%)
  2. 1 Input layer= 5 nodes, 2 Hidden layers= 24 nodes each, 1 Output layer= 5 nodes
  3. Activation function: a. Rectified linear (ReLu) function in hidden layers b. Softmax function in output layer
  4. Optimizer: Adam
  5. Loss function: Sparse categorical crossentropy
  6. Batch size: 100
  7. Epochs: 30

Topic loss loss-function accuracy machine-learning

Category Data Science


It is good to know the difference between accuracy and loss:

  • Accuracy: it is a number of correctly classified samples out of all data samples and it is measured in percent.
  • Loss: is a distance measure between the predicted output and ground truth (simply a measure between two probability distributions). To calculate this distance We use cross-entropy loss in multi-classification problem.It is not measured in percent.

Example: imagine you have a (cat, dog) dataset to classify these 2 classes. You have 2 images for each class. You have an ANN which classifies correctly 3 samples and the loss is 6.5. Thus, the accuracy is (3/4) 75% but the loss is 6.5 based on the calculation of binary cross-entropy because we have a binary-classification problem (2 classes).

Finally, it is noteworthy that If you have high accuracy and large loss that means you have some few samples hardly recognized by your model (far away from the correct classes in terms of distance).

You could now conclude that you have 94% accuracy and 12.06 loss.

Recommended to read more here.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.