本文整理汇总了Java中org.jpmml.evaluator.ModelEvaluator.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Java ModelEvaluator.evaluate方法的具体用法?Java ModelEvaluator.evaluate怎么用?Java ModelEvaluator.evaluate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jpmml.evaluator.ModelEvaluator
的用法示例。
在下文中一共展示了ModelEvaluator.evaluate方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluate
import org.jpmml.evaluator.ModelEvaluator; //导入方法依赖的package包/类
@Test
public void evaluate() throws Exception {
ModelEvaluator<?> evaluator = createModelEvaluator();
Map<FieldName, ?> arguments = createArguments("Integer", null, "Double", 76.45d);
Map<FieldName, ?> result = evaluator.evaluate(arguments);
NodeScoreDistribution<?> targetValue = (NodeScoreDistribution<?>)result.get(evaluator.getTargetFieldName());
assertEquals("Result1", targetValue.getResult());
assertEquals("10", targetValue.getEntityId());
assertEquals(21d / 42d, targetValue.getProbability("Result1"), 1e-8);
assertEquals(15d / 42d, targetValue.getProbability("Result2"), 1e-8);
assertEquals(6d / 42d, targetValue.getProbability("Result3"), 1e-8);
}
示例2: evaluate
import org.jpmml.evaluator.ModelEvaluator; //导入方法依赖的package包/类
@Test
public void evaluate() throws Exception {
ModelEvaluator<?> evaluator = createModelEvaluator();
Map<FieldName, ?> arguments = createArguments("item", Arrays.asList("Cracker", "Coke"));
Map<FieldName, ?> result = evaluator.evaluate(arguments);
assertEquals("1", getOutput(result, "entityId"));
checkValue(Arrays.asList("Cracker"), result, "antecedent");
checkValue(Arrays.asList("Water"), result, "consequent");
checkValue("{Cracker}->{Water}", result, "rule");
checkValue("1", result, "ruleId");
checkValue(1d, result, "support");
checkValue(1d, result, "confidence");
checkValue(1d, result, "lift");
}
示例3: evaluate
import org.jpmml.evaluator.ModelEvaluator; //导入方法依赖的package包/类
@Test
public void evaluate() throws Exception {
ModelEvaluator<?> evaluator = createModelEvaluator();
Map<FieldName, ?> arguments = createArguments("input", 4d);
Map<FieldName, ?> result = evaluator.evaluate(arguments);
assertEquals(8d, getTarget(result, "result"));
assertEquals(8d, getOutput(result, "RawResult"));
assertEquals(8, getOutput(result, "RawIntegerResult"));
assertEquals(35d, getOutput(result, "FinalResult"));
assertEquals(35, getOutput(result, "FinalIntegerResult"));
assertEquals("waive", getOutput(result, "BusinessDecision"));
}
示例4: evaluate
import org.jpmml.evaluator.ModelEvaluator; //导入方法依赖的package包/类
@Test
public void evaluate() throws Exception {
ModelEvaluator<?> evaluator = createModelEvaluator();
Map<FieldName, ?> arguments = createArguments("gender", "f", "educ", 19d, "jobcat", "3", "salbegin", 45000d);
Map<FieldName, ?> result = evaluator.evaluate(arguments);
FieldName lowField = FieldName.create("Probability_Low");
FieldName highField = FieldName.create("Probability_High");
// Expected values have been calculated by hand
assertEquals(0.81956470d, (Double)getOutput(result, lowField), 1e-8);
assertEquals(0.18043530d, (Double)getOutput(result, highField), 1e-8);
}
示例5: evaluate
import org.jpmml.evaluator.ModelEvaluator; //导入方法依赖的package包/类
@Test
public void evaluate() throws Exception {
ModelEvaluator<?> evaluator = createModelEvaluator();
Map<FieldName, ?> arguments = createArguments("marital status", "d", "dependents", 0);
Map<FieldName, ?> result = evaluator.evaluate(arguments);
AffinityDistribution<?> targetValue = (AffinityDistribution<?>)result.get(evaluator.getTargetFieldName());
try {
targetValue.getResult();
fail();
} catch(EvaluationException ee){
// Ignored
}
assertNotNull(targetValue.getPredictionReport());
Collection<String> categories = targetValue.getCategoryValues();
assertEquals(5, categories.size());
for(String category : categories){
assertNotNull(targetValue.getAffinity(category));
assertNotNull(targetValue.getAffinityReport(category));
}
assertEquals(Arrays.asList("3", "1", "4"), (targetValue.getEntityIdRanking()).subList(0, 3));
assertEquals("3", getOutput(result, "neighbor1"));
assertEquals("1", getOutput(result, "neighbor2"));
assertEquals("4", getOutput(result, "neighbor3"));
}
示例6: evaluate
import org.jpmml.evaluator.ModelEvaluator; //导入方法依赖的package包/类
@Test
public void evaluate() throws Exception {
ModelEvaluator<?> evaluator = createModelEvaluator();
Map<FieldName, ?> arguments = createArguments("input", 1d);
Map<FieldName, ?> result = evaluator.evaluate(arguments);
ClusterAffinityDistribution<?> affinityDistribution = (ClusterAffinityDistribution<?>)result.get(evaluator.getTargetFieldName());
assertEquals("2", affinityDistribution.getResult());
checkValue("2", 1d, result, "first");
checkValue("3", 4d, result, "second");
checkValue("1", 16d, result, "third");
}
示例7: evaluate
import org.jpmml.evaluator.ModelEvaluator; //导入方法依赖的package包/类
@Test
public void evaluate() throws Exception {
ModelEvaluator<?> evaluator = createModelEvaluator();
List<TargetField> targetFields = evaluator.getTargetFields();
assertEquals(0, targetFields.size());
try {
evaluator.getTargetField();
fail();
} catch(EvaluationException ee){
// Ignored
}
assertEquals(Evaluator.DEFAULT_TARGET_NAME, evaluator.getTargetFieldName());
Map<FieldName, ?> arguments = createArguments("input", 2d);
Map<FieldName, ?> result = evaluator.evaluate(arguments);
assertEquals(1, result.size());
assertEquals(2d * 2d, (Double)getTarget(result, Evaluator.DEFAULT_TARGET_NAME), 1e-8d);
}
示例8: evaluate
import org.jpmml.evaluator.ModelEvaluator; //导入方法依赖的package包/类
@Test
public void evaluate() throws Exception {
ModelEvaluator<?> evaluator = createModelEvaluator();
Map<FieldName, ?> arguments = createArguments("input", (2d * 0.8d), "target", "yes");
Map<FieldName, ?> result = evaluator.evaluate(arguments);
FieldName field = FieldName.create("residual");
assertEquals(0.2d, (Double)getOutput(result, field), 1e-8);
arguments = createArguments("input", (2d * 0.8d), "target", "no");
result = evaluator.evaluate(arguments);
assertEquals(-0.8d, (Double)getOutput(result, field), 1e-8);
}
示例9: evaluate
import org.jpmml.evaluator.ModelEvaluator; //导入方法依赖的package包/类
@Test
public void evaluate() throws Exception {
ModelEvaluator<?> evaluator = createModelEvaluator();
Model model = evaluator.getModel();
Map<FieldName, ?> arguments = createArguments("input", null);
Map<FieldName, ?> result = evaluator.evaluate(arguments);
assertEquals(1, result.size());
assertEquals(432.21d, getTarget(result, Evaluator.DEFAULT_TARGET_NAME));
Targets targets = model.getTargets();
for(Target target : targets){
List<TargetValue> targetValues = target.getTargetValues();
targetValues.clear();
}
result = evaluator.evaluate(arguments);
assertEquals(1, result.size());
assertEquals(null, getTarget(result, Evaluator.DEFAULT_TARGET_NAME));
}
示例10: evaluate
import org.jpmml.evaluator.ModelEvaluator; //导入方法依赖的package包/类
@Test
public void evaluate() throws Exception {
ModelEvaluator<?> evaluator = createModelEvaluator();
Map<FieldName, ?> arguments = createArguments("x1", 3d, "x2", 3d);
Map<FieldName, ?> result = evaluator.evaluate(arguments);
ProbabilityDistribution<?> targetValue = (ProbabilityDistribution<?>)result.get(evaluator.getTargetFieldName());
assertEquals("yes", targetValue.getResult());
assertNotNull(targetValue.getPredictionReport());
double value = (3d * -28.6617384d + 3d * -20.42027426d + 125.56601826d);
assertEquals(Math.exp(0d) / (Math.exp(0d) + Math.exp(value)), targetValue.getProbability("yes"), 1e-8);
assertEquals(Math.exp(value) / (Math.exp(0d) + Math.exp(value)), targetValue.getProbability("no"), 1e-8);
assertNotNull(targetValue.getProbabilityReport("yes"));
assertNotNull(targetValue.getProbabilityReport("no"));
}
示例11: evaluate
import org.jpmml.evaluator.ModelEvaluator; //导入方法依赖的package包/类
private String evaluate(double x1, double x2) throws Exception {
ModelEvaluator<?> evaluator = createModelEvaluator();
Map<FieldName, ?> arguments = createArguments("x1", x1, "x2", x2);
Map<FieldName, ?> result = evaluator.evaluate(arguments);
Classification<?> targetValue = (Classification<?>)result.get(evaluator.getTargetFieldName());
return (String)targetValue.getResult();
}
示例12: evaluate
import org.jpmml.evaluator.ModelEvaluator; //导入方法依赖的package包/类
private double evaluate(double x1, double x2) throws Exception {
ModelEvaluator<?> evaluator = createModelEvaluator();
Map<FieldName, ?> arguments = createArguments("x1", x1, "x2", x2);
Map<FieldName, ?> result = evaluator.evaluate(arguments);
Regression<?> targetValue = (Regression<?>)result.get(evaluator.getTargetFieldName());
return (Double)targetValue.getResult();
}
示例13: evaluate
import org.jpmml.evaluator.ModelEvaluator; //导入方法依赖的package包/类
@Test
public void evaluate() throws Exception {
ModelEvaluator<?> evaluator = createModelEvaluator();
List<InputField> activeFields = evaluator.getActiveFields();
assertEquals(1, activeFields.size());
List<InputField> inputFields = new ArrayList<>(evaluator.getInputFields());
assertEquals(2, inputFields.size());
inputFields.removeAll(activeFields);
assertEquals(1, inputFields.size());
InputField inputField = Iterables.getOnlyElement(inputFields);
assertTrue(inputField instanceof TargetReferenceField);
Map<FieldName, ?> arguments = createArguments("input", 0.8d, "target", 3d);
Map<FieldName, ?> result = evaluator.evaluate(arguments);
FieldName field = FieldName.create("residual");
assertEquals(2.6d, (Double)getOutput(result, field), 1e-8);
}
示例14: evaluate
import org.jpmml.evaluator.ModelEvaluator; //导入方法依赖的package包/类
@Test
public void evaluate() throws Exception {
ModelEvaluator<?> evaluator = createModelEvaluator();
Model model = evaluator.getModel();
Map<FieldName, ?> arguments = createArguments("input", null);
Map<FieldName, ?> result = evaluator.evaluate(arguments);
assertEquals(5, result.size());
assertEquals("NO", getTarget(result, Evaluator.DEFAULT_TARGET_NAME));
FieldName field = FieldName.create("I_response");
FieldName displayField = FieldName.create("U_response");
assertEquals("NO", getOutput(result, field));
assertEquals("No", getOutput(result, displayField));
assertEquals(0.02d, getOutput(result, "P_responseYes"));
assertEquals(0.98d, getOutput(result, "P_responseNo"));
Targets targets = model.getTargets();
for(Target target : targets){
List<TargetValue> targetValues = target.getTargetValues();
targetValues.clear();
}
result = evaluator.evaluate(arguments);
assertEquals(1, result.size());
assertEquals(null, getTarget(result, Evaluator.DEFAULT_TARGET_NAME));
}