本文整理汇总了Java中org.dmg.pmml.True类的典型用法代码示例。如果您正苦于以下问题:Java True类的具体用法?Java True怎么用?Java True使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
True类属于org.dmg.pmml包,在下文中一共展示了True类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:18,代码来源:TreeModelUtil.java
示例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;
}
开发者ID:jpmml,项目名称:jpmml-sklearn,代码行数:22,代码来源:TreeModelUtil.java
示例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());
}
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:21,代码来源:ScoreDistributionCleanerTest.java
示例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;
}
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:21,代码来源:PredicateInterner.java
示例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));
}
}
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:26,代码来源:ScoreDistributionInternerTest.java
示例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;
}
开发者ID:jpmml,项目名称:jpmml-lightgbm,代码行数:13,代码来源:Tree.java
示例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);
}
}
}
开发者ID:jpmml,项目名称:jpmml-lightgbm,代码行数:38,代码来源:TreeModelCompactor.java
示例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()));
}
}
开发者ID:oncewang,项目名称:oryx2,代码行数:36,代码来源:RDFUpdate.java
示例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);
}
}
}
开发者ID:oncewang,项目名称:oryx2,代码行数:33,代码来源:RDFUpdateIT.java
示例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);
}
}
}
开发者ID:jpmml,项目名称:jpmml-xgboost,代码行数:33,代码来源:TreeModelCompactor.java
示例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;
}
开发者ID:jpmml,项目名称:jpmml-xgboost,代码行数:14,代码来源:RegTree.java
示例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);
}
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:28,代码来源:MiningModelUtil.java
示例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;
}
开发者ID:jpmml,项目名称:jpmml-r,代码行数:12,代码来源:BinaryTreeConverter.java
示例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;
}
开发者ID:jpmml,项目名称:jpmml-r,代码行数:15,代码来源:RangerConverter.java
示例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;
}
开发者ID:jpmml,项目名称:jpmml-r,代码行数:13,代码来源:RandomForestConverter.java
示例16: encodeTreeModel
import org.dmg.pmml.True; //导入依赖的package包/类
private TreeModel encodeTreeModel(RGenericVector trees, int index, Schema schema){
RIntegerVector nrnodes = (RIntegerVector)trees.getValue("nrnodes");
RIntegerVector ntree = (RIntegerVector)trees.getValue("ntree");
RIntegerVector nodeStatus = (RIntegerVector)trees.getValue("nodeStatus");
RIntegerVector leftDaughter = (RIntegerVector)trees.getValue("lDaughter");
RIntegerVector rightDaughter = (RIntegerVector)trees.getValue("rDaughter");
RIntegerVector splitAtt = (RIntegerVector)trees.getValue("splitAtt");
RDoubleVector splitPoint = (RDoubleVector)trees.getValue("splitPoint");
RIntegerVector nSam = (RIntegerVector)trees.getValue("nSam");
int rows = nrnodes.asScalar();
int columns = ntree.asScalar();
Node root = new Node()
.setPredicate(new True());
encodeNode(
root,
0,
0,
FortranMatrixUtil.getColumn(nodeStatus.getValues(), rows, columns, index),
FortranMatrixUtil.getColumn(nSam.getValues(), rows, columns, index),
FortranMatrixUtil.getColumn(leftDaughter.getValues(), rows, columns, index),
FortranMatrixUtil.getColumn(rightDaughter.getValues(), rows, columns, index),
FortranMatrixUtil.getColumn(splitAtt.getValues(), rows, columns, index),
FortranMatrixUtil.getColumn(splitPoint.getValues(), rows, columns, index),
schema
);
TreeModel treeModel = new TreeModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel()), root)
.setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT);
return treeModel;
}
开发者ID:jpmml,项目名称:jpmml-r,代码行数:35,代码来源:IForestConverter.java
示例17: encodeTreeModel
import org.dmg.pmml.True; //导入依赖的package包/类
private TreeModel encodeTreeModel(MiningFunction miningFunction, RGenericVector tree, RGenericVector c_splits, Schema schema){
Node root = new Node()
.setId("1")
.setPredicate(new True());
encodeNode(root, 0, tree, c_splits, schema);
TreeModel treeModel = new TreeModel(miningFunction, ModelUtil.createMiningSchema(schema.getLabel()), root)
.setSplitCharacteristic(TreeModel.SplitCharacteristic.MULTI_SPLIT);
return treeModel;
}
开发者ID:jpmml,项目名称:jpmml-r,代码行数:13,代码来源:GBMConverter.java
示例18: 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);
}
开发者ID:cheng-li,项目名称:pyramid,代码行数:28,代码来源:MiningModelUtil.java
示例19: 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.NONE)
.setMathContext(MathContext.FLOAT);
return treeModel;
}
开发者ID:cheng-li,项目名称:pyramid,代码行数:14,代码来源:RegressionTree.java
示例20: evaluatePredicate
import org.dmg.pmml.True; //导入依赖的package包/类
static
Boolean evaluatePredicate(Predicate predicate, EvaluationContext context){
if(predicate instanceof SimplePredicate){
return evaluateSimplePredicate((SimplePredicate)predicate, context);
} else
if(predicate instanceof SimpleSetPredicate){
return evaluateSimpleSetPredicate((SimpleSetPredicate)predicate, context);
} else
if(predicate instanceof CompoundPredicate){
return evaluateCompoundPredicate((CompoundPredicate)predicate, context);
} else
if(predicate instanceof True){
return evaluateTrue((True)predicate);
} else
if(predicate instanceof False){
return evaluateFalse((False)predicate);
} // End if
if(predicate instanceof JavaPredicate){
return evaluateJavaPredicate((JavaPredicate)predicate, context);
}
throw new UnsupportedElementException(predicate);
}
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:30,代码来源:PredicateUtil.java
注:本文中的org.dmg.pmml.True类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论