use of org.dmg.pmml.FieldName in project storm by apache.
the class JPmmlModelRunner method extractRawInputs.
/**
* @return The raw inputs extracted from the tuple for all 'active fields'
*/
@Override
public Map<FieldName, Object> extractRawInputs(Tuple tuple) {
LOG.debug("Extracting raw inputs from tuple: = [{}]", tuple);
final Map<FieldName, Object> rawInputs = new LinkedHashMap<>();
for (FieldName activeField : activeFields) {
rawInputs.put(activeField, tuple.getValueByField(activeField.getValue()));
}
LOG.debug("Raw inputs = [{}]", rawInputs);
return rawInputs;
}
use of org.dmg.pmml.FieldName in project storm by apache.
the class JPmmlModelRunner method toValuesMap.
// Sends the same tuple (list of scored/predicted values) to all the declared streams
private Map<String, List<Object>> toValuesMap(Map<FieldName, ?> predScores) {
final List<Object> scoredVals = new ArrayList<>();
for (FieldName predictedField : predictedFields) {
Object targetValue = predScores.get(predictedField);
scoredVals.add(EvaluatorUtil.decode(targetValue));
}
for (FieldName outputField : outputFields) {
Object targetValue = predScores.get(outputField);
scoredVals.add(EvaluatorUtil.decode(targetValue));
}
final Map<String, List<Object>> valuesMap = new HashMap<>();
for (String stream : modelOutputs.streams()) {
valuesMap.put(stream, scoredVals);
}
return valuesMap;
}
use of org.dmg.pmml.FieldName in project storm by apache.
the class JpmmlModelOutputs method create.
// ======
private static ModelOutputs create(PMML pmmlModel, List<String> streams) {
final Set<String> fieldNames = new LinkedHashSet<>();
final Evaluator evaluator = JpmmlFactory.newEvaluator(pmmlModel);
for (FieldName predictedField : evaluator.getPredictedFields()) {
fieldNames.add(predictedField.getValue());
}
for (FieldName outputField : evaluator.getOutputFields()) {
fieldNames.add(outputField.getValue());
}
final Map<String, Fields> toDeclare = streams.stream().collect(Collectors.toMap(Function.identity(), (x) -> new Fields(new ArrayList<>(fieldNames))));
return new JpmmlModelOutputs(toDeclare);
}
Aggregations