private Double getLift(AssociationRule associationRule){ Double lift = associationRule.getLift(); if(lift == null){ throw new MissingAttributeException(associationRule, PMMLAttributes.ASSOCIATIONRULE_LIFT); } return lift; }
static public <E extends Expression & HasFieldReference<E>> FieldName ensureField(E hasField){ FieldName name = hasField.getField(); if(name == null){ throw new MissingAttributeException(MissingAttributeException.formatMessage(XPathUtil.formatElement(hasField.getClass()) + "@field"), hasField); } return name; }
public MissingAttributeException(PMMLObject object, Field field){ super(formatMessage(XPathUtil.formatElementOrAttribute(field)), object); }
private Double getLeverage(AssociationRule associationRule){ Double leverage = associationRule.getLeverage(); if(leverage == null){ throw new MissingAttributeException(associationRule, PMMLAttributes.ASSOCIATIONRULE_LEVERAGE); } return leverage; }
@Override public OpType getOpType(){ OpType opType = FieldUtil.getOpType(field, miningField); if(opType == null){ throw new MissingAttributeException(MissingAttributeException.formatMessage(XPathUtil.formatElement(field.getClass()) + "@optype"), field); } return opType; }
@Override public DataType getDataType(){ DataType dataType = derivedField.getDataType(); if(dataType == null){ throw new MissingAttributeException(derivedField, PMMLAttributes.DERIVEDFIELD_DATATYPE); } return dataType; }
@Override public DataType getDataType(){ DataType dataType = FieldUtil.getDataType(field); if(dataType == null){ throw new MissingAttributeException(MissingAttributeException.formatMessage(XPathUtil.formatElement(field.getClass()) + "@dataType"), field); } return dataType; }
@Override public OpType getOpType(){ OpType opType = derivedField.getOpType(); if(opType == null){ throw new MissingAttributeException(derivedField, PMMLAttributes.DERIVEDFIELD_OPTYPE); } return opType; }
static private String ensureValue(HasValue<?> hasValue){ String value = hasValue.getValue(); if(value == null){ throw new MissingAttributeException(MissingAttributeException.formatMessage(XPathUtil.formatElement((Class)hasValue.getClass()) + "@value"), (PMMLObject)hasValue); } return value; }
private Double getAffinity(AssociationRule associationRule){ Double affinity = associationRule.getAffinity(); if(affinity == null){ throw new MissingAttributeException(associationRule, PMMLAttributes.ASSOCIATIONRULE_AFFINITY); } return affinity; } };
static private void checkMiningFunction(Model model, MiningFunction parentMiningFunction){ MiningFunction miningFunction = model.getMiningFunction(); if(miningFunction == null){ throw new MissingAttributeException(MissingAttributeException.formatMessage(XPathUtil.formatElement(model.getClass()) + "@functionName"), model); } // End if if(!(miningFunction).equals(parentMiningFunction)){ throw new InvalidAttributeException(InvalidAttributeException.formatMessage(XPathUtil.formatElement(model.getClass()) + "@functionName=" + miningFunction.value()), model); } }
@Override public String apply(Category category){ String value = category.getValue(); if(value == null){ throw new MissingAttributeException(category, PMMLAttributes.CATEGORY_VALUE); } return value; } };
static private <F extends Field<F> & HasDiscreteDomain<F>> List<Object> parseValidValues(F field){ List<Object> result = new ArrayList<>(); DataType dataType = field.getDataType(); if(dataType == null){ throw new MissingAttributeException(MissingAttributeException.formatMessage(XPathUtil.formatElement(field.getClass()) + "@dataType"), field); } // End if if(field.hasValues()){ List<Value> pmmlValues = field.getValues(); for(Value pmmlValue : pmmlValues){ String stringValue = pmmlValue.getValue(); if(stringValue == null){ throw new MissingAttributeException(pmmlValue, PMMLAttributes.VALUE_VALUE); } Value.Property property = pmmlValue.getProperty(); switch(property){ case VALID: result.add(TypeUtil.parse(dataType, stringValue)); break; default: break; } } } return result; }
private CovariateHandler(PPCell ppCell){ super(ppCell); String value = ppCell.getValue(); if(value == null){ throw new MissingAttributeException(ppCell, PMMLAttributes.PPCELL_VALUE); } setExponent(Double.parseDouble(value)); }
private Map<FieldName, List<NeuralOutput>> parseNeuralOutputs(){ NeuralNetwork neuralNetwork = getModel(); ListMultimap<FieldName, NeuralOutput> result = ArrayListMultimap.create(); NeuralOutputs neuralOutputs = neuralNetwork.getNeuralOutputs(); for(NeuralOutput neuralOutput : neuralOutputs){ FieldName name; Expression expression = getOutputExpression(neuralOutput); if(expression instanceof HasFieldReference){ HasFieldReference<?> hasFieldReference = (HasFieldReference<?>)expression; name = hasFieldReference.getField(); if(name == null){ throw new MissingAttributeException(MissingAttributeException.formatMessage(XPathUtil.formatElement((Class)hasFieldReference.getClass()) + "@field"), expression); } } else { throw new MisplacedElementException(expression); } result.put(name, neuralOutput); } return (Map)result.asMap(); }
private FactorHandler(PPCell ppCell){ super(ppCell); String value = ppCell.getValue(); if(value == null){ throw new MissingAttributeException(ppCell, PMMLAttributes.PPCELL_VALUE); } setCategory(value); }
throw new MissingAttributeException(MissingAttributeException.formatMessage(XPathUtil.formatElement(model.getClass()) + "@functionName"), model);
@Override public FieldValue getValue(TypeInfo typeInfo){ if(this.parsedValue == null){ String value = getValue(); if(value == null){ throw new MissingAttributeException(this, PMMLAttributes.SIMPLEPREDICATE_VALUE); } this.parsedValue = parse(typeInfo, value); } return this.parsedValue; } }
@Override public FieldValue getValue(TypeInfo typeInfo){ if(this.parsedValue == null){ String value = getValue(); if(value == null){ throw new MissingAttributeException(this, PMMLAttributes.PPCELL_VALUE); } this.parsedValue = parse(typeInfo, value); } return this.parsedValue; } }
@Override public FieldValue getValue(TypeInfo typeInfo){ if(this.parsedValue == null){ String value = getValue(); if(value == null){ throw new MissingAttributeException(this, PMMLAttributes.CATEGORICALPREDICTOR_FIELD); } this.parsedValue = parse(typeInfo, value); } return this.parsedValue; } }