本文整理汇总了Java中org.dmg.pmml.TypeDefinitionField类的典型用法代码示例。如果您正苦于以下问题:Java TypeDefinitionField类的具体用法?Java TypeDefinitionField怎么用?Java TypeDefinitionField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeDefinitionField类属于org.dmg.pmml包,在下文中一共展示了TypeDefinitionField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: encodeFeatures
import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
@Override
public List<Feature> encodeFeatures(SparkMLEncoder encoder){
RegexTokenizer transformer = getTransformer();
if(!transformer.getGaps()){
throw new IllegalArgumentException("Expected splitter mode, got token matching mode");
} // End if
if(transformer.getMinTokenLength() != 1){
throw new IllegalArgumentException("Expected 1 as minimum token length, got " + transformer.getMinTokenLength() + " as minimum token length");
}
Feature feature = encoder.getOnlyFeature(transformer.getInputCol());
TypeDefinitionField field = encoder.getField(feature.getName());
if(transformer.getToLowercase()){
Apply apply = PMMLUtil.createApply("lowercase", feature.ref());
field = encoder.createDerivedField(FeatureUtil.createName("lowercase", feature), OpType.CATEGORICAL, DataType.STRING, apply);
}
return Collections.<Feature>singletonList(new DocumentFeature(encoder, field, transformer.getPattern()));
}
示例2: toContinuous
import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
public TypeDefinitionField toContinuous(FieldName name){
TypeDefinitionField field = getField(name);
DataType dataType = field.getDataType();
switch(dataType){
case INTEGER:
case FLOAT:
case DOUBLE:
break;
default:
throw new IllegalArgumentException("Field " + name.getValue() + " has data type " + dataType);
}
field.setOpType(OpType.CONTINUOUS);
return field;
}
示例3: toContinuousFeature
import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
@Override
public ContinuousFeature toContinuousFeature(){
PMMLEncoder encoder = ensureEncoder();
TypeDefinitionField field = encoder.getField(getName());
DataType dataType = field.getDataType();
switch(dataType){
case INTEGER:
case FLOAT:
case DOUBLE:
break;
default:
throw new UnsupportedOperationException();
}
field.setOpType(OpType.CONTINUOUS);
return new ContinuousFeature(encoder, field);
}
示例4: createInputValue
import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
static
private FieldValue createInputValue(Field field, MiningField miningField, Object value){
if(value == null){
return null;
}
DataType dataType = field.getDataType();
OpType opType = getOpType(field, miningField);
FieldValue fieldValue = createOrRefine(dataType, opType, value);
if(field instanceof TypeDefinitionField){
return enhance((TypeDefinitionField)field, fieldValue);
}
return fieldValue;
}
示例5: createTargetValue
import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
static
private FieldValue createTargetValue(Field field, MiningField miningField, Target target, Object value){
if(value == null){
return null;
}
DataType dataType = field.getDataType();
OpType opType = getOpType(field, miningField, target);
FieldValue fieldValue = createOrRefine(dataType, opType, value);
if(field instanceof TypeDefinitionField){
return enhance((TypeDefinitionField)field, fieldValue);
}
return fieldValue;
}
示例6: getOrdering
import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
static
private List<?> getOrdering(TypeDefinitionField field, final DataType dataType){
List<Value> values = getValidValues(field);
if(values.isEmpty()){
return null;
}
Function<Value, Object> function = new Function<Value, Object>(){
@Override
public Object apply(Value value){
return TypeUtil.parse(dataType, value.getValue());
}
};
return Lists.newArrayList(Iterables.transform(values, function));
}
示例7: load
import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
@Override
public List<String> load(TypeDefinitionField field){
List<Value> values = getValidValues(field);
Function<Value, String> function = new Function<Value, String>(){
@Override
public String apply(Value value){
String stringValue = value.getValue();
if(stringValue == null){
throw new MissingAttributeException(value, PMMLAttributes.VALUE_VALUE);
}
return stringValue;
}
};
return ImmutableList.copyOf(Iterables.transform(values, function));
}
示例8: buildColumnCategoryMapping
import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
public static Map<Integer, BiMap<String, Integer>> buildColumnCategoryMapping(DataDictionary dictionary) {
Preconditions.checkNotNull(dictionary);
InboundSettings settings = InboundSettings.create(ConfigUtils.getDefaultConfig());
List<String> columnNames = settings.getColumnNames();
Preconditions.checkNotNull(dictionary);
Map<Integer,BiMap<String,Integer>> columnToCategoryNameToIDMapping = Maps.newHashMap();
for (TypeDefinitionField field : dictionary.getDataFields()) {
Collection<Value> values = field.getValues();
if (values != null && !values.isEmpty()) {
String columnName = field.getName().getValue();
int columnNumber = columnNames.indexOf(columnName);
BiMap<String,Integer> categoryNameToID = columnToCategoryNameToIDMapping.get(columnNumber);
if (categoryNameToID == null) {
categoryNameToID = HashBiMap.create();
columnToCategoryNameToIDMapping.put(columnNumber, categoryNameToID);
}
for (Value value : values) {
categoryNameToID.put(value.getValue(), categoryNameToID.size());
}
}
}
return columnToCategoryNameToIDMapping;
}
示例9: buildCategoricalValueEncodings
import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
public static CategoricalValueEncodings buildCategoricalValueEncodings(
DataDictionary dictionary) {
Map<Integer,Collection<String>> indexToValues = new HashMap<>();
List<DataField> dataFields = dictionary.getDataFields();
for (int featureIndex = 0; featureIndex < dataFields.size(); featureIndex++) {
TypeDefinitionField field = dataFields.get(featureIndex);
Collection<Value> values = field.getValues();
if (values != null && !values.isEmpty()) {
Collection<String> categoricalValues = values.stream().map(Value::getValue).collect(Collectors.toList());
indexToValues.put(featureIndex, categoricalValues);
}
}
return new CategoricalValueEncodings(indexToValues);
}
示例10: getField
import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
public TypeDefinitionField getField(FieldName name){
DataField dataField = getDataField(name);
DerivedField derivedField = getDerivedField(name);
if(dataField != null && derivedField == null){
return dataField;
} else
if(dataField == null && derivedField != null){
return derivedField;
}
throw new IllegalArgumentException(name.getValue());
}
示例11: resolveField
import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
protected TypeDefinitionField resolveField(FieldName name){
TypeDefinitionField result = getDataField(name);
if(result == null){
result = resolveDerivedField(name);
}
return result;
}
示例12: getOutputExpression
import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
private Expression getOutputExpression(NeuralOutput neuralOutput){
DerivedField derivedField = neuralOutput.getDerivedField();
if(derivedField == null){
throw new MissingElementException(neuralOutput, PMMLElements.NEURALOUTPUT_DERIVEDFIELD);
}
Expression expression = ExpressionUtil.ensureExpression(derivedField);
if(expression instanceof FieldRef){
FieldRef fieldRef = (FieldRef)expression;
FieldName name = fieldRef.getField();
if(name == null){
throw new MissingAttributeException(fieldRef, PMMLAttributes.FIELDREF_FIELD);
}
TypeDefinitionField field = resolveField(name);
if(field == null){
throw new MissingFieldException(name, fieldRef);
} // End if
if(field instanceof DataField){
return expression;
} else
if(field instanceof DerivedField){
DerivedField targetDerivedField = (DerivedField)field;
Expression targetExpression = ExpressionUtil.ensureExpression(targetDerivedField);
return targetExpression;
} else
{
throw new InvalidAttributeException(fieldRef, PMMLAttributes.FIELDREF_FIELD, name);
}
}
return expression;
}
示例13: create
import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
static
public FieldValue create(Field field, Object value){
FieldValue result = create(field.getDataType(), field.getOpType(), value);
if(field instanceof TypeDefinitionField){
return enhance((TypeDefinitionField)field, result);
}
return result;
}
示例14: refine
import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
static
public FieldValue refine(Field field, FieldValue value){
FieldValue result = refine(field.getDataType(), field.getOpType(), value);
if((field instanceof TypeDefinitionField) && (result != value)){
return enhance((TypeDefinitionField)field, result);
}
return result;
}
示例15: enhance
import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
static
private FieldValue enhance(TypeDefinitionField field, FieldValue value){
if(value instanceof OrdinalValue){
OrdinalValue ordinalValue = (OrdinalValue)value;
ordinalValue.setOrdering(getOrdering(field, ordinalValue.getDataType()));
}
return value;
}