Method: Rumale::Preprocessing::OneHotEncoder#transform
- Defined in:
- lib/rumale/preprocessing/one_hot_encoder.rb
#transform(x) ⇒ Numo::DFloat
Encode samples into one-hot-vectors.
77 78 79 80 81 82 |
# File 'lib/rumale/preprocessing/one_hot_encoder.rb', line 77 def transform(x) x = Numo::Int32.cast(x) unless x.is_a?(Numo::Int32) raise ArgumentError, 'Expected the input samples only consists of non-negative integer values.' if x.lt(0).any? codes = encode(x, @feature_indices) codes[true, @active_features].dup end |