org.dmg.pmml.InvalidValueTreatmentMethod Java Examples
The following examples show how to use
org.dmg.pmml.InvalidValueTreatmentMethod.
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: DomainUtil.java From jpmml-sklearn with GNU Affero General Public License v3.0 | 6 votes |
static public InvalidValueTreatmentMethod parseInvalidValueTreatment(String invalidValueTreatment){ if(invalidValueTreatment == null){ return null; } switch(invalidValueTreatment){ case "as_is": return InvalidValueTreatmentMethod.AS_IS; case "as_missing": return InvalidValueTreatmentMethod.AS_MISSING; case "return_invalid": return InvalidValueTreatmentMethod.RETURN_INVALID; default: throw new IllegalArgumentException(invalidValueTreatment); } }
Example #2
Source File: InputFieldUtil.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 5 votes |
static private ScalarValue performInvalidValueTreatment(InputTypeInfo typeInfo, Object value){ MiningField miningField = typeInfo.getMiningField(); InvalidValueTreatmentMethod invalidValueTreatmentMethod = miningField.getInvalidValueTreatment(); switch(invalidValueTreatmentMethod){ case AS_IS: break; case AS_MISSING: case RETURN_INVALID: Object invalidValueReplacement = miningField.getInvalidValueReplacement(); if(invalidValueReplacement != null){ throw new MisplacedAttributeException(miningField, PMMLAttributes.MININGFIELD_INVALIDVALUEREPLACEMENT, invalidValueReplacement); } break; default: throw new UnsupportedAttributeException(miningField, invalidValueTreatmentMethod); } // End switch switch(invalidValueTreatmentMethod){ case RETURN_INVALID: Field<?> field = typeInfo.getField(); throw new InvalidResultException("Field " + PMMLException.formatKey(field.getName()) + " cannot accept user input value " + PMMLException.formatValue(value), miningField); case AS_IS: return createInvalidInputValue(typeInfo, value); case AS_MISSING: return createMissingInputValue(typeInfo); default: throw new UnsupportedAttributeException(miningField, invalidValueTreatmentMethod); } }
Example #3
Source File: Domain.java From jpmml-sklearn with GNU Affero General Public License v3.0 | 4 votes |
@Override public List<Feature> encodeFeatures(List<Feature> features, SkLearnEncoder encoder){ MissingValueTreatmentMethod missingValueTreatment = DomainUtil.parseMissingValueTreatment(getMissingValueTreatment()); Object missingValueReplacement = getMissingValueReplacement(); List<?> missingValues = getMissingValues(); if(missingValueReplacement != null){ if(missingValueTreatment == null){ missingValueTreatment = MissingValueTreatmentMethod.AS_VALUE; } } InvalidValueTreatmentMethod invalidValueTreatment = DomainUtil.parseInvalidValueTreatment(getInvalidValueTreatment()); Object invalidValueReplacement = getInvalidValueReplacement(); if(invalidValueReplacement != null){ if(invalidValueTreatment == null){ invalidValueTreatment = InvalidValueTreatmentMethod.AS_IS; } } for(Feature feature : features){ WildcardFeature wildcardFeature = asWildcardFeature(feature); DataField dataField = wildcardFeature.getField(); DataType dataType = dataField.getDataType(); if(missingValueTreatment != null){ Object pmmlMissingValueReplacement = (missingValueReplacement != null ? standardizeValue(dataType, missingValueReplacement) : null); encoder.addDecorator(dataField, new MissingValueDecorator(missingValueTreatment, pmmlMissingValueReplacement)); } // End if if(missingValues != null){ PMMLUtil.addValues(dataField, standardizeValues(dataType, missingValues), Value.Property.MISSING); } // End if if(invalidValueTreatment != null){ Object pmmlInvalidValueReplacement = (invalidValueReplacement != null ? standardizeValue(dataType, invalidValueReplacement) : null); encoder.addDecorator(dataField, new InvalidValueDecorator(invalidValueTreatment, pmmlInvalidValueReplacement)); } } return features; }
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; }