Data
2021, 6, 87
9 of 15
Table 4.
Metrics used to evaluate the dataset.
Metric
Equation
Precision
P
=
TP
(TP+FP)
Recall
R
=
TP
(TP+FN)
F1
F1
=
2
∗
P∗R
(P+R)
Accuracy
A
=
TP+TN
TP+TN+FP+FN
The scripts developed to calculate the evaluation metrics takes advantage of the
scikit-learn
library for Python (
https://scikit-learn.org/stable/
, accessed on 23 June
2021). By observing the Listing
1
, with the y_test from the testing set and x_pred from the
predictions given by the SVM model, it is possible to get the evaluation metrics, namely
precision, recall, F1-score, and the resulting confusion matrix.
Listing 1: Python code to calculate the evaluation metrics.
from
s k l e a r n . m e t r i c s
import c l a s s i f i c a t i o n _ r e p o r t , c o n f u s i o n _ m a t r i x
p r i n t
( c l a s s i f i c a t i o n _ r e p o r t ( y _ t e s t , x_pred ) )
p r i n t
( " c o n f u s i o n matrix " )
Dostları ilə paylaş: