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
data
data with labels
target
column number of label
perform
regression or classification
using
infoGain or giniIndex
with
num 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
from
the 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
node
node to be printed
depth
depth 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) -> Node
Parameters
dataset
data left to be used
depth
current 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) -> Node
Parameters
dataset
data left to be used
depth
current 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) -> Node
Parameters
dataset
data left to be used
depth
current 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) -> Node
Parameters
dataset
data left to be used
depth
current depth
Return Value
Node that splits data best
-
Classfies/Predicts an example by traversing
Declaration
Swift
public func classify(example: [[String]]) -> String
Return Value
classification/predictions as a string