• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TypeDefinitionField类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.dmg.pmml.TypeDefinitionField的典型用法代码示例。如果您正苦于以下问题:Java TypeDefinitionField类的具体用法?Java TypeDefinitionField怎么用?Java TypeDefinitionField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TypeDefinitionField类属于org.dmg.pmml包,在下文中一共展示了TypeDefinitionField类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()));
}
 
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:25,代码来源:RegexTokenizerConverter.java


示例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;
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:18,代码来源:PMMLEncoder.java


示例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);
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:21,代码来源:CategoricalFeature.java


示例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;
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:19,代码来源:FieldValueUtil.java


示例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;
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:19,代码来源:FieldValueUtil.java


示例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));
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:18,代码来源:FieldValueUtil.java


示例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));
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:20,代码来源:FieldValueUtil.java


示例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;
}
 
开发者ID:apsaltis,项目名称:oryx,代码行数:25,代码来源:PMMLUtils.java


示例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);
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:15,代码来源:AppPMMLUtils.java


示例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());
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:15,代码来源:PMMLEncoder.java


示例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;
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:10,代码来源:ModelEvaluator.java


示例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;
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:41,代码来源:NeuralNetworkEvaluator.java


示例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;
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:11,代码来源:FieldValueUtil.java


示例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;
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:11,代码来源:FieldValueUtil.java


示例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;
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:12,代码来源:FieldValueUtil.java


示例16: getValidValues

import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
static
public List<Value> getValidValues(TypeDefinitionField field){

	if(field.hasValues()){
		List<Value> pmmlValues = field.getValues();

		List<Value> result = new ArrayList<>(pmmlValues.size());

		for(int i = 0, max = pmmlValues.size(); i < max; i++){
			Value pmmlValue = pmmlValues.get(i);

			Value.Property property = pmmlValue.getProperty();
			switch(property){
				case VALID:
					result.add(pmmlValue);
					break;
				case INVALID:
				case MISSING:
					break;
				default:
					throw new UnsupportedAttributeException(pmmlValue, property);
			}
		}

		return result;
	}

	return Collections.emptyList();
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:30,代码来源:FieldValueUtil.java


示例17: encodeFeatures

import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
@Override
public List<Feature> encodeFeatures(SparkMLEncoder encoder){
	ImputerModel transformer = getTransformer();

	Double missingValue = transformer.getMissingValue();
	String strategy = transformer.getStrategy();
	Dataset<Row> surrogateDF = transformer.surrogateDF();

	String[] inputCols = transformer.getInputCols();
	String[] outputCols = transformer.getOutputCols();
	if(inputCols.length != outputCols.length){
		throw new IllegalArgumentException();
	}

	MissingValueTreatmentMethod missingValueTreatmentMethod = parseStrategy(strategy);

	List<Row> surrogateRows = surrogateDF.collectAsList();
	if(surrogateRows.size() != 1){
		throw new IllegalArgumentException();
	}

	Row surrogateRow = surrogateRows.get(0);

	List<Feature> result = new ArrayList<>();

	for(int i = 0; i < inputCols.length; i++){
		String inputCol = inputCols[i];
		String outputCol = outputCols[i];

		Feature feature = encoder.getOnlyFeature(inputCol);

		TypeDefinitionField field = encoder.getField(feature.getName());

		if(field instanceof DataField){
			DataField dataField = (DataField)field;

			Object surrogate = surrogateRow.getAs(inputCol);

			MissingValueDecorator missingValueDecorator = new MissingValueDecorator()
				.setMissingValueReplacement(ValueUtil.formatValue(surrogate))
				.setMissingValueTreatment(missingValueTreatmentMethod);

			if(missingValue != null && !missingValue.isNaN()){
				missingValueDecorator.addValues(ValueUtil.formatValue(missingValue));
			}

			encoder.addDecorator(feature.getName(), missingValueDecorator);
		} else

		{
			throw new IllegalArgumentException();
		}

		result.add(feature);
	}

	return result;
}
 
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:59,代码来源:ImputerModelConverter.java


示例18: encodeFeatures

import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
@Override
public List<Feature> encodeFeatures(SparkMLEncoder encoder){
	StringIndexerModel transformer = getTransformer();

	Feature feature = encoder.getOnlyFeature(transformer.getInputCol());

	List<String> categories = new ArrayList<>();
	categories.addAll(Arrays.asList(transformer.labels()));

	String handleInvalid = transformer.getHandleInvalid();

	TypeDefinitionField field = encoder.toCategorical(feature.getName(), categories);

	if(field instanceof DataField){
		DataField dataField = (DataField)field;

		InvalidValueTreatmentMethod invalidValueTreatmentMethod;

		switch(handleInvalid){
			case "keep":
				invalidValueTreatmentMethod = InvalidValueTreatmentMethod.AS_IS;
				break;
			case "error":
				invalidValueTreatmentMethod = InvalidValueTreatmentMethod.RETURN_INVALID;
				break;
			default:
				throw new IllegalArgumentException(handleInvalid);
		}

		InvalidValueDecorator invalidValueDecorator = new InvalidValueDecorator()
			.setInvalidValueTreatment(invalidValueTreatmentMethod);

		encoder.addDecorator(dataField.getName(), invalidValueDecorator);
	} else

	if(field instanceof DerivedField){
		// Ignored
	} else

	{
		throw new IllegalArgumentException();
	}

	switch(handleInvalid){
		case "keep":
			Apply setApply = PMMLUtil.createApply("isIn", feature.ref());

			for(String category : categories){
				setApply.addExpressions(PMMLUtil.createConstant(category));
			}

			categories.add(StringIndexerModelConverter.LABEL_UNKNOWN);

			Apply apply = PMMLUtil.createApply("if", setApply, feature.ref(), PMMLUtil.createConstant(StringIndexerModelConverter.LABEL_UNKNOWN));

			field = encoder.createDerivedField(FeatureUtil.createName("handleInvalid", feature), OpType.CATEGORICAL, feature.getDataType(), apply);
			break;
		default:
			break;
	}

	return Collections.<Feature>singletonList(new CategoricalFeature(encoder, field, categories));
}
 
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:64,代码来源:StringIndexerModelConverter.java


示例19: DocumentFeature

import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
public DocumentFeature(SparkMLEncoder encoder, TypeDefinitionField field, String wordSeparatorRE){
	super(encoder, field.getName(), field.getDataType());

	setWordSeparatorRE(wordSeparatorRE);
}
 
开发者ID:jpmml,项目名称:jpmml-sparkml,代码行数:6,代码来源:DocumentFeature.java


示例20: InteractionFeature

import org.dmg.pmml.TypeDefinitionField; //导入依赖的package包/类
public InteractionFeature(PMMLEncoder encoder, TypeDefinitionField field, List<? extends Feature> features){
	this(encoder, field.getName(), field.getDataType(), features);
}
 
开发者ID:jpmml,项目名称:jpmml-converter,代码行数:4,代码来源:InteractionFeature.java



注:本文中的org.dmg.pmml.TypeDefinitionField类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RainbowUtil类代码示例发布时间:2022-05-23
下一篇:
Java EntityEnderPearl类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap