Packages

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.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ConfusionMat
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. 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

  1. 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.

  2. 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

  3. 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

  4. 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

  5. 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)

  6. 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.