Skip to content

Commit

Permalink
Refactored the encoding of PMML elements. Fixes #103
Browse files Browse the repository at this point in the history
  • Loading branch information
vruusmann committed Jan 25, 2021
1 parent 07590b7 commit 33e650b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main/java/org/jpmml/sparkml/PMMLBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,19 +153,19 @@ public PMML build(){

org.dmg.pmml.Model model;

if(models.size() == 1){
model = Iterables.getOnlyElement(models);
if(models.size() == 0){
model = null;
} else

if(models.size() > 1){
model = MiningModelUtil.createModelChain(models);
if(models.size() == 1){
model = Iterables.getOnlyElement(models);
} else

{
throw new IllegalArgumentException("Expected a pipeline with one or more models, got a pipeline with zero models");
model = MiningModelUtil.createModelChain(models);
} // End if

if(postProcessorNames.size() > 0){
if((model != null) && (postProcessorNames.size() > 0)){
org.dmg.pmml.Model finalModel = MiningModelUtil.getFinalModel(model);

Output output = ModelUtil.ensureOutput(finalModel);
Expand All @@ -185,7 +185,7 @@ public PMML build(){

PMML pmml = encoder.encodePMML(model);

if((predictionColumns.size() > 0 || probabilityColumns.size() > 0) && (verification != null)){
if((model != null) && (predictionColumns.size() > 0 || probabilityColumns.size() > 0) && (verification != null)){
Dataset<Row> dataset = verification.getDataset();
Dataset<Row> transformedDataset = verification.getTransformedDataset();
Double precision = verification.getPrecision();
Expand Down

0 comments on commit 33e650b

Please sign in to comment.