aprendizaje_maquina 0.1.3a → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  class Matrix
2
2
  def add_ones
3
- matrix = self.to_a.map{ |i| i.insert(0,1) }
4
- matrix = Matrix.rows(matrix,copy = true)
3
+ matrix = self.to_a.map{|i| i.insert(0,1)}
4
+ matrix = Matrix.rows(matrix,copy=true)
5
5
  matrix
6
6
  end
7
7
 
@@ -10,7 +10,7 @@ class Matrix
10
10
  self.column_count.times do |i|
11
11
  array << self.column(i).normalize
12
12
  end
13
- matrix_normal = Matrix.rows(array,copy = true).transpose
13
+ matrix_normal = Matrix.rows(array,copy=true).transpose
14
14
  matrix_normal
15
15
  end
16
16
  end
@@ -1,6 +1,8 @@
1
1
  module AprendizajeMaquina
2
- class RegresionLineal
3
- attr_reader :m,:b, :ecuacion, :theta
2
+
3
+ class RegresionLineal
4
+
5
+ attr_reader :m,:b, :ecuacion, :theta
4
6
 
5
7
  def initialize(x,y)
6
8
  @x = x
@@ -42,7 +44,7 @@ module AprendizajeMaquina
42
44
  raise ArgumentError, "Must be a number or matrix 1xN"
43
45
  end
44
46
  else
45
- return "There is not a equation to make predictions (first, run find_ecuation method)"
47
+ return "There is not a equation to make predictions (first, run encontrar_ecuacion method)"
46
48
  end
47
49
  end
48
50
 
@@ -65,7 +67,7 @@ module AprendizajeMaquina
65
67
  iter = @n - 1
66
68
  xy = []
67
69
  for i in 0..iter
68
- xy << array_1[i] * array_2[i]
70
+ xy << array_1[i]*array_2[i]
69
71
  end
70
72
  xy
71
73
  end
@@ -1,3 +1,3 @@
1
1
  module AprendizajeMaquina
2
- VERSION = "0.1.3a"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aprendizaje_maquina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3a
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erickson Morales
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-11 00:00:00.000000000 Z
11
+ date: 2017-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,20 +72,13 @@ files:
72
72
  - aprendizaje_maquina.gemspec
73
73
  - bin/console
74
74
  - bin/setup
75
- - examples/clasificacion_logistica_example.rb
76
- - examples/clustering_data.csv
77
- - examples/clustering_example.rb
78
- - examples/data_lg.csv
79
- - examples/regresion_lineal_example.rb
80
- - examples/train.csv
81
75
  - lib/aprendizaje_maquina.rb
82
76
  - lib/aprendizaje_maquina/cargar.rb
83
77
  - lib/aprendizaje_maquina/clasificacion_logistica.rb
84
- - lib/aprendizaje_maquina/clustering.rb
85
78
  - lib/aprendizaje_maquina/matrixx.rb
86
79
  - lib/aprendizaje_maquina/regresion_lineal.rb
87
80
  - lib/aprendizaje_maquina/version.rb
88
- homepage:
81
+ homepage: ''
89
82
  licenses:
90
83
  - MIT
91
84
  metadata: {}
@@ -100,12 +93,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
93
  version: '0'
101
94
  required_rubygems_version: !ruby/object:Gem::Requirement
102
95
  requirements:
103
- - - ">"
96
+ - - ">="
104
97
  - !ruby/object:Gem::Version
105
- version: 1.3.1
98
+ version: '0'
106
99
  requirements: []
107
100
  rubyforge_project:
108
- rubygems_version: 2.6.14
101
+ rubygems_version: 2.5.2
109
102
  signing_key:
110
103
  specification_version: 4
111
104
  summary: Machine learning gem / Una gema para el aprendizaje de maquinas.
@@ -1,16 +0,0 @@
1
- require 'aprendizaje_maquina'
2
-
3
- data = AprendizajeMaquina::Cargar.new("data_lg.csv")
4
- x = data.to_matrix(0..1).add_ones
5
- y = data.to_vector(2)
6
- theta = Vector[0,0,0]
7
- rl = AprendizajeMaquina::ClasificacionLogistica.new(x,y,theta)
8
-
9
- rl.train(12,0.01,'SGD')
10
- prediction = rl.predict(Matrix[[1,9,22]])
11
-
12
- if prediction == 1
13
- puts "cansado"
14
- else
15
- puts "descansado"
16
- end
@@ -1,177 +0,0 @@
1
- 63, 190
2
- 65, 145
3
- 69, 160
4
- 66, 130
5
- 63, 120
6
- 65, 125
7
- 68, 124
8
- 64, 135
9
- 64, 98
10
- 66, 150
11
- 67, 160
12
- 67, 140
13
- 71, 170
14
- 60, 109
15
- 68, 170
16
- 63, 165
17
- 67, 147
18
- 63, 110
19
- 68, 160
20
- 60, 125
21
- 66, 142
22
- 65, 154
23
- 62, 119
24
- 65, 135
25
- 69, 195
26
- 63, 110
27
- 63, 140
28
- 64, 219
29
- 66, 135
30
- 66, 140
31
- 68, 135
32
- 68, 99
33
- 64, 100
34
- 62, 135
35
- 74, 200
36
- 63, 150
37
- 69, 163
38
- 71, 116
39
- 68, 145
40
- 71, 140
41
- 68, 125
42
- 66, 130
43
- 72, 157
44
- 68, 200
45
- 61, 110
46
- 64, 165
47
- 70, 115
48
- 67, 153
49
- 65, 135
50
- 62, 116
51
- 63, 122
52
- 66, 130
53
- 73, 180
54
- 66, 110
55
- 69, 190
56
- 68, 160
57
- 62, 115
58
- 66, 130
59
- 64, 110
60
- 70, 150
61
- 72, 185
62
- 70, 175
63
- 66, 200
64
- 68, 180
65
- 62, 135
66
- 63, 120
67
- 63, 134
68
- 72, 185
69
- 72, 160
70
- 68, 160
71
- 65, 143
72
- 68, 180
73
- 65, 130
74
- 65, 200
75
- 65, 195
76
- 66, 160
77
- 70, 195
78
- 63, 120
79
- 69, 120
80
- 64, 110
81
- 67, 140
82
- 66, 104
83
- 63, 125
84
- 71, 140
85
- 68, 190
86
- 65, 125
87
- 66, 125
88
- 64, 125
89
- 72, 245
90
- 74, 235
91
- 62, 130
92
- 68, 135
93
- 62, 120
94
- 63, 155
95
- 65, 130
96
- 64, 130
97
- 74, 200
98
- 70, 145
99
- 68, 140
100
- 69, 135
101
- 61, 124
102
- 66, 125
103
- 76, 216
104
- 66, 120
105
- 62, 103
106
- 65, 162
107
- 69, 165
108
- 73, 164
109
- 70, 153
110
- 75, 172
111
- 58, 103
112
- 63, 135
113
- 68, 160
114
- 69, 141
115
- 67, 145
116
- 68, 148
117
- 67, 180
118
- 70, 150
119
- 70, 160
120
- 60, 170
121
- 70, 210
122
- 66, 175
123
- 64, 130
124
- 72, 172
125
- 64, 108
126
- 72, 190
127
- 66, 142
128
- 69, 235
129
- 72, 145
130
- 66, 143
131
- 70, 141
132
- 64, 110
133
- 70, 196
134
- 65, 118
135
- 72, 200
136
- 61, 145
137
- 63, 110
138
- 65, 115
139
- 70, 170
140
- 66, 160
141
- 62, 123
142
- 65, 135
143
- 68, 140
144
- 65, 160
145
- 60, 150
146
- 72, 168
147
- 61, 100
148
- 62, 100
149
- 66, 135
150
- 67, 155
151
- 62, 135
152
- 64, 200
153
- 66, 140
154
- 62, 185
155
- 65, 125
156
- 72, 165
157
- 64, 95
158
- 72, 155
159
- 65, 110
160
- 67, 165
161
- 65, 132
162
- 66, 125
163
- 64, 120
164
- 63, 130
165
- 66, 130
166
- 63, 115
167
- 59, 160
168
- 64, 150
169
- 64, 130
170
- 61, 120
171
- 66, 150
172
- 66, 250
173
- 71, 150
174
- 70, 180
175
- 69, 210
176
- 61, 105
177
- 64, 140
@@ -1,9 +0,0 @@
1
- require 'aprendizaje_maquina'
2
-
3
- load_data = AprendizajeMaquina::Cargar.new('clustering_data.csv')
4
- dataset = load_data.to_matrix
5
- clustering = AprendizajeMaquina::KmeansClustering.new(2,dataset)
6
- clustering.fit(20)
7
- p clustering.cluster(0)
8
- p clustering.cluster(1)
9
- p clustering.predict(Vector[63,190])
data/examples/data_lg.csv DELETED
@@ -1,145 +0,0 @@
1
- 0,24,1
2
- 0.1,23.5,1
3
- 0.2,23.4,1
4
- 0.3,23.3,1
5
- 0.4,23.2,1
6
- 0.5,23.1,1
7
- 1,23,1
8
- 1.1,23.5,1
9
- 1.2,23.4,1
10
- 1.3,23.3,1
11
- 1.4,23.2,1
12
- 1.5,23.1,1
13
- 2,22,1
14
- 2.1,22.5,1
15
- 2.2,22.4,1
16
- 2.3,22.3,1
17
- 2.4,22.2,1
18
- 2.5,22.1,1
19
- 3,21,1
20
- 3.1,21.5,1
21
- 3.2,21.4,1
22
- 3.3,21.3,1
23
- 3.4,21.2,1
24
- 3.5,21.1,1
25
- 4,20,1
26
- 4.1,20.5,1
27
- 4.2,20.4,1
28
- 4.3,20.3,1
29
- 4.4,20.2,1
30
- 4.5,20.1,1
31
- 5,19,1
32
- 5.1,19.5,1
33
- 5.2,19.4,1
34
- 5.3,19.3,1
35
- 5.4,19.2,1
36
- 5.5,19.1,1
37
- 6,18,1
38
- 6.1,18.5,1
39
- 6.2,18.4,1
40
- 6.3,18.3,1
41
- 6.4,18.2,1
42
- 6.5,18.1,1
43
- 7,17,1
44
- 7.1,17.5,1
45
- 7.2,17.4,1
46
- 7.3,17.3,1
47
- 7.4,17.2,1
48
- 7.5,17.1,1
49
- 8,16,0
50
- 8.1,16.5,0
51
- 8.2,16.4,0
52
- 8.3,16.3,0
53
- 8.4,16.2,0
54
- 8.5,16.1,0
55
- 9,15,0
56
- 9.1,15.5,0
57
- 9.2,15.4,0
58
- 9.3,15.3,0
59
- 9.4,15.2,0
60
- 9.5,15.1,0
61
- 10,14,0
62
- 10.1,14.5,0
63
- 10.2,14.4,0
64
- 10.3,14.3,0
65
- 10.4,14.2,0
66
- 10.5,14.1,0
67
- 11,13,0
68
- 11.1,13.5,0
69
- 11.2,13.4,0
70
- 11.3,13.3,0
71
- 11.4,13.2,0
72
- 11.5,13.1,0
73
- 12,12,0
74
- 12.1,12.5,0
75
- 12.2,12.4,0
76
- 12.3,12.3,0
77
- 12.4,12.2,0
78
- 12.5,12.1,0
79
- 13,11,0
80
- 13.1,11.5,0
81
- 13.2,11.4,0
82
- 13.3,11.3,0
83
- 13.4,11.2,0
84
- 13.5,11.1,0
85
- 14,10,0
86
- 14.1,10.5,0
87
- 14.2,10.4,0
88
- 14.3,10.3,0
89
- 14.4,10.2,0
90
- 14.5,10.1,0
91
- 15,9,0
92
- 15.1,9.5,0
93
- 15.2,9.4,0
94
- 15.3,9.3,0
95
- 15.4,9.2,0
96
- 15.5,9.1,0
97
- 16,8,0
98
- 16.1,8.5,0
99
- 16.2,8.4,0
100
- 16.3,8.3,0
101
- 16.4,8.2,0
102
- 16.5,8.1,0
103
- 17,7,0
104
- 17.1,7.5,0
105
- 17.2,7.4,0
106
- 17.3,7.3,0
107
- 17.4,7.2,0
108
- 17.5,7.1,0
109
- 18,6,0
110
- 18.1,6.5,0
111
- 18.2,6.4,0
112
- 18.3,6.3,0
113
- 18.4,6.2,0
114
- 18.5,6.1,0
115
- 19,5,0
116
- 19.1,5.5,0
117
- 19.2,5.4,0
118
- 19.3,5.3,0
119
- 19.4,5.2,0
120
- 19.5,5.1,0
121
- 20,4,0
122
- 20.1,4.5,0
123
- 20.2,4.4,0
124
- 20.3,4.3,0
125
- 20.4,4.2,0
126
- 20.5,4.1,0
127
- 21,3,0
128
- 21.1,3.5,0
129
- 21.2,3.4,0
130
- 21.3,3.3,0
131
- 21.4,3.2,0
132
- 21.5,3.1,0
133
- 22,2,0
134
- 22.1,2.5,0
135
- 22.2,2.4,0
136
- 22.3,2.3,0
137
- 22.4,2.2,0
138
- 22.5,2.1,0
139
- 23,1,0
140
- 23.1,1.5,0
141
- 23.2,1.4,0
142
- 23.3,1.3,0
143
- 23.4,1.2,0
144
- 23.5,1.1,0
145
- 24,0,0