Packages

class DecisionTreeC45wp extends DecisionTreeC45

The DecisionTreeC45wp class extends DecisionTreeC45 with pruning capabilities. The base class uses the C45 algorithm to construct a decision tree for classifying instance vectors.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. DecisionTreeC45wp
  2. DecisionTreeC45
  3. DecisionTree
  4. ClassifierReal
  5. Classifier
  6. Model
  7. ConfusionFit
  8. Error
  9. QoF
  10. AnyRef
  11. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new DecisionTreeC45wp(x: MatriD, y: VectoI, fn_: Strings = null, k: Int = 2, cn_: Strings = null, conts: Set[Int] = Set [Int] (), hparam: HyperParameter = hp)

    x

    the input/data matrix with instances stored in rows

    y

    the response/classification vector, where y_i = class for row i of matrix x

    fn_

    the names for all features/variables

    k

    the number of classes

    cn_

    the names for all classes

    conts

    the set of feature indices for variables that are treated as continuous

    hparam

    the hyper-parameters for the decision tree

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. 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.

    Definition Classes
    ConfusionFit
  5. def add(n: Node, vc: (Int, Node)*): Unit

    Add multiple child nodes to the tree via branchs from node 'n'.

    Add multiple child nodes to the tree via branchs from node 'n'.

    n

    the parent node

    vc

    the branch value and child node, repeatable

    Definition Classes
    DecisionTree
  6. def add(n: Node, v: Int, c: Node): Unit

    Add child node 'c' to the tree via branch 'v' from node 'n'.

    Add child node 'c' to the tree via branch 'v' from node 'n'.

    n

    the parent node

    v

    the branch value from the parent node

    c

    the child node

    Definition Classes
    DecisionTree
  7. def addRoot(r: Node): Unit

    Add the root node to the tree.

    Add the root node to the tree.

    r

    the root node of the tree

    Definition Classes
    DecisionTree
  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. def bestCandidate(can: Set[Node]): (Node, Double)

    Of all the pruning candidates, find the one with the least gain.

    Of all the pruning candidates, find the one with the least gain.

    can

    the nodes that are canidates for pruning

  10. def calcCorrelation: MatriD

    Calculate the correlation matrix for the feature vectors 'fea'.

    Calculate the correlation matrix for the feature vectors 'fea'. If the correlations are too high, the independence assumption may be dubious.

    Definition Classes
    ClassifierReal
  11. def calcCorrelation2(zrg: Range, xrg: Range): MatriD

    Calculate the correlation matrix for the feature vectors of Z (Level 3) and those of X (level 2).

    Calculate the correlation matrix for the feature vectors of Z (Level 3) and those of X (level 2). If the correlations are too high, the independence assumption may be dubious.

    zrg

    the range of Z-columns

    xrg

    the range of X-columns

    Definition Classes
    ClassifierReal
  12. def calcEntropy(nodes: ArrayBuffer[Node] = leaves): Double

    Calculate the entropy of the tree as the weighted average over the list of nodes (defualts to leaves).

    Calculate the entropy of the tree as the weighted average over the list of nodes (defualts to leaves).

    nodes

    the nodes to compute the weighted entropy over

    Definition Classes
    DecisionTree
  13. def candidates: Set[Node]

    Find candidate nodes that may be pruned, i.e., those that are parents of leaf nodes, restricted to those that don't have any children that are themselves internal nodes.

  14. def classify(z: VectoD): (Int, String, Double)

    Given a data vector 'z', classify it returning the class number (0, ..., k-1) by following a decision path from the root to a leaf.

    Given a data vector 'z', classify it returning the class number (0, ..., k-1) by following a decision path from the root to a leaf. Return the best class, its name and FIX.

    z

    the data vector to classify

    Definition Classes
    DecisionTreeC45Classifier
  15. def classify(xx: MatriD = x): VectoI

    Classify all of the row vectors in matrix 'xx'.

    Classify all of the row vectors in matrix 'xx'.

    xx

    the row vectors to classify (defaults to x)

    Definition Classes
    ClassifierReal
  16. def classify(z: VectoI): (Int, String, Double)

    Given a new discrete (integer-valued) data vector 'z', determine which class it belongs to, by first converting it to a vector of doubles.

    Given a new discrete (integer-valued) data vector 'z', determine which class it belongs to, by first converting it to a vector of doubles. Return the best class, its name and its relative probability

    z

    the vector to classify

    Definition Classes
    ClassifierRealClassifier
  17. def classify2(z: VectoD): Int

    Given a data vector z, classify it returning the class number (0, ..., k-1) by following a decision path from the root to a leaf.

    Given a data vector z, classify it returning the class number (0, ..., k-1) by following a decision path from the root to a leaf. If no branch found, give maximal decision of current node. Return the best class and its name.

    z

    the data vector to classify

    Definition Classes
    DecisionTree
  18. def classify2(z: VectoI): Int

    Given a data vector z, classify it returning the class number (0, ..., k-1) by following a decision path from the root to a leaf.

    Given a data vector z, classify it returning the class number (0, ..., k-1) by following a decision path from the root to a leaf. If no branch found, give maximal decision of current node. Return the best class and its name.

    z

    the data vector to classify

    Definition Classes
    DecisionTree
  19. def clearConfusion(): Unit

    Clear the total cummulative confusion matrix.

    Clear the total cummulative confusion matrix.

    Definition Classes
    ConfusionFit
  20. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native() @HotSpotIntrinsicCandidate()
  21. var cn: Strings
    Attributes
    protected
    Definition Classes
    ClassifierReal
  22. def confusion(yp: VectoI, yy: VectoI = y): MatriI

    Compare the actual class 'y' vector versus the predicted class 'yp' vector, returning the confusion matrix 'cmat', which for 'k = 2' is

    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.t', the transpose of 'cmat'.

    yp

    the precicted class values/labels

    yy

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

    Definition Classes
    ConfusionFit
    See also

    www.dataschool.io/simple-guide-to-confusion-matrix-terminology

  23. def contrast(yp: VectoI, yy: VectoI = y): Unit

    Contract the actual class 'yy' vector versus the predicted class 'yp' vector.

    Contract the actual class 'yy' vector versus the predicted class 'yp' vector.

    yp

    the predicted class values/labels

    yy

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

    Definition Classes
    ConfusionFit
  24. def crossValidate(nx: Int = 10, show: Boolean = false): Array[Statistic]

    Test the accuracy of the classified results by cross-validation, returning the Quality of Fit (QoF) measures such as accuracy.

    Test the accuracy of the classified results by cross-validation, returning the Quality of Fit (QoF) measures such as accuracy. This method slices out instances/rows to form the test dataset.

    nx

    number of folds/crosses and cross-validations (defaults to 10x).

    show

    the show flag (show result from each iteration)

    Definition Classes
    ClassifierRealClassifier
  25. def crossValidateRand(nx: Int = 10, show: Boolean = false): Array[Statistic]

    Test the accuracy of the classified results by cross-validation, returning the Quality of Fit (QoF) measures such as accuracy.

    Test the accuracy of the classified results by cross-validation, returning the Quality of Fit (QoF) measures such as accuracy. This method randomizes the instances/rows selected for the test dataset.

    nx

    number of folds/crosses and cross-validations (defaults to 10x).

    show

    the show flag (show result from each iteration)

    Definition Classes
    ClassifierRealClassifier
  26. def diagnose(e: VectoD, yy: VectoD, yp: VectoD, w: VectoD = null, ym: Double = noDouble): Unit

    Diagnose the health of the model by computing the Quality of Fit (QoF) measures, from the error/residual vector and the predicted & actual 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. For some models the instances may be weighted.

    e

    the m-dimensional error/residual vector (yy - yp)

    yy

    the actual response vector to use (test/full)

    yp

    the predicted response vector (test/full)

    w

    the weights on the instances (defaults to null)

    ym

    the mean of the actual response vector to use (test/full)

    Definition Classes
    ConfusionFitQoF
    See also

    Regression_WLS

  27. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  28. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  29. def eval(xx: MatriD, yy: VectoD = null): ClassifierReal

    Test the quality of the training with a test dataset and return the fraction of correct classifications.

    Test the quality of the training with a test dataset and return the fraction of correct classifications.

    xx

    the integer-valued test vectors stored as rows of a matrix

    yy

    the classification vector (impl. classes should ignore or default yy to y)

    Definition Classes
    ClassifierRealModel
  30. 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.

    p

    the precision

    r

    the recall

    Definition Classes
    ConfusionFit
  31. def f1v: VectoD

    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.

    Definition Classes
    ConfusionFit
  32. def f_(z: Double): String

    Format a double value.

    Format a double value.

    z

    the double value to format

    Definition Classes
    QoF
  33. def featureSelection(TOL: Double = 0.01): Unit

    Perform feature selection on the classifier.

    Perform feature selection on the classifier. Use backward elimination technique, that is, remove the least significant feature, in terms of cross- validation accuracy, in each round.

    TOL

    tolerance indicating negligible accuracy loss when removing features

    Definition Classes
    ClassifierReal
  34. def fit: VectoD

    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.

    Definition Classes
    ConfusionFitQoF
  35. def fitLabel: Seq[String]

    Return the labels for the Quality of Fit (QoF) measures.

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

    Definition Classes
    ConfusionFitQoF
  36. def fitLabel_v: Seq[String]

    Return the labels for the Quality of Fit (QoF) measures.

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

    Definition Classes
    ConfusionFit
  37. def fitMap: Map[String, String]

    Build a map of quality of fit measures (use of LinkedHashMap makes it ordered).

    Build a map of quality of fit measures (use of LinkedHashMap makes it ordered).

    Definition Classes
    QoF
  38. def fitMicroMap: Map[String, VectoD]

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

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

    Definition Classes
    ConfusionFit
  39. final def flaw(method: String, message: String): Unit
    Definition Classes
    Error
  40. var fn: Strings
    Attributes
    protected
    Definition Classes
    ClassifierReal
  41. val fset: Array[Boolean]

    the set of features to turn on or off.

    the set of features to turn on or off. All features are on by default. Used for feature selection.

    Attributes
    protected
    Definition Classes
    ClassifierReal
  42. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  43. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  44. def help: String

    Return the help string that describes the Quality of Fit (QoF) measures provided by the ConfusionFit class.

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

    Definition Classes
    ConfusionFitQoF
  45. def hparameter: HyperParameter

    Return the model hyper-parameters (if none, return null).

    Return the model hyper-parameters (if none, return null). Hyper-parameters may be used to regularize parameters or tune the optimizer.

    Definition Classes
    ClassifierRealModel
  46. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  47. 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.

    Definition Classes
    ConfusionFit
    See also

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

  48. def leafChildren(n: Node): Boolean

    Determine whether all the children of node 'n' are leaf nodes.

    Determine whether all the children of node 'n' are leaf nodes.

    n

    the node in question

  49. val m: Int

    the number of data vectors in training-set (# rows)

    the number of data vectors in training-set (# rows)

    Attributes
    protected
    Definition Classes
    ClassifierReal
  50. def makeLeaf(n: Node): Unit

    As part of tree pruning, turn an internal node into a leaf.

    As part of tree pruning, turn an internal node into a leaf.

    n

    the node to turn into a leaf (pruning all nodes below it)

    Definition Classes
    DecisionTree
  51. val md: Double

    the training-set size as a Double

    the training-set size as a Double

    Attributes
    protected
    Definition Classes
    ClassifierReal
  52. val modelConcept: URI

    An optional reference to an ontological concept

    An optional reference to an ontological concept

    Definition Classes
    Model
  53. def modelName: String

    An optional name for the model (or modeling technique)

    An optional name for the model (or modeling technique)

    Definition Classes
    Model
  54. val n: Int

    the number of features/variables (# columns)

    the number of features/variables (# columns)

    Attributes
    protected
    Definition Classes
    ClassifierReal
  55. val nd: Double

    the feature-set size as a Double

    the feature-set size as a Double

    Attributes
    protected
    Definition Classes
    ClassifierReal
  56. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  57. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  58. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  59. 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, ...

    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.

    Definition Classes
    ConfusionFit
  60. def parameter: VectoD

    Return the vector of model parameter (feature order) vector.

    Return the vector of model parameter (feature order) vector.

    Definition Classes
    DecisionTreeC45Model
  61. def printTree(): Unit

    Print the decision tree using 'prinT' method from Node class.

    Print the decision tree using 'prinT' method from Node class.

    Definition Classes
    DecisionTree
  62. def prune(nPrune: Int = 1, threshold: Double = 0.98): Unit

    Prune 'nPrune' nodes from the tree, the ones providing the least gain.

    Prune 'nPrune' nodes from the tree, the ones providing the least gain.

    nPrune

    the number of nodes to be pruned.

    threshold

    cut-off for pruning (IG < threshold, then prune)

  63. def pseudo_rSq: Double

    Compute the Efron's pseudo R-squared value.

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

    Definition Classes
    ConfusionFit
  64. def report: String

    Return a basic report on the trained model.

    Return a basic report on the trained model.

    Definition Classes
    ClassifierRealModel
  65. def reset(): Unit

    Reset or re-initialize counters, if needed.

    Reset or re-initialize counters, if needed.

    Definition Classes
    DecisionTree
  66. def setStream(str: Int = 0): Unit

    Set the random number 'stream' to 'str'.

    Set the random number 'stream' to 'str'. This is useful for testing purposes, since a fixed stream will follow the same sequence each time.

    str

    the new fixed random number stream

    Definition Classes
    Classifier
  67. def size: Int

    Return the number of data vectors in training/test-set (# rows).

    Return the number of data vectors in training/test-set (# rows).

    Definition Classes
    ClassifierRealClassifier
  68. val stream: Int

    the random number stream {0, 1, ..., 999} to be used

    the random number stream {0, 1, ..., 999} to be used

    Attributes
    protected
    Definition Classes
    Classifier
  69. def summary(b: VectoD = null, show: Boolean = false): String

    Produce a summary report with diagnostics and the overall quality of fit.

    Produce a summary report with diagnostics and the overall quality of fit.

    b

    the parameters of the model

    show

    flag indicating whether to print the summary

    Definition Classes
    ConfusionFit
  70. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  71. def test(xx: MatriD, yy: VectoI): Double

    Test the quality of the training with a test-set and return the fraction of correct classifications.

    Test the quality of the training with a test-set and return the fraction of correct classifications.

    xx

    the real-valued test vectors stored as rows of a matrix

    yy

    the test classification vector, where 'yy_i = class for row i of xx'

    Definition Classes
    ClassifierReal
  72. def test(itest: Ints): Double

    Test the quality of the training with a test-set and return the fraction of correct classifications.

    Test the quality of the training with a test-set and return the fraction of correct classifications.

    itest

    indices of the instances considered test data

    Definition Classes
    ClassifierRealClassifier
  73. def test(testStart: Int, testEnd: Int): Double

    Test the quality of the training with a test dataset and return the fraction of correct classifications.

    Test the quality of the training with a test dataset and return the fraction of correct classifications. Can be used when the dataset is randomized so that the testing/training part of a dataset corresponds to simple slices of vectors and matrices.

    testStart

    the beginning of test region (inclusive).

    testEnd

    the end of test region (exclusive).

    Definition Classes
    Classifier
  74. def tn_fp_fn_tp(con: MatriI = cmat): (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 cmat)

    Definition Classes
    ConfusionFit
  75. def toString(): String
    Definition Classes
    AnyRef → Any
  76. def total_cmat(): MatriI

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

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

    Definition Classes
    ConfusionFit
  77. def train(itest: Ints): DecisionTreeC45

    Train the decision tree.

    Train the decision tree.

    itest

    the indices for the test data (currently not used)

    Definition Classes
    DecisionTreeC45Classifier
  78. def train(xx: MatriD = null, yy: VectoD = null): Classifier

    Train the classifier by computing the probabilities from a training dataset of data vectors and their classifications.

    Train the classifier by computing the probabilities from a training dataset of data vectors and their classifications. Must be implemented in any extending class. Can be used when the whole dataset is used for training.

    xx

    the data/input matrix (impl. classes should ignore or default xx to x)

    yy

    the response/classification vector (impl. classes should ignore or default yy to y)

    Definition Classes
    ClassifierModel
  79. def train(testStart: Int, testEnd: Int): Classifier

    Train the classifier by computing the probabilities from a training dataset of data vectors and their classifications.

    Train the classifier by computing the probabilities from a training dataset of data vectors and their classifications. Must be implemented in any extending class. Can be used when the dataset is randomized so that the training part of a dataset corresponds to simple slices of vectors and matrices.

    testStart

    starting index of test region (inclusive) used in cross-validation

    testEnd

    ending index of test region (exclusive) used in cross-validation

    Definition Classes
    Classifier
  80. def vc_default: Array[Int]

    Return default values for binary input data (value count 'vc' set to 2).

    Return default values for binary input data (value count 'vc' set to 2). Also may be used for binning into two categories.

    Definition Classes
    ClassifierReal
  81. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  82. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  83. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] ) @Deprecated
    Deprecated

Inherited from DecisionTreeC45

Inherited from DecisionTree

Inherited from ClassifierReal

Inherited from Classifier

Inherited from Model

Inherited from ConfusionFit

Inherited from Error

Inherited from QoF

Inherited from AnyRef

Inherited from Any

Ungrouped