org.jpmml.evaluator.EvaluationContext Java Examples

The following examples show how to use org.jpmml.evaluator.EvaluationContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransformationDictionaryTest.java    From jpmml-evaluator with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void evaluateChain() throws Exception {
	Map<FieldName, ?> arguments = createArguments("Value", 1);

	EvaluationContext.DERIVEDFIELD_GUARD_PROVIDER.set(new FieldNameSet(2));

	try {
		assertValueEquals(1d, evaluate(FieldName.create("StageOne"), arguments));

		try {
			evaluate(FieldName.create("StageThree"), arguments);

			fail();
		} catch(EvaluationException ee){
			// Ignored
		}
	} finally {
		EvaluationContext.DERIVEDFIELD_GUARD_PROVIDER.set(null);
	}

	assertValueEquals(1d, evaluate(FieldName.create("StageThree"), arguments));
}
 
Example #2
Source File: SupportVectorMachineModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected <V extends Number> Map<FieldName, ?> evaluateRegression(ValueFactory<V> valueFactory, EvaluationContext context){
	SupportVectorMachineModel supportVectorMachineModel = getModel();

	List<SupportVectorMachine> supportVectorMachines = supportVectorMachineModel.getSupportVectorMachines();
	if(supportVectorMachines.size() != 1){
		throw new InvalidElementListException(supportVectorMachines);
	}

	SupportVectorMachine supportVectorMachine = supportVectorMachines.get(0);

	Object input = createInput(context);

	Value<V> result = evaluateSupportVectorMachine(valueFactory, supportVectorMachine, input);

	return TargetUtil.evaluateRegression(getTargetField(), result);
}
 
Example #3
Source File: TreeModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 6 votes vote down vote up
private Boolean evaluateNode(Trail trail, Node node, EvaluationContext context){
	EmbeddedModel embeddedModel = node.getEmbeddedModel();
	if(embeddedModel != null){
		throw new UnsupportedElementException(embeddedModel);
	}

	Predicate predicate = PredicateUtil.ensurePredicate(node);

	// A compound predicate whose boolean operator is "surrogate" represents a special case
	if(predicate instanceof CompoundPredicate){
		CompoundPredicate compoundPredicate = (CompoundPredicate)predicate;

		PredicateUtil.CompoundPredicateResult result = PredicateUtil.evaluateCompoundPredicateInternal(compoundPredicate, context);
		if(result.isAlternative()){
			trail.addMissingLevel();
		}

		return result.getResult();
	} else

	{
		return PredicateUtil.evaluate(predicate, context);
	}
}
 
Example #4
Source File: TreeModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * @param parent The parent Node of the Node that evaluated to the missing value.
 * @param node The Node that evaluated to the missing value.
 */
private Trail handleMissingValue(Trail trail, Node parent, Node node, EvaluationContext context){
	TreeModel treeModel = getModel();

	TreeModel.MissingValueStrategy missingValueStrategy = treeModel.getMissingValueStrategy();
	switch(missingValueStrategy){
		case NULL_PREDICTION:
			return trail.selectNull();
		case LAST_PREDICTION:
			return trail.selectLastPrediction();
		case DEFAULT_CHILD:
			return handleDefaultChild(trail, parent, context);
		case NONE:
			return null;
		default:
			throw new UnsupportedAttributeException(treeModel, missingValueStrategy);
	}
}
 
Example #5
Source File: GeneralRegressionModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected <V extends Number> Map<FieldName, ?> evaluateRegression(ValueFactory<V> valueFactory, EvaluationContext context){
	GeneralRegressionModel generalRegressionModel = getModel();

	GeneralRegressionModel.ModelType modelType = generalRegressionModel.getModelType();
	switch(modelType){
		case COX_REGRESSION:
			return evaluateCoxRegression(valueFactory, context);
		default:
			return evaluateGeneralRegression(valueFactory, context);
	}
}
 
Example #6
Source File: RuleSetModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
static
private void evaluateRule(Rule rule, ListMultimap<Object, SimpleRule> firedRules, EvaluationContext context){
	Boolean status = PredicateUtil.evaluatePredicateContainer(rule, context);

	if(status == null || !status.booleanValue()){
		return;
	} // End if

	if(rule instanceof SimpleRule){
		SimpleRule simpleRule = (SimpleRule)rule;

		Object score = simpleRule.getScore();
		if(score == null){
			throw new MissingAttributeException(simpleRule, PMMLAttributes.SIMPLERULE_SCORE);
		}

		firedRules.put(score, simpleRule);
	} else

	if(rule instanceof CompoundRule){
		CompoundRule compoundRule = (CompoundRule)rule;

		evaluateRules(compoundRule.getRules(), firedRules, context);
	} else

	{
		throw new UnsupportedElementException(rule);
	}
}
 
Example #7
Source File: RuleSetModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
static
private void evaluateRules(List<Rule> rules, ListMultimap<Object, SimpleRule> firedRules, EvaluationContext context){

	for(Rule rule : rules){
		evaluateRule(rule, firedRules, context);
	}
}
 
Example #8
Source File: NearestNeighborModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
private <V extends Number> List<InstanceResult<V>> evaluateInstanceRows(ValueFactory<V> valueFactory, EvaluationContext context){
	NearestNeighborModel nearestNeighborModel = getModel();

	ComparisonMeasure comparisonMeasure = nearestNeighborModel.getComparisonMeasure();

	List<FieldValue> values = new ArrayList<>();

	KNNInputs knnInputs = nearestNeighborModel.getKNNInputs();
	for(KNNInput knnInput : knnInputs){
		FieldName name = knnInput.getField();
		if(name == null){
			throw new MissingAttributeException(knnInput, PMMLAttributes.KNNINPUT_FIELD);
		}

		FieldValue value = context.evaluate(name);

		values.add(value);
	}

	Measure measure = MeasureUtil.ensureMeasure(comparisonMeasure);

	if(measure instanceof Similarity){
		return evaluateSimilarity(valueFactory, comparisonMeasure, knnInputs.getKNNInputs(), values);
	} else

	if(measure instanceof Distance){
		return evaluateDistance(valueFactory, comparisonMeasure, knnInputs.getKNNInputs(), values);
	} else

	{
		throw new UnsupportedElementException(measure);
	}
}
 
Example #9
Source File: GeneralRegressionModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
static
private FieldValue getVariable(FieldName name, EvaluationContext context){
	FieldValue value = context.evaluate(name);

	if(FieldValueUtil.isMissing(value)){
		throw new MissingValueException(name);
	}

	return value;
}
 
Example #10
Source File: GeneralRegressionModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
static
private Integer getTrials(GeneralRegressionModel generalRegressionModel, EvaluationContext context){
	FieldName trialsVariable = generalRegressionModel.getTrialsVariable();

	if(trialsVariable != null){
		FieldValue value = getVariable(trialsVariable, context);

		return value.asInteger();
	}

	return generalRegressionModel.getTrialsValue();
}
 
Example #11
Source File: GeneralRegressionModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
static
private Number getOffset(GeneralRegressionModel generalRegressionModel, EvaluationContext context){
	FieldName offsetVariable = generalRegressionModel.getOffsetVariable();

	if(offsetVariable != null){
		FieldValue value = getVariable(offsetVariable, context);

		return value.asNumber();
	}

	return generalRegressionModel.getOffsetValue();
}
 
Example #12
Source File: GeneralRegressionModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
private <V extends Number> Value<V> computeCumulativeLink(Value<V> value, EvaluationContext context){
	GeneralRegressionModel generalRegressionModel = getModel();

	GeneralRegressionModel.CumulativeLinkFunction cumulativeLinkFunction = generalRegressionModel.getCumulativeLinkFunction();
	if(cumulativeLinkFunction == null){
		throw new MissingAttributeException(generalRegressionModel, PMMLAttributes.GENERALREGRESSIONMODEL_CUMULATIVELINKFUNCTION);
	}

	Number offset = getOffset(generalRegressionModel, context);
	if(offset != null){
		value.add(offset);
	}

	switch(cumulativeLinkFunction){
		case LOGIT:
		case PROBIT:
		case CLOGLOG:
		case LOGLOG:
		case CAUCHIT:
			GeneralRegressionModelUtil.computeCumulativeLink(cumulativeLinkFunction, value);
			break;
		default:
			throw new UnsupportedAttributeException(generalRegressionModel, cumulativeLinkFunction);
	}

	return value;
}
 
Example #13
Source File: GeneralRegressionModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
private <V extends Number> Value<V> computeDotProduct(ValueFactory<V> valueFactory, Iterable<PCell> parameterCells, Map<String, Row> parameterPredictorRows, EvaluationContext context){
	Value<V> result = null;

	for(PCell parameterCell : parameterCells){
		String parameterName = parameterCell.getParameterName();
		if(parameterName == null){
			throw new MissingAttributeException(parameterCell, PMMLAttributes.PCELL_PARAMETERNAME);
		}

		Number beta = parameterCell.getBeta();
		if(beta == null){
			throw new MissingAttributeException(parameterCell, PMMLAttributes.PCELL_BETA);
		} // End if

		if(result == null){
			result = valueFactory.newValue();
		}

		Row parameterPredictorRow = parameterPredictorRows.get(parameterName);
		if(parameterPredictorRow != null){
			Value<V> x = parameterPredictorRow.evaluate(valueFactory, context);

			if(x == null){
				return null;
			}

			result.add(beta, x.getValue());
		} else

		{
			result.add(beta);
		}
	}

	return result;
}
 
Example #14
Source File: GeneralRegressionModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
private <V extends Number> Value<V> computeDotProduct(ValueFactory<V> valueFactory, EvaluationContext context){
	GeneralRegressionModel generalRegressionModel = getModel();

	Map<?, Map<String, Row>> ppMatrixMap = getPPMatrixMap();

	Map<String, Row> parameterPredictorRows;

	if(ppMatrixMap.isEmpty()){
		parameterPredictorRows = Collections.emptyMap();
	} else

	{
		parameterPredictorRows = ppMatrixMap.get(null);
		if(parameterPredictorRows == null){
			PPMatrix ppMatrix = generalRegressionModel.getPPMatrix();

			throw new InvalidElementException(ppMatrix);
		}
	}

	Map<?, List<PCell>> paramMatrixMap = getParamMatrixMap();

	List<PCell> parameterCells = paramMatrixMap.get(null);

	if(paramMatrixMap.size() != 1 || parameterCells == null){
		ParamMatrix paramMatrix = generalRegressionModel.getParamMatrix();

		throw new InvalidElementException(paramMatrix);
	}

	return computeDotProduct(valueFactory, parameterCells, parameterPredictorRows, context);
}
 
Example #15
Source File: GeneralRegressionModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
private <V extends Number> Map<FieldName, ?> evaluateGeneralRegression(ValueFactory<V> valueFactory, EvaluationContext context){
	GeneralRegressionModel generalRegressionModel = getModel();

	TargetField targetField = getTargetField();

	Value<V> result = computeDotProduct(valueFactory, context);
	if(result == null){
		return TargetUtil.evaluateRegressionDefault(valueFactory, targetField);
	}

	GeneralRegressionModel.ModelType modelType = generalRegressionModel.getModelType();
	switch(modelType){
		case REGRESSION:
		case GENERAL_LINEAR:
			break;
		case GENERALIZED_LINEAR:
			result = computeLink(result, context);
			break;
		case MULTINOMIAL_LOGISTIC:
		case ORDINAL_MULTINOMIAL:
		case COX_REGRESSION:
			throw new InvalidAttributeException(generalRegressionModel, modelType);
		default:
			throw new UnsupportedAttributeException(generalRegressionModel, modelType);
	}

	return TargetUtil.evaluateRegression(targetField, result);
}
 
Example #16
Source File: ExpressionTranslatorTest.java    From jpmml-sparkml with GNU Affero General Public License v3.0 5 votes vote down vote up
static
public void checkValue(Object expectedValue, String sqlExpression){
	Expression expression = translateInternal("SELECT (" + sqlExpression + ") FROM __THIS__");

	Object sparkValue = expression.eval(InternalRow.empty());

	if(expectedValue instanceof String){
		assertEquals(expectedValue, sparkValue.toString());
	} else

	if(expectedValue instanceof Integer){
		assertEquals(expectedValue, ((Number)sparkValue).intValue());
	} else

	if(expectedValue instanceof Float){
		assertEquals(expectedValue, ((Number)sparkValue).floatValue());
	} else

	if(expectedValue instanceof Double){
		assertEquals(expectedValue, ((Number)sparkValue).doubleValue());
	} else

	{
		assertEquals(expectedValue, sparkValue);
	}

	org.dmg.pmml.Expression pmmlExpression = ExpressionTranslator.translate(expression);

	EvaluationContext context = new VirtualEvaluationContext();
	context.declareAll(Collections.emptyMap());

	FieldValue value = ExpressionUtil.evaluate(pmmlExpression, context);

	Object pmmlValue = FieldValueUtil.getValue(value);
	assertEquals(expectedValue, pmmlValue);
}
 
Example #17
Source File: FunctionTransformerTest.java    From jpmml-sklearn with GNU Affero General Public License v3.0 5 votes vote down vote up
static
private Object evaluate(String function, Object value){
	UFunc ufunc = new UFunc("numpy.core", "_ufunc_reconstruct");
	ufunc.__init__(new String[]{"numpy", function});

	FieldName name = FieldName.create("x");

	DataType dataType;

	if(value instanceof Integer){
		dataType = DataType.INTEGER;
	} else

	if(value instanceof Float){
		dataType = DataType.FLOAT;
	} else

	{
		dataType = DataType.DOUBLE;
	}

	EvaluationContext context = new VirtualEvaluationContext();
	context.declare(name, FieldValueUtil.create(dataType, OpType.CONTINUOUS, value));

	Expression expression = UFuncUtil.encodeUFunc(ufunc, Collections.singletonList(new FieldRef(name)));

	FieldValue result = ExpressionUtil.evaluate(expression, context);

	return FieldValueUtil.getValue(result);
}
 
Example #18
Source File: TreeModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
private Trail handleTrue(Trail trail, Node node, EvaluationContext context){

		// A "true" leaf node
		if(!node.hasNodes()){
			return trail.selectNode(node);
		}

		trail.push(node);

		List<Node> children = node.getNodes();
		for(int i = 0, max = children.size(); i < max; i++){
			Node child = children.get(i);

			Boolean status = evaluateNode(trail, child, context);

			if(status == null){
				Trail destination = handleMissingValue(trail, node, child, context);

				if(destination != null){
					return destination;
				}
			} else

			if(status.booleanValue()){
				return handleTrue(trail, child, context);
			}
		}

		// A "true" non-leaf node
		return handleNoTrueChild(trail);
	}
 
Example #19
Source File: TreeModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected <V extends Number> Map<FieldName, ?> evaluateRegression(ValueFactory<V> valueFactory, EvaluationContext context){
	TargetField targetField = getTargetField();

	Trail trail = new Trail();

	Node node = evaluateTree(trail, context);
	if(node == null){
		return TargetUtil.evaluateRegressionDefault(valueFactory, targetField);
	}

	NodeScore<V> result = createNodeScore(valueFactory, targetField, node);

	return TargetUtil.evaluateRegression(targetField, result);
}
 
Example #20
Source File: ClusteringModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected <V extends Number> Map<FieldName, ClusterAffinityDistribution<V>> evaluateClustering(ValueFactory<V> valueFactory, EvaluationContext context){
	ClusteringModel clusteringModel = getModel();

	ComparisonMeasure comparisonMeasure = clusteringModel.getComparisonMeasure();

	List<ClusteringField> clusteringFields = getCenterClusteringFields();

	List<FieldValue> values = new ArrayList<>(clusteringFields.size());

	for(int i = 0, max = clusteringFields.size(); i < max; i++){
		ClusteringField clusteringField = clusteringFields.get(i);

		FieldName name = clusteringField.getField();
		if(name == null){
			throw new MissingAttributeException(clusteringField, PMMLAttributes.CLUSTERINGFIELD_FIELD);
		}

		FieldValue value = context.evaluate(name);

		values.add(value);
	}

	ClusterAffinityDistribution<V> result;

	Measure measure = MeasureUtil.ensureMeasure(comparisonMeasure);

	if(measure instanceof Similarity){
		result = evaluateSimilarity(valueFactory, comparisonMeasure, clusteringFields, values);
	} else

	if(measure instanceof Distance){
		result = evaluateDistance(valueFactory, comparisonMeasure, clusteringFields, values);
	} else

	{
		throw new UnsupportedElementException(measure);
	}

	// "For clustering models, the identifier of the winning cluster is returned as the predictedValue"
	result.computeResult(DataType.STRING);

	return Collections.singletonMap(getTargetName(), result);
}
 
Example #21
Source File: RegressionModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected <V extends Number> Map<FieldName, ?> evaluateRegression(ValueFactory<V> valueFactory, EvaluationContext context){
	RegressionModel regressionModel = getModel();

	TargetField targetField = getTargetField();

	FieldName targetName = regressionModel.getTargetField();
	if(targetName != null && !Objects.equals(targetField.getFieldName(), targetName)){
		throw new InvalidAttributeException(regressionModel, PMMLAttributes.REGRESSIONMODEL_TARGETFIELD, targetName);
	}

	List<RegressionTable> regressionTables = regressionModel.getRegressionTables();
	if(regressionTables.size() != 1){
		throw new InvalidElementListException(regressionTables);
	}

	RegressionTable regressionTable = regressionTables.get(0);

	Value<V> result = evaluateRegressionTable(valueFactory, regressionTable, context);
	if(result == null){
		return TargetUtil.evaluateRegressionDefault(valueFactory, targetField);
	}

	RegressionModel.NormalizationMethod normalizationMethod = regressionModel.getNormalizationMethod();
	switch(normalizationMethod){
		case NONE:
		case SOFTMAX:
		case LOGIT:
		case EXP:
		case PROBIT:
		case CLOGLOG:
		case LOGLOG:
		case CAUCHIT:
			RegressionModelUtil.normalizeRegressionResult(normalizationMethod, result);
			break;
		case SIMPLEMAX:
			throw new InvalidAttributeException(regressionModel, normalizationMethod);
		default:
			throw new UnsupportedAttributeException(regressionModel, normalizationMethod);
	}

	return TargetUtil.evaluateRegression(targetField, result);
}
 
Example #22
Source File: JavaModel.java    From jpmml-evaluator with GNU Affero General Public License v3.0 4 votes vote down vote up
protected <V extends Number> Map<FieldName, ?> evaluateRegression(ValueFactory<V> valueFactory, EvaluationContext context){
	return evaluateDefault();
}
 
Example #23
Source File: JavaModel.java    From jpmml-evaluator with GNU Affero General Public License v3.0 4 votes vote down vote up
protected <V extends Number> Map<FieldName, ?> evaluateClassification(ValueFactory<V> valueFactory, EvaluationContext context){
	return evaluateDefault();
}
 
Example #24
Source File: JavaModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected <V extends Number> Map<FieldName, ?> evaluateRegression(ValueFactory<V> valueFactory, EvaluationContext context){
	JavaModel javaModel = getModel();

	return javaModel.evaluateRegression(valueFactory, context);
}
 
Example #25
Source File: JavaModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected <V extends Number> Map<FieldName, ?> evaluateClassification(ValueFactory<V> valueFactory, EvaluationContext context){
	JavaModel javaModel = getModel();

	return javaModel.evaluateClassification(valueFactory, context);
}
 
Example #26
Source File: NearestNeighborModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected <V extends Number> Map<FieldName, AffinityDistribution<V>> evaluateClustering(ValueFactory<V> valueFactory, EvaluationContext context){
	NearestNeighborModel nearestNeighborModel = getModel();

	Table<Integer, FieldName, FieldValue> table = getTrainingInstances();

	List<InstanceResult<V>> instanceResults = evaluateInstanceRows(valueFactory, context);

	FieldName instanceIdVariable = nearestNeighborModel.getInstanceIdVariable();
	if(instanceIdVariable == null){
		throw new MissingAttributeException(nearestNeighborModel, PMMLAttributes.NEARESTNEIGHBORMODEL_INSTANCEIDVARIABLE);
	}

	Function<Integer, String> function = createIdentifierResolver(instanceIdVariable, table);

	AffinityDistribution<V> result = createAffinityDistribution(instanceResults, function, null);

	return Collections.singletonMap(getTargetName(), result);
}
 
Example #27
Source File: NearestNeighborModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected <V extends Number> Map<FieldName, AffinityDistribution<V>> evaluateMixed(ValueFactory<V> valueFactory, EvaluationContext context){
	NearestNeighborModel nearestNeighborModel = getModel();

	Table<Integer, FieldName, FieldValue> table = getTrainingInstances();

	List<InstanceResult<V>> instanceResults = evaluateInstanceRows(valueFactory, context);

	Ordering<InstanceResult<V>> ordering = (Ordering.natural()).reverse();

	List<InstanceResult<V>> nearestInstanceResults = ordering.sortedCopy(instanceResults);

	Integer numberOfNeighbors = nearestNeighborModel.getNumberOfNeighbors();
	if(numberOfNeighbors == null){
		throw new MissingAttributeException(nearestNeighborModel, PMMLAttributes.NEARESTNEIGHBORMODEL_NUMBEROFNEIGHBORS);
	}

	nearestInstanceResults = nearestInstanceResults.subList(0, numberOfNeighbors);

	Function<Integer, String> function = new Function<Integer, String>(){

		@Override
		public String apply(Integer row){
			return row.toString();
		}
	};

	FieldName instanceIdVariable = nearestNeighborModel.getInstanceIdVariable();
	if(instanceIdVariable != null){
		function = createIdentifierResolver(instanceIdVariable, table);
	}

	Map<FieldName, AffinityDistribution<V>> results = new LinkedHashMap<>();

	List<TargetField> targetFields = getTargetFields();
	for(TargetField targetField : targetFields){
		FieldName name = targetField.getFieldName();

		Object value;

		OpType opType = targetField.getOpType();
		switch(opType){
			case CONTINUOUS:
				value = calculateContinuousTarget(valueFactory, name, nearestInstanceResults, table);
				break;
			case CATEGORICAL:
				value = calculateCategoricalTarget(valueFactory, name, nearestInstanceResults, table);
				break;
			default:
				throw new InvalidElementException(nearestNeighborModel);
		}

		value = TypeUtil.parseOrCast(targetField.getDataType(), value);

		AffinityDistribution<V> result = createAffinityDistribution(instanceResults, function, value);

		results.put(name, result);
	}

	return results;
}
 
Example #28
Source File: NearestNeighborModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected <V extends Number> Map<FieldName, AffinityDistribution<V>> evaluateClassification(ValueFactory<V> valueFactory, EvaluationContext context){
	return evaluateMixed(valueFactory, context);
}
 
Example #29
Source File: NearestNeighborModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected <V extends Number> Map<FieldName, AffinityDistribution<V>> evaluateRegression(ValueFactory<V> valueFactory, EvaluationContext context){
	return evaluateMixed(valueFactory, context);
}
 
Example #30
Source File: MiningModelEvaluator.java    From jpmml-evaluator with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected <V extends Number> Map<FieldName, ?> evaluateMixed(ValueFactory<V> valueFactory, EvaluationContext context){
	return evaluateAny(valueFactory, context);
}