HRLEngine 0.2.8

HRLEngine 0.2.8

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Dec 2016
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Enrique de la Torre.



HRLEngine 0.2.8

  • By
  • Enrique de la Torre

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.