Method: EasyML::Data::Preprocessor::SimpleImputer#transform_categorical
- Defined in:
- lib/easy_ml/data/preprocessor/simple_imputer.rb
#transform_categorical(val) ⇒ Object
175 176 177 178 179 180 181 182 183 |
# File 'lib/easy_ml/data/preprocessor/simple_imputer.rb', line 175 def transform_categorical(val) return "other" if val.nil? values = @statistics.dig(:categorical, :value) || {} min_ct = [:categorical_min] || 25 allowed_values = values.select { |_v, c| c >= min_ct }.keys.map(&:to_s) allowed_values.include?(val.to_s) ? val.to_s : "other" end |