RandomTree
public class RandomTree
Undocumented
-
training data set whole as inputed by user in init
Declaration
Swift
public var originalDataSet: RandomDataSet -
root node of the decision tree
Declaration
Swift
public var root: Node? -
max depth tree is grown
Declaration
Swift
public var maxDepth: Int -
number of vars to be used at every step
Declaration
Swift
public var randomVars: Int -
column number of target var
Declaration
Swift
public var target: Int -
tolerance for regression
Declaration
Swift
public var tolerance: Float -
Creates original DataSet to be stored and grows decision tree
Declaration
Swift
public init (data: [[String]], target: Int, maxDepth: Int = 9999, perform: String, using: String, with: Int, tolerance: Float = 0.1)Parameters
datadata with labels
targetcolumn number of label
performregression or classification
usinginfoGain or giniIndex
withnum of random vars to consider at each iteration
Return Value
DecisionTree
-
Returns a set of randomIndices
Declaration
Swift
public func getRandomIndices(from: RandomDataSet) -> [Int]Parameters
fromthe dataset from which the random index need to be selected
Return Value
Array of random indexes
-
displays the grown tree by calling print tree
Declaration
Swift
public func displayTree()Return Value
None
-
prints part of tree at given node and indents wrt. depth
Declaration
Swift
public func printTree(node: Node, depth: Int)Parameters
nodenode to be printed
depthdepth of the node wrt. root
Return Value
None
-
Forms decision regression tree using gini index recursively
Declaration
Swift
public func giniR(dataset: RandomDataSet, depth: Int) -> NodeParameters
datasetdata left to be used
depthcurrent depth
Return Value
Node that splits data best
-
Forms decision classification tree using gini index recursively
Declaration
Swift
public func giniC(dataset: RandomDataSet, depth: Int) -> NodeParameters
datasetdata left to be used
depthcurrent depth
Return Value
Node that splits data best
-
Examine the dataset to create classification Tree with id3 recursively
Declaration
Swift
public func id3C(dataset: RandomDataSet, depth: Int) -> NodeParameters
datasetdata left to be used
depthcurrent depth
Return Value
Node that splits data best
-
/ Examine the dataset to create regression tree with id3 recursively
Declaration
Swift
public func id3R(dataset: RandomDataSet, depth: Int) -> NodeParameters
datasetdata left to be used
depthcurrent depth
Return Value
Node that splits data best
-
Classfies/Predicts an example by traversing
Declaration
Swift
public func classify(example: [[String]]) -> StringReturn Value
classification/predictions as a string
RandomTree Class Reference