aprendizaje_maquina 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0a8b0a74d8f2e8f8b22a89bd9b6a5f8d1d36ef7
4
- data.tar.gz: d631cfcae79261763f72b1c1f8ac94b1c8b80f56
3
+ metadata.gz: 3c2e981b08fdd73029daf73b0836ced26dd40dce
4
+ data.tar.gz: a9e5fd556a2b44b338b670ce26b4a78fab94fa48
5
5
  SHA512:
6
- metadata.gz: f3065a235bb3cca7c5d325290d0b8b62d2991743d8f4321bc0eae82080b96942e4a4b323b18deab58cd01bf04c6e9e438bad8fd3183517e0f2f2a1eabe3caa8a
7
- data.tar.gz: c7ca538696ab235ce326415eb6ebb70e7c97d51d15f33fff7c1f5b1c0f3f6425f74cfffabc8083999a0a92d582bbbc9887ca58eaf92366483240a74689cc35a8
6
+ metadata.gz: 2c8b5f72b79679e33dec9c26deebfabc255eb87929a2a1896b4f49e4d728cd2c4338ddc412a255a742071d199b025515132af9f67030a9408b6c125d9e32bc4c
7
+ data.tar.gz: 2f1066aa20a5a93879dfacd4c4557e344088cf3cd8c2168d61c64032e4e0d6d7bb327ab2f5fd844f8b46d1ad97367aa14e775c523076c1fdc3d8906ea02aca25
@@ -4,4 +4,13 @@ class Matrix
4
4
  matrix = Matrix.rows(matrix,copy=true)
5
5
  matrix
6
6
  end
7
+
8
+ def normalize
9
+ array = []
10
+ self.column_count.times do |i|
11
+ array << self.column(i).normalize
12
+ end
13
+ matrix_normal = Matrix.rows(array,copy=true).transpose
14
+ matrix_normal
15
+ end
7
16
  end
@@ -1,9 +1,8 @@
1
1
  module AprendizajeMaquina
2
2
 
3
3
  class RegresionLineal
4
-
4
+
5
5
  attr_reader :m,:b, :ecuacion, :theta
6
- attr_accessor :x,:y
7
6
 
8
7
  def initialize(x,y)
9
8
  @x = x
@@ -16,7 +15,7 @@ module AprendizajeMaquina
16
15
  end
17
16
  end
18
17
 
19
- def encontrar_ecuacion
18
+ def find_ecuation
20
19
  if @x.is_a?(Array) && @y.is_a?(Array)
21
20
  @trained = true
22
21
  @m = ((@n*sumatoria(multiplicar(@x,@y))) - (sumatoria(@x)*sumatoria(@y))).to_f / ((@n*sumatoria(al_cuadrado(@x))) - (sumatoria(@x)**2)).to_f
@@ -33,7 +32,7 @@ module AprendizajeMaquina
33
32
  end
34
33
  end
35
34
 
36
- def hacer_prediccion(x_a_predecir)
35
+ def make_prediction(x_a_predecir)
37
36
  if @trained == true
38
37
  if x_a_predecir.is_a?(Numeric)
39
38
  prediccion = (@m * x_a_predecir) + @b
@@ -46,13 +45,22 @@ module AprendizajeMaquina
46
45
  end
47
46
  else
48
47
  return "There is not a equation to make predictions (first, run encontrar_ecuacion method)"
49
- <<<<<<< HEAD
50
48
  end
51
- =======
52
- end
53
- >>>>>>> c8f8271ff1de1334797f9c6f048289c908e9dcb5
54
49
  end
55
50
 
51
+ alias_method :train, :find_ecuation
52
+ alias_method :predict, :make_prediction
53
+
54
+ def self.deprecate(old_method, new_method)
55
+ define_method(old_method) do |*args, &block|
56
+ warn "Warning: #{old_method}() is deprecated. Use #{new_method}()."
57
+ send(new_method, *args, &block)
58
+ end
59
+ end
60
+
61
+ deprecate :encontrar_ecuacion, :find_ecuation
62
+ deprecate :hacer_prediccion, :make_prediction
63
+
56
64
  private
57
65
 
58
66
  def multiplicar(array_1,array_2)
@@ -81,4 +89,4 @@ module AprendizajeMaquina
81
89
  sumatoria(array).to_f / array.length
82
90
  end
83
91
  end
84
- end
92
+ end
@@ -1,3 +1,3 @@
1
1
  module AprendizajeMaquina
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erickson Morales
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-11 00:00:00.000000000 Z
11
+ date: 2017-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler