February 2018
Intermediate to advanced
378 pages
10h 14m
English
Let's now see how to train the multiple regression:
private func prepentColumnOfOnes(matrix: [Double], rows: Int, columns: Int) -> [Double] { let weightsCount = columns+1 var withFirstDummyColumn = [Double](repeating: 1.0, count: rows * (columns+1)) for row in 0..<rows { for column in 1..<weightsCount { withFirstDummyColumn[row*weightsCount + column] = matrix[row*columns + column-1] } } return withFirstDummyColumn } 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 ...Read now
Unlock full access