All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dmg.pmml.tree.SimplifyingNodeTransformer Maven / Gradle / Ivy

There is a newer version: 1.6.6
Show newest version
/*
 * Copyright (c) 2019 Villu Ruusmann
 */
package org.dmg.pmml.tree;

/**
 * 

* A {@link Node} element converter between {@link ComplexNode} and {@link SimpleNode}. *

* *

* All conversions are information-preserving. *

*/ public class SimplifyingNodeTransformer implements NodeTransformer { /** *

* Attempts to transform {@link ComplexNode} to the most memory-efficient {@link SimpleNode}. *

*/ @Override public Node fromComplexNode(ComplexNode complexNode){ return simplify(complexNode); } public Node simplify(Node node){ if(node.hasExtensions() || (node.getPartition() != null) || (node.getEmbeddedModel() != null)){ return node; } // End if if(node.hasScoreDistributions()){ return new ClassifierNode(node); } Number recordCount = node.getRecordCount(); if(node.hasNodes()){ if(recordCount != null){ return new CountingBranchNode(node); } else { return new BranchNode(node); } } else { if(recordCount != null){ return new CountingLeafNode(node); } else { return new LeafNode(node); } } } public static final SimplifyingNodeTransformer INSTANCE = new SimplifyingNodeTransformer(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy