Skip to content

Commit

Permalink
Updated JPMML-Converter dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
vruusmann committed Feb 2, 2021
1 parent 11bda29 commit bf59c07
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@
<dependency>
<groupId>org.jpmml</groupId>
<artifactId>jpmml-converter</artifactId>
<version>1.4.4</version>
<version>1.4.6</version>
</dependency>

<dependency>
<groupId>org.jpmml</groupId>
<artifactId>jpmml-xgboost</artifactId>
<version>1.4.4</version>
<version>1.4.5</version>
</dependency>

<dependency>
Expand All @@ -87,7 +87,7 @@
<dependency>
<groupId>org.jpmml</groupId>
<artifactId>pmml-evaluator-testing</artifactId>
<version>1.5.5</version>
<version>1.5.11</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/org/jpmml/h2o/XGBoostMojoModelConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,19 @@
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;
import java.util.function.Function;
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;
Expand All @@ -61,13 +60,14 @@ public Stream<Feature> apply(Feature feature){
if(feature instanceof CategoricalFeature){
CategoricalFeature categoricalFeature = (CategoricalFeature)feature;

List<Object> 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<Feature> binaryFeaturesStream = values.stream()
.map(value -> new BinaryFeature(encoder, categoricalFeature, value));

Stream<Feature> missingValueFeatureStream = Stream.of(new MissingValueFeature(encoder, categoricalFeature));

return Stream.concat(binaryFeaturesStream, missingValueFeatureStream);
}

return Stream.of(feature);
Expand Down

0 comments on commit bf59c07

Please sign in to comment.