Swiftpack.co - denissimon/prediction-builder-swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by denissimon.
denissimon/prediction-builder-swift v1.2.1
A library for machine learning that builds predictions using a linear regression.
⭐️ 11
🕓 3 weeks ago
.package(url: "https://github.com/denissimon/prediction-builder-swift.git", from: "v1.2.1")

PredictionBuilder

Swift Platform

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

Installation

CocoaPods

To install PredictionBuilder using CocoaPods, add this line to your Podfile:

pod 'PredictionBuilder', '~> 1.2'

Carthage

To install PredictionBuilder using Carthage, add this line to your Cartfile:

github "denissimon/prediction-builder-swift"

Swift Package Manager

To install PredictionBuilder using Swift Package Manager, add the following to your Package.swift:

dependencies: [
    .package(url: "https://github.com/denissimon/prediction-builder-swift.git", from: "1.2")
]

Manually

Copy 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

let prediction = PredictionBuilder()

prediction.set(x: x, data: data)

// What is the expected y value for a given x value?
do {
    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

GitHub

link
Stars: 11
Last commit: 3 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

v1.2.1
3 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics