Class: Uranai::FeatureNormalizer

Inherits:
Object
  • Object
show all
Defined in:
lib/uranai/feature_normalizer.rb

Instance Method Summary collapse

Constructor Details

#initialize(feature) ⇒ FeatureNormalizer

Returns a new instance of FeatureNormalizer.



5
6
7
# File 'lib/uranai/feature_normalizer.rb', line 5

def initialize(feature)
  @feature = feature
end

Instance Method Details

#normalizeObject



9
10
11
12
13
14
15
16
17
# File 'lib/uranai/feature_normalizer.rb', line 9

def normalize
  (matrix_feature - matrix_mean)
    .transpose
    .to_a
    .zip(std_of_each_feature)
    .map do |arr|
      arr[0].map { |ele| ele / arr[1] }
    end
end