本文整理汇总了Java中org.jpmml.converter.BooleanFeature类的典型用法代码示例。如果您正苦于以下问题:Java BooleanFeature类的具体用法?Java BooleanFeature怎么用?Java BooleanFeature使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BooleanFeature类属于org.jpmml.converter包,在下文中一共展示了BooleanFeature类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPPCells
import org.jpmml.converter.BooleanFeature; //导入依赖的package包/类
static
private double createPPCells(Feature feature, Parameter parameter, PPMatrix ppMatrix, Set<FieldName> covariates, Set<FieldName> factors){
if(feature instanceof BinaryFeature){
BinaryFeature binaryFeature = (BinaryFeature)feature;
return createPPCell(binaryFeature.getValue(), binaryFeature.getName(), parameter, ppMatrix, factors);
} else
if(feature instanceof BooleanFeature){
BooleanFeature booleanFeature = (BooleanFeature)feature;
return createPPCell("true", booleanFeature.getName(), parameter, ppMatrix, factors);
} else
if(feature instanceof ConstantFeature){
ConstantFeature constantFeature = (ConstantFeature)feature;
return (constantFeature.getValue()).doubleValue();
} else
if(feature instanceof InteractionFeature){
InteractionFeature interactionFeature = (InteractionFeature)feature;
double result = 1d;
List<? extends Feature> inputFeatures = interactionFeature.getInputFeatures();
for(Feature inputFeature : inputFeatures){
result *= createPPCells(inputFeature, parameter, ppMatrix, covariates, factors);
}
return result;
} else
if(feature instanceof PowerFeature){
PowerFeature powerFeature = (PowerFeature)feature;
return createPPCell(String.valueOf(powerFeature.getPower()), powerFeature.getName(), parameter, ppMatrix, covariates);
} else
{
ContinuousFeature continuousFeature = feature.toContinuousFeature();
return createPPCell("1", continuousFeature.getName(), parameter, ppMatrix, covariates);
}
}
示例2: encodeNode
import org.jpmml.converter.BooleanFeature; //导入依赖的package包/类
private <P extends Number> void encodeNode(Node node, int i, ScoreEncoder<P> scoreEncoder, List<? extends Number> leftDaughter, List<? extends Number> rightDaughter, List<? extends Number> bestvar, List<Double> xbestsplit, List<P> nodepred, Schema schema){
Predicate leftPredicate;
Predicate rightPredicate;
int var = ValueUtil.asInt(bestvar.get(i));
if(var != 0){
Feature feature = schema.getFeature(var - 1);
Double split = xbestsplit.get(i);
if(feature instanceof BooleanFeature){
BooleanFeature booleanFeature = (BooleanFeature)feature;
if(split != 0.5d){
throw new IllegalArgumentException();
}
leftPredicate = createSimplePredicate(booleanFeature, SimplePredicate.Operator.EQUAL, booleanFeature.getValue(0));
rightPredicate = createSimplePredicate(booleanFeature, SimplePredicate.Operator.EQUAL, booleanFeature.getValue(1));
} else
if(feature instanceof CategoricalFeature){
CategoricalFeature categoricalFeature = (CategoricalFeature)feature;
List<String> values = categoricalFeature.getValues();
leftPredicate = createSimpleSetPredicate(categoricalFeature, selectValues(values, split, true));
rightPredicate = createSimpleSetPredicate(categoricalFeature, selectValues(values, split, false));
} else
{
ContinuousFeature continuousFeature = feature.toContinuousFeature();
String value = ValueUtil.formatValue(split);
leftPredicate = createSimplePredicate(continuousFeature, SimplePredicate.Operator.LESS_OR_EQUAL, value);
rightPredicate = createSimplePredicate(continuousFeature, SimplePredicate.Operator.GREATER_THAN, value);
}
} else
{
P prediction = nodepred.get(i);
node.setScore(scoreEncoder.encode(prediction));
return;
}
int left = ValueUtil.asInt(leftDaughter.get(i));
if(left != 0){
Node leftChild = new Node()
.setId(String.valueOf(left))
.setPredicate(leftPredicate);
encodeNode(leftChild, left - 1, scoreEncoder, leftDaughter, rightDaughter, bestvar, xbestsplit, nodepred, schema);
node.addNodes(leftChild);
}
int right = ValueUtil.asInt(rightDaughter.get(i));
if(right != 0){
Node rightChild = new Node()
.setId(String.valueOf(right))
.setPredicate(rightPredicate);
encodeNode(rightChild, right - 1, scoreEncoder, leftDaughter, rightDaughter, bestvar, xbestsplit, nodepred, schema);
node.addNodes(rightChild);
}
}