49
ππππππ πππ =
π‘ππ’π πππ ππ‘ππ£π
π‘ππ’π πππ ππ‘ππ£π + ππππ π πππ ππ‘ππ£π
Equation 7: precision equation
Recall (
) is the ability of the model to find all the positive values in the dataset for this
instance:
ππππππ =
π‘ππ’π πππ ππ‘ππ£π
π‘ππ’π πππ ππ‘ππ£π + ππππ π πππππ‘ππ£π
Equation 8: recall equation
F1-score (
) is the harmonic mean of precision and recall, and is a measure of the
modelβs accuracy, for the classification of each instance:
πΉ
1
=
2
ππππππ πππ
β1
+ ππππππ
β1
=
ππππππ πππ β ππππππ
ππππππ πππ + ππππππ
=
ππ
ππ +
1
2
(πΉπ + πΉπ)
Equation 9: F1-score - harmonic mean equation
Lastly, Support is simply the times that each specific class is encountered in the dataset, the
instances of each label. It is from those instances that the precision and recall are calculated
for each label of the dataset, in a binary way (one-against-all).
The average values of the report below the label-by-label metrics lead the results from binary
to multiclass classification [34]. Most importantly, accuracy (
) measures
the overall ability of the model to classify correctly over all of the values. If π¦
π
Μ is the predicted
value of sample π and π¦
π
is the real value, then accuracy is defined as:
ππππ’ππππ¦(π¦, π¦Μ) =
1
π
π ππππππ
β
1(π¦
π
Μ = π¦
π
)
π
π ππππππ
β1
π=0
Equation 10: accuracy equation
Or more intuitively:
ππππ’ππππ¦ =
ππ + ππ
ππ + ππ + πΉπ + πΉπ
=
πππππππ‘ ππππ π ππππππ‘ππππ
πππ ππππ π ππππππ‘ππππ
Equation 11: intuitive accuracy equation
Macro average is simply the mean of all the above binary metrics, for precision, recall and f-1
score respectively, taking all classes as of equal importance, which is often untrue, especially
in unbalanced datasets such as NSL-KDD; weighted average is the mean value of the binary
metrics, with each classβs score weighted by its presence in the dataset (the support value).
The weighted average is much closer to the accuracy score, as we can see in the classification