lib/eps/label_encoder.rb in eps-0.3.0 vs lib/eps/label_encoder.rb in eps-0.3.1
- old
+ new
@@ -22,12 +22,16 @@
def transform(y)
y.map do |yi|
if yi.nil?
nil
else
- v = @labels[yi.to_s]
- raise "Unknown label: #{yi}" unless v
- v
+ # use an additional label for unseen values
+ # this is only used during training for the LightGBM eval_set
+ # LightGBM ignores them (only uses seen categories for predictions)
+ # https://github.com/microsoft/LightGBM/issues/1936
+ # the evaluator also ignores them (to be consistent with LightGBM)
+ # but doesn't use this code
+ @labels[yi.to_s] || @labels.size
end
end
end
def inverse_transform(y)