当前位置: 首页>>代码示例>>Java>>正文


Java DataDictionary.getDataFields方法代码示例

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


在下文中一共展示了DataDictionary.getDataFields方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRawDataField

import org.dmg.pmml.DataDictionary; //导入方法依赖的package包/类
public static DataField getRawDataField(DataDictionary dataDictionary, String rawFieldName) {
    // now find the actual dataField
    DataField rawField = null;
    for (DataField dataField : dataDictionary.getDataFields()) {
        String rawDataFieldName = dataField.getName().getValue();
        if (rawDataFieldName.equals(rawFieldName)) {
            rawField = dataField;
            break;
        }
    }
    if (rawField == null) {
        throw new UnsupportedOperationException("Could not trace back {} to a raw input field. Maybe saomething is not implemented " +
                "yet or the PMML file is faulty.");
    }
    return rawField;
}
 
开发者ID:brwe,项目名称:es-token-plugin,代码行数:17,代码来源:ProcessPMMLHelper.java

示例2: findTargetCategories

import org.dmg.pmml.DataDictionary; //导入方法依赖的package包/类
private String[] findTargetCategories(DataDictionary dataDictionary, Map<String, List<PCell>> targetClassPCellMap,
                                      String targetVariable) {
    String[] targetCategories = new String[2];
    String class1 = targetClassPCellMap.keySet().iterator().next();
    targetCategories[0] = class1;
    // find it in the datafields
    for (DataField dataField : dataDictionary.getDataFields()) {
        if (dataField.getName().toString().equals(targetVariable)) {
            for (Value value : dataField.getValues()) {
                String valueString = value.getValue();
                if (valueString.equals(class1) == false) {
                    targetCategories[1] = valueString;
                }
            }
            if (targetCategories[1] == null) {
                throw new ElasticsearchParseException("could not find target class");
            }
            break;
        }
    }
    return targetCategories;
}
 
开发者ID:brwe,项目名称:es-token-plugin,代码行数:23,代码来源:GeneralizedLinearRegressionModelFactory.java

示例3: buildColumnCategoryMapping

import org.dmg.pmml.DataDictionary; //导入方法依赖的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

示例4: getFeatureNames

import org.dmg.pmml.DataDictionary; //导入方法依赖的package包/类
/**
 * @param dictionary {@link DataDictionary} from model
 * @return names of features in order
 */
public static List<String> getFeatureNames(DataDictionary dictionary) {
  List<DataField> dataFields = dictionary.getDataFields();
  Preconditions.checkArgument(dataFields != null && !dataFields.isEmpty(),
                              "No fields in DataDictionary");
  return dataFields.stream().map(field -> field.getName().getValue()).collect(Collectors.toList());
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:11,代码来源:AppPMMLUtils.java

示例5: buildCategoricalValueEncodings

import org.dmg.pmml.DataDictionary; //导入方法依赖的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

示例6: checkDataDictionary

import org.dmg.pmml.DataDictionary; //导入方法依赖的package包/类
protected static void checkDataDictionary(InputSchema schema, DataDictionary dataDictionary) {
  assertNotNull(dataDictionary);
  assertEquals("Wrong number of features",
               schema.getNumFeatures(),
               dataDictionary.getNumberOfFields().intValue());
  List<DataField> dataFields = dataDictionary.getDataFields();
  assertEquals(schema.getNumFeatures(), dataFields.size());
  for (DataField dataField : dataFields) {
    String featureName = dataField.getName().getValue();
    if (schema.isNumeric(featureName)) {
      assertEquals("Wrong op type for feature " + featureName,
                   OpType.CONTINUOUS,
                   dataField.getOpType());
      assertEquals("Wrong data type for feature " + featureName,
                   DataType.DOUBLE,
                   dataField.getDataType());
    } else if (schema.isCategorical(featureName)) {
      assertEquals("Wrong op type for feature " + featureName,
                   OpType.CATEGORICAL,
                   dataField.getOpType());
      assertEquals("Wrong data type for feature " + featureName,
                   DataType.STRING,
                   dataField.getDataType());
    } else {
      assertNull(dataField.getOpType());
      assertNull(dataField.getDataType());
    }
  }
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:30,代码来源:AbstractAppMLlibIT.java

示例7: encodePMML

import org.dmg.pmml.DataDictionary; //导入方法依赖的package包/类
@Override
public PMML encodePMML(Model model){

	if(this.transformers.size() > 0){
		List<Model> models = new ArrayList<>(this.transformers);
		models.add(model);

		Schema schema = new Schema(null, Collections.<Feature>emptyList());

		model = MiningModelUtil.createModelChain(models, schema);
	}

	PMML pmml = super.encodePMML(model);

	DataDictionary dataDictionary = pmml.getDataDictionary();

	List<DataField> dataFields = dataDictionary.getDataFields();
	for(DataField dataField : dataFields){
		UnivariateStats univariateStats = getUnivariateStats(dataField.getName());

		if(univariateStats == null){
			continue;
		}

		ModelStats modelStats = model.getModelStats();
		if(modelStats == null){
			modelStats = new ModelStats();

			model.setModelStats(modelStats);
		}

		modelStats.addUnivariateStats(univariateStats);
	}

	return pmml;
}
 
开发者ID:jpmml,项目名称:jpmml-sklearn,代码行数:37,代码来源:SkLearnEncoder.java

示例8: visit

import org.dmg.pmml.DataDictionary; //导入方法依赖的package包/类
@Override
public VisitorAction visit(DataDictionary dataDictionary){

	if(dataDictionary.hasDataFields()){
		List<DataField> dataFields = dataDictionary.getDataFields();

		for(ListIterator<DataField> it = dataFields.listIterator(); it.hasNext(); ){
			it.set(new RichDataField(it.next()));
		}
	}

	return super.visit(dataDictionary);
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:14,代码来源:FieldOptimizer.java

示例9: processDataDictionary

import org.dmg.pmml.DataDictionary; //导入方法依赖的package包/类
private void processDataDictionary(DataDictionary dataDictionary){

		if(dataDictionary.hasDataFields()){
			List<DataField> dataFields = dataDictionary.getDataFields();

			Set<DataField> usedDataFields = getUsedDataFields();

			dataFields.retainAll(usedDataFields);
		}
	}
 
开发者ID:jpmml,项目名称:jpmml-model,代码行数:11,代码来源:DataDictionaryCleaner.java

示例10: inspect

import org.dmg.pmml.DataDictionary; //导入方法依赖的package包/类
@Test
public void inspect() throws Exception {
	DataDictionary dataDictionary = new DataDictionary()
		.setNumberOfFields(1);

	Field field = ReflectionUtil.getField(DataDictionary.class, "dataFields");

	assertNull(ReflectionUtil.getFieldValue(field, dataDictionary));

	List<DataField> dataFields = dataDictionary.getDataFields();
	assertEquals(0, dataFields.size());

	assertNotNull(ReflectionUtil.getFieldValue(field, dataDictionary));

	PMML pmml = new PMML(null, null, dataDictionary);

	InvalidMarkupInspector inspector = new InvalidMarkupInspector();

	try {
		inspector.applyTo(pmml);

		fail();
	} catch(InvalidMarkupException ife){
		List<InvalidMarkupException> exceptions = inspector.getExceptions();

		String[] features = {"[email protected]", "PMML/Header", "DataDictionary", "DataDictionary/DataField"};

		assertEquals(features.length, exceptions.size());
		assertEquals(0, exceptions.indexOf(ife));

		for(int i = 0; i < exceptions.size(); i++){
			InvalidMarkupException exception = exceptions.get(i);

			String message = exception.getMessage();

			assertTrue(message.contains(features[i]));
		}
	}
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:40,代码来源:InvalidMarkupInspectorTest.java


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