February 2018
Intermediate to advanced
378 pages
10h 14m
English
I'm not describing here a .csv parsing in Swift; if you are interested in the details, please see the supplementary materials. Assuming that you've successfully loaded the test data in the form of two arrays, [Double] for features and [String] for labels, have a go at the following code:
let (xMat, yVec) = loadCSVData()
To create a decision tree and evaluate it, try this:
let sklDecisionTree = DecisionTree() let xSKLDecisionTree = xMat.map { (x: [Double]) -> DecisionTreeInput in return DecisionTreeInput(length: x[0], fluffy: x[1], color_light_black: x[2], color_pink_gold: x[3], color_purple_polka_dot: x[4], color_space_gray: x[5]) } let predictionsSKLTree = try! xSKLDecisionTree .map(sklDecisionTree.prediction) ...Read now
Unlock full access