Java Code Examples for org.dmg.pmml.MiningField#getMissingValueReplacement()
The following examples show how to use
org.dmg.pmml.MiningField#getMissingValueReplacement() .
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: ValueParser.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 6 votes |
@Override public VisitorAction visit(MiningField miningField){ FieldName name = miningField.getName(); if(name == null){ throw new MissingAttributeException(miningField, PMMLAttributes.MININGFIELD_NAME); } DataType dataType = resolveDataType(name); if(dataType != null){ Object missingValueReplacement = miningField.getMissingValueReplacement(); if(missingValueReplacement != null){ missingValueReplacement = safeParseOrCast(dataType, missingValueReplacement); miningField.setMissingValueReplacement(missingValueReplacement); } Object invalidValueReplacement = miningField.getInvalidValueReplacement(); if(invalidValueReplacement != null){ invalidValueReplacement = safeParseOrCast(dataType, invalidValueReplacement); miningField.setInvalidValueReplacement(invalidValueReplacement); } } return super.visit(miningField); }
Example 2
Source File: InputFieldUtil.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 5 votes |
static private ScalarValue performMissingValueTreatment(InputTypeInfo typeInfo){ MiningField miningField = typeInfo.getMiningField(); MissingValueTreatmentMethod missingValueTreatmentMethod = miningField.getMissingValueTreatment(); if(missingValueTreatmentMethod == null){ missingValueTreatmentMethod = MissingValueTreatmentMethod.AS_IS; } switch(missingValueTreatmentMethod){ case AS_IS: case AS_MEAN: case AS_MODE: case AS_MEDIAN: case AS_VALUE: return createMissingInputValue(typeInfo); case RETURN_INVALID: Field<?> field = typeInfo.getField(); Object missingValueReplacement = miningField.getMissingValueReplacement(); if(missingValueReplacement != null){ throw new MisplacedAttributeException(miningField, PMMLAttributes.MININGFIELD_MISSINGVALUEREPLACEMENT, missingValueReplacement); } throw new InvalidResultException("Field " + PMMLException.formatKey(field.getName()) + " requires user input value", miningField); default: throw new UnsupportedAttributeException(miningField, missingValueTreatmentMethod); } }
Example 3
Source File: InputFieldUtil.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 5 votes |
static private ScalarValue createMissingInputValue(InputTypeInfo typeInfo){ MiningField miningField = typeInfo.getMiningField(); Object missingValueReplacement = miningField.getMissingValueReplacement(); if(missingValueReplacement != null){ return (ScalarValue)createInputValue(typeInfo, missingValueReplacement); } return (ScalarValue)FieldValues.MISSING_VALUE; }
Example 4
Source File: InputFieldUtil.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 4 votes |
static public boolean isDefault(Field<?> field, MiningField miningField){ if(field instanceof DataField){ if(!Objects.equals(field.getOpType(), FieldUtil.getOpType(field, miningField))){ return false; } } else { if(!Objects.equals(miningField.getOpType(), null)){ return false; } } Object invalidValueReplacement = miningField.getInvalidValueReplacement(); if(invalidValueReplacement != null){ return false; } InvalidValueTreatmentMethod invalidValueTreatmentMethod = miningField.getInvalidValueTreatment(); switch(invalidValueTreatmentMethod){ case RETURN_INVALID: case AS_IS: // XXX break; default: return false; } Object missingValueReplacement = miningField.getMissingValueReplacement(); if(missingValueReplacement != null){ return false; } OutlierTreatmentMethod outlierTreatmentMethod = miningField.getOutlierTreatment(); switch(outlierTreatmentMethod){ case AS_IS: break; default: return false; } return true; }