class ConfusionMat extends AnyRef
The ConfusionMat
object provides functions for determining the confusion
matrix as well as derived quality metrics such as accuracy, precsion, recall,
and Cohen's kappa coefficient.
- Alphabetic
- By Inheritance
- ConfusionMat
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
-
new
ConfusionMat(y: VectoI, yp: VectoI, k: Int = 2)
- y
the actual class labels
- yp
the precicted class labels
- k
the number class values
Value Members
-
def
accuracy: Double
Compute the accuracy of the classification, i.e., the fraction of correct classifications.
Compute the accuracy of the classification, i.e., the fraction of correct classifications. Note, the correct classifications 'tp_i' are in the main diagonal of the confusion matrix.
-
def
confusion: MatriI
Compare the actual class 'y' vector versus the predicted class 'yp' vector, returning the confusion matrix, which for 'k = 2' is
Compare the actual class 'y' vector versus the predicted class 'yp' vector, returning the confusion matrix, which for 'k = 2' is
yp 0 1 ---------- y 0 | tn fp | 1 | fn tp | ----------
- See also
www.dataschool.io/simple-guide-to-confusion-matrix-terminology
-
def
f1_measure(prec: Double, recl: Double): Double
Compute the F1-measure, i.e., the harmonic mean of the precision and recall.
Compute the F1-measure, i.e., the harmonic mean of the precision and recall.
- prec
the precision
- recl
the recall
-
def
kappa: Double
Compute Cohen's 'kappa' coefficient that measures agreement between actual 'y' and predicted 'yp' classifications.
Compute Cohen's 'kappa' coefficient that measures agreement between actual 'y' and predicted 'yp' classifications.
- See also
en.wikipedia.org/wiki/Cohen%27s_kappa
-
def
pos_neg(con: MatriI = conf): (Double, Double, Double, Double)
Return the confusion matrix for 'k = 2' as a tuple (tn, fp, fn, tp).
Return the confusion matrix for 'k = 2' as a tuple (tn, fp, fn, tp).
- con
the confusion matrix (defaults to conf)
-
def
prec_recl: (VectoD, VectoD, Double, Double)
Compute micro-precision and micro-recall, which gives the precision and recall for each class i in {0, 1, ...
Compute micro-precision and micro-recall, which gives the precision and recall for each class i in {0, 1, ... k}. Also return the macro-precision and macro-recall that are simply their respective means. The precision is the fraction classified as true, which are actually true. The recall is the fraction of the actually true, which are classified as true. Note, for k = 2, ordinary precision and recall will correspond to the last elements in the 'prec' and 'recl' micro vectors.