本文整理汇总了Java中org.dmg.pmml.True类的典型用法代码示例。如果您正苦于以下问题:Java True类的具体用法?Java True怎么用?Java True使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
True类属于org.dmg.pmml包,在下文中一共展示了True类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeTreeModel
import org.dmg.pmml.True; //导入依赖的package包/类
static
public TreeModel encodeTreeModel(org.apache.spark.ml.tree.Node node, PredicateManager predicateManager, MiningFunction miningFunction, Schema schema){
Node root = encodeNode(node, predicateManager, Collections.<FieldName, Set<String>>emptyMap(), miningFunction, schema)
.setPredicate(new True());
TreeModel treeModel = new TreeModel(miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root)
.setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT);
String compact = TreeModelOptions.COMPACT;
if(compact != null && Boolean.valueOf(compact)){
Visitor visitor = new TreeModelCompactor();
visitor.applyTo(treeModel);
}
return treeModel;
}
示例2: encodeTreeModel
import org.dmg.pmml.True; //导入依赖的package包/类
static
public <E extends Estimator & HasTree> TreeModel encodeTreeModel(E estimator, PredicateManager predicateManager, MiningFunction miningFunction, Schema schema){
Tree tree = estimator.getTree();
int[] leftChildren = tree.getChildrenLeft();
int[] rightChildren = tree.getChildrenRight();
int[] features = tree.getFeature();
double[] thresholds = tree.getThreshold();
double[] values = tree.getValues();
Node root = new Node()
.setId("1")
.setPredicate(new True());
encodeNode(root, predicateManager, 0, leftChildren, rightChildren, features, thresholds, values, miningFunction, schema);
TreeModel treeModel = new TreeModel(miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root)
.setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT);
return treeModel;
}
示例3: clean
import org.dmg.pmml.True; //导入依赖的package包/类
@Test
public void clean(){
Node node = new Node()
.setPredicate(new True())
.setScore("1")
.addScoreDistributions(new ScoreDistribution("0", 0), new ScoreDistribution("1", 100));
TreeModel treeModel = new TreeModel(MiningFunction.CLASSIFICATION, new MiningSchema(), node);
ScoreDistributionCleaner cleaner = new ScoreDistributionCleaner();
cleaner.applyTo(treeModel);
assertTrue(node.hasScoreDistributions());
treeModel.setMiningFunction(MiningFunction.REGRESSION);
cleaner.applyTo(treeModel);
assertFalse(node.hasScoreDistributions());
}
示例4: intern
import org.dmg.pmml.True; //导入依赖的package包/类
public Predicate intern(Predicate predicate){
if(predicate instanceof SimplePredicate){
return intern((SimplePredicate)predicate);
} else
if(predicate instanceof SimpleSetPredicate){
return intern((SimpleSetPredicate)predicate);
} else
if(predicate instanceof True){
return intern((True)predicate);
} else
if(predicate instanceof False){
return intern((False)predicate);
}
return predicate;
}
示例5: intern
import org.dmg.pmml.True; //导入依赖的package包/类
@Test
public void intern(){
ScoreDistribution left = new ScoreDistribution("event", 0.33d);
ScoreDistribution right = new ScoreDistribution("event", 0.33d);
Node leftChild = createNode(left);
Node rightChild = createNode(right);
Node root = new Node()
.setPredicate(new True())
.addNodes(leftChild, rightChild);
TreeModel treeModel = new TreeModel()
.setNode(root);
for(int i = 0; i < 2; i++){
assertNotSame((leftChild.getScoreDistributions()).get(i), (rightChild.getScoreDistributions()).get(i));
}
intern(treeModel);
for(int i = 0; i < 2; i++){
assertSame((leftChild.getScoreDistributions()).get(i), (rightChild.getScoreDistributions()).get(i));
}
}
示例6: encodeTreeModel
import org.dmg.pmml.True; //导入依赖的package包/类
public TreeModel encodeTreeModel(PredicateManager predicateManager, Schema schema){
Node root = new Node()
.setPredicate(new True());
encodeNode(root, predicateManager, Collections.<FieldName, Set<String>>emptyMap(), 0, schema);
TreeModel treeModel = new TreeModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel()), root)
.setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT)
.setMissingValueStrategy(TreeModel.MissingValueStrategy.DEFAULT_CHILD);
return treeModel;
}
示例7: handleNodePop
import org.dmg.pmml.True; //导入依赖的package包/类
private void handleNodePop(Node node){
Double recordCount = node.getRecordCount();
String score = node.getScore();
Predicate predicate = node.getPredicate();
if(recordCount != null){
node.setRecordCount(null);
} // End if
if(predicate instanceof True){
Node parentNode = getParentNode();
if(parentNode == null){
return;
}
String parentScore = parentNode.getScore();
if(parentScore != null){
throw new IllegalArgumentException();
}
parentNode.setScore(score);
List<Node> parentChildren = parentNode.getNodes();
boolean success = parentChildren.remove(node);
if(!success){
throw new IllegalArgumentException();
} // End if
if(node.hasNodes()){
List<Node> children = node.getNodes();
parentChildren.addAll(children);
}
}
}
示例8: buildPredicate
import org.dmg.pmml.True; //导入依赖的package包/类
private Predicate buildPredicate(Split split,
CategoricalValueEncodings categoricalValueEncodings) {
if (split == null) {
// Left child always applies, but is evaluated second
return new True();
}
int featureIndex = inputSchema.predictorToFeatureIndex(split.feature());
FieldName fieldName = FieldName.create(inputSchema.getFeatureNames().get(featureIndex));
if (split.featureType().equals(FeatureType.Categorical())) {
// Note that categories in MLlib model select the *left* child but the
// convention here will be that the predicate selects the *right* child
// So the predicate will evaluate "not in" this set
// More ugly casting
@SuppressWarnings("unchecked")
List<Double> javaCategories = (List<Double>) (List<?>)
JavaConversions.seqAsJavaList(split.categories());
Set<Integer> negativeEncodings = javaCategories.stream().map(Double::intValue).collect(Collectors.toSet());
Map<Integer,String> encodingToValue =
categoricalValueEncodings.getEncodingValueMap(featureIndex);
List<String> negativeValues = negativeEncodings.stream().map(encodingToValue::get).collect(Collectors.toList());
String joinedValues = TextUtils.joinPMMLDelimited(negativeValues);
return new SimpleSetPredicate(fieldName,
SimpleSetPredicate.BooleanOperator.IS_NOT_IN,
new Array(Array.Type.STRING, joinedValues));
} else {
// For MLlib, left means <= threshold, so right means >
return new SimplePredicate(fieldName, SimplePredicate.Operator.GREATER_THAN)
.setValue(Double.toString(split.threshold()));
}
}
示例9: checkNode
import org.dmg.pmml.True; //导入依赖的package包/类
private static void checkNode(Node node) {
assertNotNull(node.getId());
List<ScoreDistribution> scoreDists = node.getScoreDistributions();
int numDists = scoreDists.size();
if (numDists == 0) {
// Non-leaf
List<Node> children = node.getNodes();
assertEquals(2, children.size());
Node rightChild = children.get(0);
Node leftChild = children.get(1);
assertInstanceOf(leftChild.getPredicate(), True.class);
assertEquals(node.getRecordCount().doubleValue(),
leftChild.getRecordCount() + rightChild.getRecordCount());
assertEquals(node.getId() + "+", rightChild.getId());
assertEquals(node.getId() + "-", leftChild.getId());
checkNode(rightChild);
checkNode(leftChild);
} else {
// Leaf
assertRange(numDists, 1, 2);
ScoreDistribution first = scoreDists.get(0);
if (numDists == 1) {
assertEquals(1.0, first.getConfidence().doubleValue());
} else {
assertGreater(first.getConfidence(), 0.0);
assertLess(first.getConfidence(), 1.0);
ScoreDistribution second = scoreDists.get(1);
assertGreater(second.getConfidence(), 0.0);
assertLess(second.getConfidence(), 1.0);
}
}
}
示例10: handleNodePop
import org.dmg.pmml.True; //导入依赖的package包/类
private void handleNodePop(Node node){
String score = node.getScore();
Predicate predicate = node.getPredicate();
if(predicate instanceof True){
Node parentNode = getParentNode();
if(parentNode == null){
return;
}
String parentScore = parentNode.getScore();
if(parentScore != null){
throw new IllegalArgumentException();
}
parentNode.setScore(score);
List<Node> parentChildren = parentNode.getNodes();
boolean success = parentChildren.remove(node);
if(!success){
throw new IllegalArgumentException();
} // End if
if(node.hasNodes()){
List<Node> children = node.getNodes();
parentChildren.addAll(children);
}
}
}
示例11: encodeTreeModel
import org.dmg.pmml.True; //导入依赖的package包/类
public TreeModel encodeTreeModel(Schema schema){
org.dmg.pmml.tree.Node root = new org.dmg.pmml.tree.Node()
.setPredicate(new True());
encodeNode(root, 0, schema);
TreeModel treeModel = new TreeModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel()), root)
.setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT)
.setMissingValueStrategy(TreeModel.MissingValueStrategy.DEFAULT_CHILD)
.setMathContext(MathContext.FLOAT);
return treeModel;
}
示例12: createSegmentation
import org.dmg.pmml.True; //导入依赖的package包/类
static
public Segmentation createSegmentation(Segmentation.MultipleModelMethod multipleModelMethod, List<? extends Model> models, List<? extends Number> weights){
if((weights != null) && (models.size() != weights.size())){
throw new IllegalArgumentException();
}
List<Segment> segments = new ArrayList<>();
for(int i = 0; i < models.size(); i++){
Model model = models.get(i);
Number weight = (weights != null ? weights.get(i) : null);
Segment segment = new Segment()
.setId(String.valueOf(i + 1))
.setPredicate(new True())
.setModel(model);
if(weight != null && !ValueUtil.isOne(weight)){
segment.setWeight(ValueUtil.asDouble(weight));
}
segments.add(segment);
}
return new Segmentation(multipleModelMethod, segments);
}
示例13: encodeTreeModel
import org.dmg.pmml.True; //导入依赖的package包/类
private TreeModel encodeTreeModel(RGenericVector tree, Schema schema){
Node root = new Node()
.setPredicate(new True());
encodeNode(root, tree, schema);
TreeModel treeModel = new TreeModel(this.miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root)
.setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT);
return treeModel;
}
示例14: encodeTreeModel
import org.dmg.pmml.True; //导入依赖的package包/类
private TreeModel encodeTreeModel(MiningFunction miningFunction, ScoreEncoder scoreEncoder, RGenericVector childNodeIDs, RNumberVector<?> splitVarIDs, RNumberVector<?> splitValues, RGenericVector terminalClassCounts, Schema schema){
RNumberVector<?> leftChildIDs = (RNumberVector<?>)childNodeIDs.getValue(0);
RNumberVector<?> rightChildIDs = (RNumberVector<?>)childNodeIDs.getValue(1);
Node root = new Node()
.setPredicate(new True());
encodeNode(root, 0, scoreEncoder, leftChildIDs, rightChildIDs, splitVarIDs, splitValues, terminalClassCounts, schema);
TreeModel treeModel = new TreeModel(miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root)
.setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT);
return treeModel;
}
示例15: encodeTreeModel
import org.dmg.pmml.True; //导入依赖的package包/类
private <P extends Number> TreeModel encodeTreeModel(MiningFunction miningFunction, ScoreEncoder<P> scoreEncoder, List<? extends Number> leftDaughter, List<? extends Number> rightDaughter, List<P> nodepred, List<? extends Number> bestvar, List<Double> xbestsplit, Schema schema){
Node root = new Node()
.setId("1")
.setPredicate(new True());
encodeNode(root, 0, scoreEncoder, leftDaughter, rightDaughter, bestvar, xbestsplit, nodepred, schema);
TreeModel treeModel = new TreeModel(miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root)
.setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT);
return treeModel;
}