RandomForest
public class RandomForest
Undocumented
-
Undocumented
Declaration
Swift
public var forest: [RandomTree]
-
Undocumented
Declaration
Swift
public var fullData: [[String]]
-
Undocumented
Declaration
Swift
public var target: Int
-
Undocumented
Declaration
Swift
public var nTrees: Int
-
Undocumented
Declaration
Swift
public var nFeatures: Int
-
Undocumented
Declaration
Swift
public var depth: Int
-
Undocumented
Declaration
Swift
public var perform: String
-
Undocumented
Declaration
Swift
public var using: String
-
Undocumented
Declaration
Swift
public var tolerance: Float
-
Initializer for Random Forest
Declaration
Swift
public init (data: [[String]], target: Int, perform: String, using: String, nTrees: Int, nFeatures: Int, depth: Int, tolerance: Float = 0.1)
Parameters
data
data with labels
target
label column number
perform
regression or classification
using
giniIndex or infoGain
nTrees
number of Trees
Return Value
Random Forest
-
Makes the forest using bootstrapped data
Declaration
Swift
public func make()
Return Value
None
-
Returns bootstrapped and out of bootData
Declaration
Swift
public func splitData(from: [[String]]) -> ([[String]], [[String]])
Parameters
from
string array of data
Return Value
boostrapped data and out of boot data
-
Classfies/Predicts an example by using all trees in the foret
Declaration
Swift
public func predict(this: [[String]]) -> String
Return Value
classification/predictions as a string
-
Scores the random forest’s accuracy on test data
Declaration
Swift
public func score(with: [[String]]) -> (Float, [String])
Parameters
testData
test data as a 2D string array with feature header
Return Value
- accuracy of classifications as float
- classifications as string array