ml.rb 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +12 -0
- data/README.md +4 -0
- data/Rakefile +2 -0
- data/data/ex1data1.txt +97 -0
- data/lib/ext.rb +14 -0
- data/lib/linear_regression.rb +19 -0
- data/lib/ml/version.rb +4 -0
- data/lib/ml.rb +4 -0
- data/ml.rb.gemspec +19 -0
- data/spec/linear_regression_spec.rb +6 -0
- metadata +72 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
data/data/ex1data1.txt
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
6.1101,17.592
|
2
|
+
5.5277,9.1302
|
3
|
+
8.5186,13.662
|
4
|
+
7.0032,11.854
|
5
|
+
5.8598,6.8233
|
6
|
+
8.3829,11.886
|
7
|
+
7.4764,4.3483
|
8
|
+
8.5781,12
|
9
|
+
6.4862,6.5987
|
10
|
+
5.0546,3.8166
|
11
|
+
5.7107,3.2522
|
12
|
+
14.164,15.505
|
13
|
+
5.734,3.1551
|
14
|
+
8.4084,7.2258
|
15
|
+
5.6407,0.71618
|
16
|
+
5.3794,3.5129
|
17
|
+
6.3654,5.3048
|
18
|
+
5.1301,0.56077
|
19
|
+
6.4296,3.6518
|
20
|
+
7.0708,5.3893
|
21
|
+
6.1891,3.1386
|
22
|
+
20.27,21.767
|
23
|
+
5.4901,4.263
|
24
|
+
6.3261,5.1875
|
25
|
+
5.5649,3.0825
|
26
|
+
18.945,22.638
|
27
|
+
12.828,13.501
|
28
|
+
10.957,7.0467
|
29
|
+
13.176,14.692
|
30
|
+
22.203,24.147
|
31
|
+
5.2524,-1.22
|
32
|
+
6.5894,5.9966
|
33
|
+
9.2482,12.134
|
34
|
+
5.8918,1.8495
|
35
|
+
8.2111,6.5426
|
36
|
+
7.9334,4.5623
|
37
|
+
8.0959,4.1164
|
38
|
+
5.6063,3.3928
|
39
|
+
12.836,10.117
|
40
|
+
6.3534,5.4974
|
41
|
+
5.4069,0.55657
|
42
|
+
6.8825,3.9115
|
43
|
+
11.708,5.3854
|
44
|
+
5.7737,2.4406
|
45
|
+
7.8247,6.7318
|
46
|
+
7.0931,1.0463
|
47
|
+
5.0702,5.1337
|
48
|
+
5.8014,1.844
|
49
|
+
11.7,8.0043
|
50
|
+
5.5416,1.0179
|
51
|
+
7.5402,6.7504
|
52
|
+
5.3077,1.8396
|
53
|
+
7.4239,4.2885
|
54
|
+
7.6031,4.9981
|
55
|
+
6.3328,1.4233
|
56
|
+
6.3589,-1.4211
|
57
|
+
6.2742,2.4756
|
58
|
+
5.6397,4.6042
|
59
|
+
9.3102,3.9624
|
60
|
+
9.4536,5.4141
|
61
|
+
8.8254,5.1694
|
62
|
+
5.1793,-0.74279
|
63
|
+
21.279,17.929
|
64
|
+
14.908,12.054
|
65
|
+
18.959,17.054
|
66
|
+
7.2182,4.8852
|
67
|
+
8.2951,5.7442
|
68
|
+
10.236,7.7754
|
69
|
+
5.4994,1.0173
|
70
|
+
20.341,20.992
|
71
|
+
10.136,6.6799
|
72
|
+
7.3345,4.0259
|
73
|
+
6.0062,1.2784
|
74
|
+
7.2259,3.3411
|
75
|
+
5.0269,-2.6807
|
76
|
+
6.5479,0.29678
|
77
|
+
7.5386,3.8845
|
78
|
+
5.0365,5.7014
|
79
|
+
10.274,6.7526
|
80
|
+
5.1077,2.0576
|
81
|
+
5.7292,0.47953
|
82
|
+
5.1884,0.20421
|
83
|
+
6.3557,0.67861
|
84
|
+
9.7687,7.5435
|
85
|
+
6.5159,5.3436
|
86
|
+
8.5172,4.2415
|
87
|
+
9.1802,6.7981
|
88
|
+
6.002,0.92695
|
89
|
+
5.5204,0.152
|
90
|
+
5.0594,2.8214
|
91
|
+
5.7077,1.8451
|
92
|
+
7.6366,4.2959
|
93
|
+
5.8707,7.2029
|
94
|
+
5.3054,1.9869
|
95
|
+
8.2934,0.14454
|
96
|
+
13.394,9.0551
|
97
|
+
5.4369,0.61705
|
data/lib/ext.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
class LinearRegression
|
2
|
+
# Parameters:
|
3
|
+
#
|
4
|
+
# x - m by n matrix
|
5
|
+
# y - vector of length m
|
6
|
+
#
|
7
|
+
# TODO (farleyknight@gmail.com): If x happens to be a vector
|
8
|
+
# we should use the, presumably, less costly computation of
|
9
|
+
# using GSL::Fit::linear(x, y) over GSL::MultiFit::linear(X, y)
|
10
|
+
def fit(x, y)
|
11
|
+
raise "" unless x.is_a? Matrix
|
12
|
+
raise "" unless y.is_a? Vector and y.length == x.shape[1]
|
13
|
+
end
|
14
|
+
|
15
|
+
# x - vector of length n
|
16
|
+
def predict(x)
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
data/lib/ml/version.rb
ADDED
data/lib/ml.rb
ADDED
data/ml.rb.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = 'ml.rb'
|
4
|
+
s.version = '0.0.1'
|
5
|
+
s.date = '2012-08-14'
|
6
|
+
s.summary = "A bunch of machine learning algorithms, written in Ruby"
|
7
|
+
s.description = "A bunch of machine learning algorithms, written in Ruby"
|
8
|
+
s.authors = ["Farley Knight"]
|
9
|
+
s.email = 'farleyknight@gmail.com'
|
10
|
+
|
11
|
+
s.homepage = 'https://github.com/farleyknight/ml.rb'
|
12
|
+
|
13
|
+
s.add_development_dependency "bundler", ">= 1.0.0"
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
17
|
+
s.require_path = 'lib'
|
18
|
+
end
|
19
|
+
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ml.rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Farley Knight
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.0
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.0.0
|
30
|
+
description: A bunch of machine learning algorithms, written in Ruby
|
31
|
+
email: farleyknight@gmail.com
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- .gitignore
|
37
|
+
- Gemfile
|
38
|
+
- Gemfile.lock
|
39
|
+
- README.md
|
40
|
+
- Rakefile
|
41
|
+
- data/ex1data1.txt
|
42
|
+
- lib/ext.rb
|
43
|
+
- lib/linear_regression.rb
|
44
|
+
- lib/ml.rb
|
45
|
+
- lib/ml/version.rb
|
46
|
+
- ml.rb.gemspec
|
47
|
+
- spec/linear_regression_spec.rb
|
48
|
+
homepage: https://github.com/farleyknight/ml.rb
|
49
|
+
licenses: []
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.8.24
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: A bunch of machine learning algorithms, written in Ruby
|
72
|
+
test_files: []
|