Java Code Examples for org.dmg.pmml.DataField#getDataType()
The following examples show how to use
org.dmg.pmml.DataField#getDataType() .
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: Transformer.java From jpmml-sklearn with GNU Affero General Public License v3.0 | 6 votes |
public DataField updateDataField(DataField dataField, OpType opType, DataType dataType, SkLearnEncoder encoder){ FieldName name = dataField.getName(); if(encoder.isFrozen(name)){ return dataField; } switch(dataType){ case DOUBLE: // If the DataField element already specifies a non-default data type, then keep it if(!(DataType.DOUBLE).equals(dataField.getDataType())){ dataType = dataField.getDataType(); } break; } dataField .setOpType(opType) .setDataType(dataType); return dataField; }
Example 2
Source File: NaNAsMissingDecorator.java From jpmml-lightgbm with GNU Affero General Public License v3.0 | 5 votes |
@Override public VisitorAction visit(DataField dataField){ DataType dataType = dataField.getDataType(); switch(dataType){ case FLOAT: case DOUBLE: PMMLUtil.addValues(dataField, Collections.singletonList("NaN"), Property.MISSING); break; default: break; } return super.visit(dataField); }
Example 3
Source File: CategoricalDomain.java From jpmml-sklearn with GNU Affero General Public License v3.0 | 5 votes |
@Override public Feature encode(WildcardFeature wildcardFeature, List<?> values){ PMMLEncoder encoder = wildcardFeature.getEncoder(); if(values == null || values.isEmpty()){ DataField dataField = (DataField)encoder.getField(wildcardFeature.getName()); dataField.setOpType(OpType.CATEGORICAL); return new ObjectFeature(encoder, dataField.getName(), dataField.getDataType()); } return wildcardFeature.toCategoricalFeature(standardizeValues(wildcardFeature.getDataType(), values)); }
Example 4
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 5
Source File: TemporalDomain.java From jpmml-sklearn with GNU Affero General Public License v3.0 | 4 votes |
@Override public List<Feature> encodeFeatures(List<Feature> features, SkLearnEncoder encoder){ features = super.encodeFeatures(features, encoder); List<Feature> result = new ArrayList<>(); for(int i = 0; i < features.size(); i++){ Feature feature = features.get(i); WildcardFeature wildcardFeature = asWildcardFeature(feature); DataField dataField = wildcardFeature.getField(); dataField.setOpType(OpType.ORDINAL); feature = new ObjectFeature(encoder, dataField.getName(), dataField.getDataType()); result.add(feature); } return result; }
Example 6
Source File: TargetFieldUtil.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 4 votes |
static public Value getValidValue(DataField dataField, Object value){ if(value == null){ return null; } // End if if(dataField.hasValues()){ DataType dataType = dataField.getDataType(); if(dataType == null){ throw new MissingAttributeException(dataField, PMMLAttributes.DATAFIELD_DATATYPE); } value = TypeUtil.parseOrCast(dataType, value); List<Value> pmmlValues = dataField.getValues(); for(int i = 0, max = pmmlValues.size(); i < max; i++){ Value pmmlValue = pmmlValues.get(i); Object simpleValue = pmmlValue.getValue(); if(simpleValue == null){ throw new MissingAttributeException(pmmlValue, PMMLAttributes.VALUE_VALUE); } Value.Property property = pmmlValue.getProperty(); switch(property){ case VALID: { boolean equals = TypeUtil.equals(dataType, value, simpleValue); if(equals){ return pmmlValue; } } break; case INVALID: case MISSING: break; default: throw new UnsupportedAttributeException(pmmlValue, property); } } } return null; }