Method: Rumale::Preprocessing::L2Normalizer#fit_transform

Defined in:
lib/rumale/preprocessing/l2_normalizer.rb

#fit_transform(x) ⇒ Numo::DFloat

Calculate L2-norms of each sample, and then normalize samples to unit L2-norm.

Parameters:

  • x (Numo::DFloat)

    (shape: [n_samples, n_features]) The samples to calculate L2-norms.

Returns:

  • (Numo::DFloat)

    The normalized samples.



46
47
48
49
50
# File 'lib/rumale/preprocessing/l2_normalizer.rb', line 46

def fit_transform(x, _y = nil)
  check_sample_array(x)
  fit(x)
  x / @norm_vec.tile(x.shape[1], 1).transpose
end