Skip to content

Latest commit

 

History

History
63 lines (47 loc) · 2.5 KB

README.md

File metadata and controls

63 lines (47 loc) · 2.5 KB

HRLEngine

CI Status codecov.io Version Docs

This repository is DEPRECATED. Refer to HRLClassifier instead.

Use Machine Learning to predict if a person is working out based of his/her heart rate.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

HRLEngine is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "HRLEngine"

Usage

let date = Date()

let dataFrame = DataFrame()
dataFrame.append(record: Record(date:date.addingTimeInterval(-6 * 60 * 60),
                                bpm:Float(100)),
                 isWorkingOut: false)
dataFrame.append(record: Record(date:date.addingTimeInterval(-5 * 60 * 60),
                                bpm:Float(140)),
                 isWorkingOut: true)
dataFrame.append(record: Record(date:date.addingTimeInterval(-4 * 60 * 60),
                                bpm:Float(120)),
                 isWorkingOut: true)
dataFrame.append(record: Record(date:date.addingTimeInterval(-3 * 60 * 60),
                                bpm:Float(70)),
                 isWorkingOut: false)
dataFrame.append(record: Record(date:date.addingTimeInterval(-2 * 60 * 60),
                                bpm:Float(55)),
                 isWorkingOut: false)
dataFrame.append(record: Record(date:date.addingTimeInterval(-1 * 60 * 60),
                                bpm:Float(125)),
                 isWorkingOut: true)

let engine = Engine()
engine.train(with: dataFrame)

let predictDate = date.addingTimeInterval(-3.5 * 60 * 60)
let predictBPM = Float(130)
let isWorkingOut = engine.predictedWorkingOut(for: Record(date:predictDate,
                                                          bpm:predictBPM))

print("At \(predictDate) with \(predictBPM) bpm, is user working out? \(isWorkingOut)")

License

HRLEngine is available under the MIT license. See the LICENSE file for more info.