FitC

scalation.modeling.classifying.FitC
See theFitC companion object
trait FitC(k: Int) extends FitM

The FitC trait provides methods for determining the confusion matrix as well as derived Quality of Fit (QoF) measures such as pseudo R-squared, sst, sse, accuracy, precision, recall, specificity and Cohen's kappa coefficient.

Value parameters

k

the number distinct class values/labels (defaults to 2)

Attributes

See also

modeling.Fit Must call the confusion method before calling the other methods.

Companion
object
Graph
Supertypes
trait FitM
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Concrete methods

def accuracy: Double

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.

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.

Attributes

def clearConfusion(): Unit

Clear the total cummulative confusion matrix.

Clear the total cummulative confusion matrix.

Attributes

def confusion(y_: VectorI, yp: VectorI): MatrixI

Compare the actual class y vector versus the predicted class yp vector, returning the confusion matrix cmat, which for k = 2 is yp 0 1 ---------- y 0 | tn fp | 1 | fn tp | ---------- Note: ScalaTion's confusion matrix is Actual × Predicted, but to swap the position of actual y (rows) with predicted yp (columns) simply use cmat.transpose, the transpose of cmat.

Compare the actual class y vector versus the predicted class yp vector, returning the confusion matrix cmat, which for k = 2 is yp 0 1 ---------- y 0 | tn fp | 1 | fn tp | ---------- Note: ScalaTion's confusion matrix is Actual × Predicted, but to swap the position of actual y (rows) with predicted yp (columns) simply use cmat.transpose, the transpose of cmat.

Value parameters

y_

the actual class values/labels for full (y) or test (y_e) dataset

yp

the predicted class values/labels

Attributes

See also
def contrast(y_: VectorI, yp: VectorI): Unit

Contract the actual class y_ vector versus the predicted class yp vector.

Contract the actual class y_ vector versus the predicted class yp vector.

Value parameters

y_

the actual class values/labels for full (y) or test (y_e) dataset

yp

the predicted class values/labels

Attributes

override def diagnose(y_: VectorD, yp: VectorD, w: VectorD): VectorD

Diagnose the health of the model by computing the Quality of Fit (QoF) measures, from the error/residual vector and the predicted & actual responses. For some models the instances may be weighted.

Diagnose the health of the model by computing the Quality of Fit (QoF) measures, from the error/residual vector and the predicted & actual responses. For some models the instances may be weighted.

Value parameters

w

the weights on the instances (defaults to null)

y_

the actual response/output vector to use (test/full)

yp

the predicted response/output vector (test/full)

Attributes

Definition Classes
def diagnose(y_: VectorI, yp: VectorI): VectorD

Diagnose the health of the model by computing the Quality of Fit (QoF) measures, from the error/residual vector and the predicted & actual responses. Requires the actual and predicted responses to be non-negative integers. Must override when there negative responses.

Diagnose the health of the model by computing the Quality of Fit (QoF) measures, from the error/residual vector and the predicted & actual responses. Requires the actual and predicted responses to be non-negative integers. Must override when there negative responses.

Value parameters

y_

the actual response/output vector to use (test/full)

yp

the predicted response/output vector (test/full)

Attributes

def f1_measure(p: Double, r: 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.

Value parameters

p

the precision

r

the recall

Attributes

def f1v: VectorD

Compute the micro-F1-measure vector, i.e., the harmonic mean of the precision and recall.

Compute the micro-F1-measure vector, i.e., the harmonic mean of the precision and recall.

Attributes

def fit: VectorD

Return the Quality of Fit (QoF) measures corresponding to the labels given above in the fitLabel method.

Return the Quality of Fit (QoF) measures corresponding to the labels given above in the fitLabel method.

Attributes

def fitLabel_v: Seq[String]

Return the labels for the Quality of Fit (QoF) measures. Override to add additional QoF measures.

Return the labels for the Quality of Fit (QoF) measures. Override to add additional QoF measures.

Attributes

def fitMicroMap: Map[String, VectorD]

Return the Quality of Fit (QoF) vector micro-measures, i.e., measures for each class.

Return the Quality of Fit (QoF) vector micro-measures, i.e., measures for each class.

Attributes

def help: String

Return the help string that describes the Quality of Fit (QoF) measures provided by the FitC class. Override to correspond to fitLabel.

Return the help string that describes the Quality of Fit (QoF) measures provided by the FitC class. Override to correspond to fitLabel.

Attributes

def kappaf(y_: VectorI, yp: VectorI): 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.

Value parameters

y_

the actual response/output vector to use (test/full)

yp

the predicted response/output vector (test/full)

Attributes

See also

en.wikipedia.org/wiki/Cohen%27s_kappa

def p_r_s(): Unit

Compute the micro-precision, micro-recall and micro-specificity vectors which have elements for each class i in {0, 1, ... k-1}. Precision is the fraction classified as true that are actually true. Recall (sensitivity) is the fraction of the actually true that are classified as true. Specificity is the fraction of the actually false that are classified as false. Note, for k = 2, ordinary precision p, recall r and specificity s will correspond to the last elements in the pv, rv and sv micro vectors.

Compute the micro-precision, micro-recall and micro-specificity vectors which have elements for each class i in {0, 1, ... k-1}. Precision is the fraction classified as true that are actually true. Recall (sensitivity) is the fraction of the actually true that are classified as true. Specificity is the fraction of the actually false that are classified as false. Note, for k = 2, ordinary precision p, recall r and specificity s will correspond to the last elements in the pv, rv and sv micro vectors.

Attributes

def pseudo_rSq: Double

Compute the Efron's pseudo R-squared value. Override to McFadden's, etc.

Compute the Efron's pseudo R-squared value. Override to McFadden's, etc.

Value parameters

p1

the first parameter

p2

the second parameter

Attributes

def summary(x_: MatrixD, fname: Array[String], b: VectorD, vifs: VectorD): String

Produce a summary report with diagnostics and the overall Quality of Fit (QoF). Classifier should override this method.

Produce a summary report with diagnostics and the overall Quality of Fit (QoF). Classifier should override this method.

Value parameters

b

the parameters/pmf for the model

fname

the array of feature/variable names

vifs

the Variance Inflation Factors (VIFs)

x_

the testing/full data/input matrix

Attributes

def tn_fp_fn_tp(con: MatrixI): (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).

Value parameters

con

the confusion matrix (defaults to cmat)

Attributes

Return a copy of the total cumulative confusion matrix tcmat and clear tcmat.

Return a copy of the total cumulative confusion matrix tcmat and clear tcmat.

Attributes

Inherited methods

def rSq0_: Double

Attributes

Inherited from:
FitM
def rSq_: Double

Return the coefficient of determination (R^2). Must call diagnose first.

Return the coefficient of determination (R^2). Must call diagnose first.

Attributes

Inherited from:
FitM
def sse_: Double

Return the sum of the squares for error (sse). Must call diagnose first.

Return the sum of the squares for error (sse). Must call diagnose first.

Attributes

Inherited from:
FitM