Latest 1.0.2
Homepage https://github.com/denissimon/prediction-builder-swift
License MIT
Platforms ios 8.0, osx 10.9, watchos 2.0, tvos 9.0, requires ARC
Authors

PredictionBuilder is a library for machine learning that builds predictions using a linear regression.

Requirements

Swift 3.0+

Installation

CocoaPods

To install the library using CocoaPods, add it to your Podfile:

use_frameworks!
pod 'PredictionBuilder'

Then, run pod install (or pod update).

Carthage

To install the library using Carthage, add it to your Cartfile:

github "denissimon/prediction-builder-swift"

Run carthage update to build the framework and drag the built PredictionBuilder.framework into your project.

Swift Package Manager

To install the library using the Swift Package Manager, add it to your Package.swift file:

dependencies: [
    .Package(url: "https://github.com/denissimon/prediction-builder-swift.git", majorVersion: 1)
]

Manual

Simply drag PredictionBuilder.swift into your project.

Example

import PredictionBuilder

let data: [[Double]] = [[1,20],[2,70],[2,45],[3,81],[5,73],[6,80],[7,110]]
let x: Double = 4.5

// What is the expected y value for a given x value?
do {
    let prediction = PredictionBuilder(x: x, data: data)
    let result = try prediction.build() // y = 76.65
} catch let msg {
    print(msg)
}

The returned instance has the following properties:

result.lnModel linear model that fits the data: "29.56362+10.46364x"

result.cor correlation coefficient: 0.8348

result.x given x value: 4.5

result.y predicted y value: 76.65

License

Licensed under the MIT license

Latest podspec

{
    "name": "PredictionBuilder",
    "version": "1.0.2",
    "homepage": "https://github.com/denissimon/prediction-builder-swift",
    "authors": {
        "Denis Simon": "[email protected]"
    },
    "summary": "A library for machine learning that builds predictions using a linear regression.",
    "license": {
        "type": "MIT"
    },
    "source": {
        "git": "https://github.com/denissimon/prediction-builder-swift.git",
        "tag": "v1.0.2"
    },
    "source_files": "Sources/PredictionBuilder.swift",
    "requires_arc": true,
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This