# What is the meaning of the parameter “metrics” in the method model.compile in Keras?

I don't have very clear the meaning of the parameter metrics of the compile method of the class model in Keras:

model.compile(..., metrics = ['accuracy'], ...)


the documentation states:

List of metrics to be evaluated by the model during training and testing

what I don't understand is:

are these the metrics used to evaluate the performance of the network at the end of each training epoch, i.e. at the end of each epoch the code makes the network predict on the training set and calculates the metrics passed

OR

are these the metrics used to train the network, i.e. is the network trained with the goal of obtaining the best possible value for these metrics (I don't know how it could do this, something like: if the recall is low then it corrects the weights more when working with positive samples)?

(or it has another meaning?)

The argument metrics is meant to define your criterion for training evaluation. Let me make an example: if you are training a classifier, you want to evaluate your model based on how accurate (in percentage) it is. Therefore, your metric is accuracy (experessed as a float in the [0, 1] range). The higher the accuracy, the lower the loss, the better the model.

metrics must not be confused with loss. The loss function is something you need in order to "punish" your model when it makes mistakes. The loss function is at the basics of backpropagation and of weight update, it's the loss object what Neural Networks use to learn. Metrics instead is something that humans watch to understand how good a model is and communicate it.

The definition of some metrics is optional, you can evaluate a model based on the loss value only if you want. Sometimes you don't need to specify it. For example in regression tasks, i.e. when you have to predict continuous outputs, you speecify a loss (usually MSE or RMSE) and also evaluate your model based on that.

• so what happens is that at the end of each epoch the metrics passed are used to evaluate the performance of the model making it predict on the training set? – Ingen 77 Oct 1 '19 at 15:32
• Yes exactly. The metrics is telling us how good the model is doing throughout training, and how's its overall performance. It's not used by the model to tune its parameters (that's the loss function), but it's just something that us humans find useful to understand its goodness. – Leevo Oct 1 '19 at 17:03
• It also specifies what metrics are computed on the validation set at each epoch, if supplied, in addition to the training data. – Sean Owen Oct 1 '19 at 19:02
• @Leevo all clear, many thanks! – Ingen 77 Oct 2 '19 at 7:57
• @SeanOwen yes, it's very useful, thanks! – Ingen 77 Oct 2 '19 at 7:58