From bf59c07f20fbe7299b84708e1c93c94f334daaa7 Mon Sep 17 00:00:00 2001 From: Villu Ruusmann Date: Tue, 2 Feb 2021 09:33:45 +0200 Subject: [PATCH] Updated JPMML-Converter dependency --- pom.xml | 6 +++--- .../org/jpmml/h2o/XGBoostMojoModelConverter.java | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index b373866..369a972 100644 --- a/pom.xml +++ b/pom.xml @@ -68,13 +68,13 @@ org.jpmml jpmml-converter - 1.4.4 + 1.4.6 org.jpmml jpmml-xgboost - 1.4.4 + 1.4.5 @@ -87,7 +87,7 @@ org.jpmml pmml-evaluator-testing - 1.5.5 + 1.5.11 test diff --git a/src/main/java/org/jpmml/h2o/XGBoostMojoModelConverter.java b/src/main/java/org/jpmml/h2o/XGBoostMojoModelConverter.java index 7b255a3..87ec98d 100644 --- a/src/main/java/org/jpmml/h2o/XGBoostMojoModelConverter.java +++ b/src/main/java/org/jpmml/h2o/XGBoostMojoModelConverter.java @@ -21,7 +21,6 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -29,12 +28,12 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.dmg.pmml.MissingValueTreatmentMethod; import org.dmg.pmml.mining.MiningModel; import org.jpmml.converter.BinaryFeature; import org.jpmml.converter.CategoricalFeature; import org.jpmml.converter.Feature; import org.jpmml.converter.Label; +import org.jpmml.converter.MissingValueFeature; import org.jpmml.converter.PMMLEncoder; import org.jpmml.converter.Schema; import org.jpmml.xgboost.HasXGBoostOptions; @@ -61,13 +60,14 @@ public Stream apply(Feature feature){ if(feature instanceof CategoricalFeature){ CategoricalFeature categoricalFeature = (CategoricalFeature)feature; - List values = new ArrayList<>(categoricalFeature.getValues()); - values.add("missing(NA)"); + List values = categoricalFeature.getValues(); - ImputerUtil.encodeFeature(categoricalFeature, "missing(NA)", MissingValueTreatmentMethod.AS_VALUE); - - return values.stream() + Stream binaryFeaturesStream = values.stream() .map(value -> new BinaryFeature(encoder, categoricalFeature, value)); + + Stream missingValueFeatureStream = Stream.of(new MissingValueFeature(encoder, categoricalFeature)); + + return Stream.concat(binaryFeaturesStream, missingValueFeatureStream); } return Stream.of(feature);