Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished creating SimpleLinearRegression class (which allows the use …
…of 1 feature set and 1 set of output) and the PolynomialRegression class which allows for multiple features. The class have been tested on another example Xcode project, but unit tests will be coming soon
- Loading branch information
Guled
committed
Jul 3, 2016
1 parent
cac9741
commit c3c3874
Showing
31 changed files
with
7,009 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[submodule "Carthage/Checkouts/Upsurge"] | ||
path = Carthage/Checkouts/Upsurge | ||
url = https://github.com/aleph7/Upsurge.git | ||
[submodule "Carthage/Checkouts/SwiftCSV"] | ||
path = Carthage/Checkouts/SwiftCSV | ||
url = https://github.com/naoty/SwiftCSV.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github "aleph7/Upsurge" | ||
github "naoty/SwiftCSV" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github "naoty/SwiftCSV" "0.3.2" | ||
github "aleph7/Upsurge" "0.7.1" |
3,076 changes: 3,076 additions & 0 deletions
3,076
Carthage/Build/iOS/5FD32965-4A8D-3B49-863A-52CC8CA028E9.bcsymbolmap
Large diffs are not rendered by default.
Oops, something went wrong.
3,058 changes: 3,058 additions & 0 deletions
3,058
Carthage/Build/iOS/76FBCEEB-5344-3B4C-87CE-1B427BF1FF26.bcsymbolmap
Large diffs are not rendered by default.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
Carthage/Build/iOS/Upsurge.framework.dSYM/Contents/Info.plist
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file added
BIN
+10.6 MB
Carthage/Build/iOS/Upsurge.framework.dSYM/Contents/Resources/DWARF/Upsurge
Binary file not shown.
99 changes: 99 additions & 0 deletions
99
Carthage/Build/iOS/Upsurge.framework/Headers/Upsurge-Swift.h
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file added
BIN
+37.4 KB
Carthage/Build/iOS/Upsurge.framework/Modules/Upsurge.swiftmodule/arm.swiftdoc
Binary file not shown.
Binary file added
BIN
+604 KB
Carthage/Build/iOS/Upsurge.framework/Modules/Upsurge.swiftmodule/arm.swiftmodule
Binary file not shown.
Binary file added
BIN
+37.4 KB
Carthage/Build/iOS/Upsurge.framework/Modules/Upsurge.swiftmodule/arm64.swiftdoc
Binary file not shown.
Binary file added
BIN
+604 KB
Carthage/Build/iOS/Upsurge.framework/Modules/Upsurge.swiftmodule/arm64.swiftmodule
Binary file not shown.
Binary file added
BIN
+37.4 KB
Carthage/Build/iOS/Upsurge.framework/Modules/Upsurge.swiftmodule/i386.swiftdoc
Binary file not shown.
Binary file added
BIN
+604 KB
Carthage/Build/iOS/Upsurge.framework/Modules/Upsurge.swiftmodule/i386.swiftmodule
Binary file not shown.
Binary file added
BIN
+37.4 KB
Carthage/Build/iOS/Upsurge.framework/Modules/Upsurge.swiftmodule/x86_64.swiftdoc
Binary file not shown.
Binary file added
BIN
+604 KB
Carthage/Build/iOS/Upsurge.framework/Modules/Upsurge.swiftmodule/x86_64.swiftmodule
Binary file not shown.
10 changes: 10 additions & 0 deletions
10
Carthage/Build/iOS/Upsurge.framework/Modules/module.modulemap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
// | ||
// DataManager.swift | ||
// MLKit | ||
// | ||
// Created by Guled on 6/30/16. | ||
// Copyright © 2016 Somnibyte. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Upsurge | ||
|
||
/** | ||
The Numeric Type Protocol allows for generic functions | ||
to take in integers or doubles or floats. | ||
*/ | ||
public protocol NumericType { | ||
func +(lhs: Self, rhs: Self) -> Self | ||
func -(lhs: Self, rhs: Self) -> Self | ||
func *(lhs: Self, rhs: Self) -> Self | ||
func /(lhs: Self, rhs: Self) -> Self | ||
func %(lhs: Self, rhs: Self) -> Self | ||
init(_ v: Int) | ||
} | ||
|
||
|
||
extension Double : NumericType { } | ||
extension Float : NumericType { } | ||
extension Int : NumericType { } | ||
extension Int8 : NumericType { } | ||
extension Int16 : NumericType { } | ||
extension Int32 : NumericType { } | ||
extension Int64 : NumericType { } | ||
extension UInt : NumericType { } | ||
extension UInt8 : NumericType { } | ||
extension UInt16 : NumericType { } | ||
extension UInt32 : NumericType { } | ||
extension UInt64 : NumericType { } | ||
|
||
|
||
public class MLDataManager{ | ||
|
||
|
||
enum MLDataHandelingError: ErrorType { | ||
|
||
} | ||
|
||
|
||
/** | ||
Description Goes Here | ||
@param | ||
@return | ||
*/ | ||
public static func sumUpData<T: NumericType> (data: Array<T>) -> T { | ||
var sum = T(0) | ||
for val in data{ | ||
sum = sum + val | ||
} | ||
return sum | ||
} | ||
|
||
/** | ||
Description Goes Here | ||
@param | ||
@return | ||
*/ | ||
public static func mean<T: NumericType> (data: Array<T>) -> T { | ||
let totalSum = sumUpData(data) | ||
let totalAmountOfData = T(data.count) | ||
return totalSum/totalAmountOfData | ||
} | ||
|
||
public static func dataToMatrix (features:[Array<Float>], output: Array<Float>) -> (Matrix<Float>,ValueArray<Float>) { | ||
|
||
|
||
// Create Output Matrix | ||
let output_matrix = Matrix<Float>(rows:output.count, columns: 1, elements:output) | ||
|
||
// Create "contant/intercept" list | ||
let contant_array = [Float](count: features[0].count, repeatedValue: 1.0) | ||
var matrix_as_array:[[Float]] = [] | ||
|
||
for (i, _) in contant_array.enumerate() { | ||
var new_row:[Float] = [] | ||
new_row.append(contant_array[i]) | ||
|
||
for feature_array in features { | ||
new_row.append(feature_array[i]) | ||
} | ||
|
||
matrix_as_array.append(new_row) | ||
} | ||
|
||
let feature_matrix = Matrix<Float>(matrix_as_array) | ||
|
||
return (feature_matrix, output_matrix.elements) | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The license can be found here: https://creativecommons.org/licenses/by/4.0/ |
Oops, something went wrong.