Skip to content

Commit

Permalink
Update LinearRegression.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelesantos committed Jun 11, 2024
1 parent 40ad824 commit 04244d3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/RefdsAlgorithm/MachineLearning/LinearRegression.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ public class LinearRegression {
semaphore.signal()
}

public func predict(for features: [Double]) -> Double? {
public func predict(for features: [NSNumber]) -> Double? {
semaphore.wait()
guard !coefficients.isEmpty,
var prediction = coefficients[safe: 0]
else { return nil }

for i in features.indices {
if let coefficient = coefficients[safe: i + 1] {
prediction += coefficient * features[i]
prediction += coefficient * features[i].doubleValue
}
}
semaphore.signal()
Expand Down

0 comments on commit 04244d3

Please sign in to comment.