ruby_linear_regression 0.1.2 → 0.1.4

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: c4a942f9cdf052124b34dbd82121c6e23c594876
4
- data.tar.gz: f8a9df1f5bad4dff0879aec24a96eab9c3b37eb9
3
+ metadata.gz: 8cba2118afd13d70db9b3507b3cfee6a814b2e02
4
+ data.tar.gz: ba65dab424b629bb81f04811c1ddf4e24a910a85
5
5
  SHA512:
6
- metadata.gz: 55debbd4791148263d13a023c56e4cfef83cdf8e0c120e70ee95efa537ff5abe340e84113eed672a465cbe822647ca7a1b2744568fa13ac473206276bf2c878e
7
- data.tar.gz: a538ba98fa89db3610f54140bd4de6a38f28ff96c997b18a047ae8e057c6b838e38d718c50fa3eb9b00ea88630e9fd85f9417aaeecc0f4d6a104abd14e108592
6
+ metadata.gz: 9a4a4ebd99923983194a69c1cfeae6334ef0e6a7b9c5caa47c3f55ee92bddde8f8c30e735fd8b44bd3c38d4567ce4b6f3e0f1026277ebd1ecaac66b68df45b02
7
+ data.tar.gz: 02c69eb19ac21ce780767e83c1e239cb11e30aa3ac75837fff3404793e26ae429d28a8633147146f52ec47d83cad3a1a6bc3624ff02fd4116d8133195bbe5031
@@ -3,7 +3,7 @@ require 'matrix'
3
3
  # RubyLinearRegression
4
4
  class RubyLinearRegression
5
5
 
6
- attr_reader :x,:y,:theta,:mu,:sigma
6
+ attr_reader :x,:y,:theta,:mu,:sigma, :lambda, :normalize
7
7
 
8
8
  def initialize
9
9
  @mu = 0
@@ -14,10 +14,12 @@ class RubyLinearRegression
14
14
  # Arguments:
15
15
  # x_data: (Two dimensiolnal array with the independent variables of your training data)
16
16
  # y_data: (Array with the dependent variables of your training data)
17
- def load_training_data x_data, y_data
17
+ def load_training_data x_data, y_data, normalize = true
18
+
19
+ @normalize = normalize
18
20
 
19
21
  # normalize the x_data
20
- x_data = normalize_data( x_data )
22
+ x_data = normalize_data( x_data ) if @normalize
21
23
 
22
24
  # add 1 column to our data
23
25
  x_data = x_data.map { |r| [1].concat(r) }
@@ -82,7 +84,7 @@ class RubyLinearRegression
82
84
  # normalize
83
85
  data.each_index do |i|
84
86
  data[i] = (data[i] - @mu[i]) / @sigma[i].to_f
85
- end
87
+ end if @normalize
86
88
 
87
89
  # add 1 column to prediction data
88
90
  data = [1].concat( data )
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_linear_regression
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soren Blond Daugaard