February 2018
Intermediate to advanced
378 pages
10h 14m
English
The training part is also very similar to linear regression:
public func train(xMat: [[Double]], yVec: [Double], learningRate: Double, maxSteps: Int) {
precondition(maxSteps > 0, "The number of learning iterations should be grater then 0.")
let sampleCount = xMat.count
precondition(sampleCount == yVec.count, "The number of samples in xMat should be equal to the number of labels in yVec.")
precondition(sampleCount > 0, "xMat should contain at least one sample.")
precondition(xMat.first!.count > 0, "Samples should have at least one feature.")
let featureCount = xMat.first!.count
let weightsCount = featureCount+1
weights = [Double](repeating: 1.0, count: weightsCount)
if normalization { // Flatten let flattenedXMat ...Read now
Unlock full access