当前位置: 首页>>代码示例>>Java>>正文


Java SimplePredicate类代码示例

本文整理汇总了Java中org.dmg.pmml.SimplePredicate的典型用法代码示例。如果您正苦于以下问题:Java SimplePredicate类的具体用法?Java SimplePredicate怎么用?Java SimplePredicate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SimplePredicate类属于org.dmg.pmml包,在下文中一共展示了SimplePredicate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: evaluateSurrogateCompoundPredicate

import org.dmg.pmml.SimplePredicate; //导入依赖的package包/类
@Test
public void evaluateSurrogateCompoundPredicate(){
	FieldName temperature = FieldName.create("temperature");
	FieldName humidity = FieldName.create("humidity");

	CompoundPredicate temperaturePredicate = new CompoundPredicate(CompoundPredicate.BooleanOperator.AND)
		.addPredicates(
			new SimplePredicate(temperature, SimplePredicate.Operator.LESS_THAN).setValue("90"),
			new SimplePredicate(temperature, SimplePredicate.Operator.GREATER_THAN).setValue("50")
		);

	SimplePredicate humidityPredicate = new SimplePredicate(humidity, SimplePredicate.Operator.GREATER_OR_EQUAL).setValue("80");

	CompoundPredicate compoundPredicate = new CompoundPredicate(CompoundPredicate.BooleanOperator.SURROGATE)
		.addPredicates(temperaturePredicate, humidityPredicate);

	assertEquals(Boolean.TRUE, evaluate(compoundPredicate, temperature, 70, humidity, null));
	assertEquals(Boolean.FALSE, evaluate(compoundPredicate, temperature, 40, humidity, null));
	assertEquals(Boolean.FALSE, evaluate(compoundPredicate,  temperature, 100, humidity, null));

	assertEquals(Boolean.TRUE, evaluate(compoundPredicate, temperature, null, humidity, 90));
	assertEquals(Boolean.FALSE, evaluate(compoundPredicate, temperature, null, humidity, 70));

	assertEquals(null, evaluate(compoundPredicate, temperature, null, humidity, null));
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:26,代码来源:PredicateUtilTest.java

示例2: transform

import org.dmg.pmml.SimplePredicate; //导入依赖的package包/类
private Predicate transform(SimpleSetPredicate simpleSetPredicate){
	Array array = simpleSetPredicate.getArray();

	List<String> content = ArrayUtil.getContent(array);
	if(content.size() != 1){
		return simpleSetPredicate;
	}

	String value = content.get(0);

	SimpleSetPredicate.BooleanOperator booleanOperator = simpleSetPredicate.getBooleanOperator();
	switch(booleanOperator){
		case IS_IN:
			return createSimplePredicate(simpleSetPredicate.getField(), SimplePredicate.Operator.EQUAL, value);
		case IS_NOT_IN:
			return createSimplePredicate(simpleSetPredicate.getField(), SimplePredicate.Operator.NOT_EQUAL, value);
		default:
			break;
	}

	return simpleSetPredicate;
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:23,代码来源:PredicateTransformer.java

示例3: intern

import org.dmg.pmml.SimplePredicate; //导入依赖的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

示例4: buildPredicate

import org.dmg.pmml.SimplePredicate; //导入依赖的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

示例5: encodePredicate

import org.dmg.pmml.SimplePredicate; //导入依赖的package包/类
static
private Predicate encodePredicate(Feature feature, Node node, boolean left){
	FieldName name = feature.getName();
	SimplePredicate.Operator operator;
	String value;

	if(feature instanceof BinaryFeature){
		BinaryFeature binaryFeature = (BinaryFeature)feature;

		operator = (left ? SimplePredicate.Operator.NOT_EQUAL : SimplePredicate.Operator.EQUAL);
		value = binaryFeature.getValue();
	} else

	{
		ContinuousFeature continuousFeature = feature.toContinuousFeature();

		Number splitValue = Float.intBitsToFloat(node.split_cond());

		DataType dataType = continuousFeature.getDataType();
		switch(dataType){
			case INTEGER:
				splitValue = (int)(splitValue.floatValue() + 1f);
				break;
			case FLOAT:
				break;
			default:
				throw new IllegalArgumentException();
		}

		operator = (left ? SimplePredicate.Operator.LESS_THAN : SimplePredicate.Operator.GREATER_OR_EQUAL);
		value = ValueUtil.formatValue(splitValue);
	}

	SimplePredicate simplePredicate = new SimplePredicate(name, operator)
		.setValue(value);

	return simplePredicate;
}
 
开发者ID:jpmml,项目名称:jpmml-xgboost,代码行数:39,代码来源:RegTree.java

示例6: getFieldNamesFromPredicate

import org.dmg.pmml.SimplePredicate; //导入依赖的package包/类
protected static void getFieldNamesFromPredicate(Set<String> fieldNames, Predicate predicate) {
    if (predicate instanceof CompoundPredicate) {
        List<Predicate> predicates = ((CompoundPredicate) predicate).getPredicates();
        for (Predicate predicate1 : predicates) {
            getFieldNamesFromPredicate(fieldNames, predicate1);
        }
    } else {
        if (predicate instanceof SimplePredicate) {
            fieldNames.add(((SimplePredicate) predicate).getField().getValue());
        } else if (predicate instanceof SimpleSetPredicate) {
            fieldNames.add(((SimpleSetPredicate) predicate).getField().getValue());
        }
    }
}
 
开发者ID:brwe,项目名称:es-token-plugin,代码行数:15,代码来源:TreeModelFactory.java

示例7: createSimpleSetPredicate

import org.dmg.pmml.SimplePredicate; //导入依赖的package包/类
public Predicate createSimpleSetPredicate(Feature feature, List<String> values){

		if(values.size() == 1){
			String value = values.get(0);

			return createSimplePredicate(feature, SimplePredicate.Operator.EQUAL, value);
		}

		Predicate predicate = new InternableSimpleSetPredicate()
			.setField(feature.getName())
			.setBooleanOperator(SimpleSetPredicate.BooleanOperator.IS_IN)
			.setArray(createArray(feature.getDataType(), values));

		return intern(predicate);
	}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:16,代码来源:PredicateManager.java

示例8: createSimplePredicate

import org.dmg.pmml.SimplePredicate; //导入依赖的package包/类
public Predicate createSimplePredicate(Feature feature, SimplePredicate.Operator operator, String value){
	Predicate predicate = new InternableSimplePredicate()
		.setField(feature.getName())
		.setOperator(operator)
		.setValue(value);

	return intern(predicate);
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:9,代码来源:PredicateManager.java

示例9: getChildren

import org.dmg.pmml.SimplePredicate; //导入依赖的package包/类
static
private Iterator<Node> getChildren(Node node){
	Predicate predicate = node.getPredicate();

	if(!(predicate instanceof SimplePredicate)){
		return null;
	}

	SimplePredicate simplePredicate = (SimplePredicate)predicate;

	FieldName name = simplePredicate.getField();
	SimplePredicate.Operator operator = simplePredicate.getOperator();

	if(!(SimplePredicate.Operator.LESS_OR_EQUAL).equals(operator)){
		return null;
	} // End if

	if(node.hasNodes()){
		List<Node> children = node.getNodes();

		int endPos = 0;

		for(Node child : children){

			if(!checkPredicate(child, name, operator)){
				break;
			}

			endPos++;
		}

		if(endPos > 0){
			return (children.subList(0, endPos)).iterator();
		}

		return null;
	}

	return null;
}
 
开发者ID:jpmml,项目名称:jpmml-sklearn,代码行数:41,代码来源:TreeModelFlattener.java

示例10: checkPredicate

import org.dmg.pmml.SimplePredicate; //导入依赖的package包/类
static
private boolean checkPredicate(Node node, FieldName name, SimplePredicate.Operator operator){
	Predicate predicate = node.getPredicate();

	if(predicate instanceof SimplePredicate){
		SimplePredicate simplePredicate = (SimplePredicate)predicate;

		return (simplePredicate.getField()).equals(name) && (simplePredicate.getOperator()).equals(operator);
	}

	return false;
}
 
开发者ID:jpmml,项目名称:jpmml-sklearn,代码行数:13,代码来源:TreeModelFlattener.java

示例11: encodePredicate

import org.dmg.pmml.SimplePredicate; //导入依赖的package包/类
static
private Predicate encodePredicate(Feature feature, Node node, boolean left){
    FieldName name = feature.getName();
    SimplePredicate.Operator operator;
    String value;

    if(feature instanceof BinaryFeature){
        BinaryFeature binaryFeature = (BinaryFeature)feature;

        operator = (left ? SimplePredicate.Operator.NOT_EQUAL : SimplePredicate.Operator.EQUAL);
        value = binaryFeature.getValue();
    } else

    {
        ContinuousFeature continuousFeature = feature.toContinuousFeature();

        Number splitValue = node.getThreshold();

        DataType dataType = continuousFeature.getDataType();
        switch(dataType){
            case INTEGER:
                splitValue = (int)(splitValue.floatValue() + 1f);
                break;
            case FLOAT:
                break;
            default:
                throw new IllegalArgumentException();
        }

        operator = (left ? SimplePredicate.Operator.LESS_OR_EQUAL : SimplePredicate.Operator.GREATER_THAN);
        value = ValueUtil.formatValue(splitValue);
    }

    SimplePredicate simplePredicate = new SimplePredicate(name, operator)
            .setValue(value);

    return simplePredicate;
}
 
开发者ID:cheng-li,项目名称:pyramid,代码行数:39,代码来源:RegressionTree.java

示例12: evaluatePredicate

import org.dmg.pmml.SimplePredicate; //导入依赖的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

示例13: createSimplePredicate

import org.dmg.pmml.SimplePredicate; //导入依赖的package包/类
static
private SimplePredicate createSimplePredicate(FieldName field, SimplePredicate.Operator operator, String value){
	SimplePredicate simplePredicate = new SimplePredicate(field, operator)
		.setValue(value);

	return simplePredicate;
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:8,代码来源:PredicateTransformer.java

示例14: internSimplePredicate

import org.dmg.pmml.SimplePredicate; //导入依赖的package包/类
@Test
public void internSimplePredicate(){
	FieldName name = FieldName.create("x");

	Predicate left = new SimplePredicate(name, SimplePredicate.Operator.EQUAL)
		.setValue("1");

	Predicate right = new SimplePredicate(name, SimplePredicate.Operator.EQUAL)
		.setValue("1");

	checkTree(left, right);
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:13,代码来源:PredicateInternerTest.java

示例15: optimizeSimplePredicate

import org.dmg.pmml.SimplePredicate; //导入依赖的package包/类
@Test
public void optimizeSimplePredicate(){
	Predicate predicate = new SimplePredicate(FieldName.create("x"), SimplePredicate.Operator.EQUAL)
		.setValue("1");

	checkTree(predicate, HasParsedValue.class);
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:8,代码来源:PredicateOptimizerTest.java


注:本文中的org.dmg.pmml.SimplePredicate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。