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


Java Model.getMiningSchema方法代码示例

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


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

示例1: validatePMMLVsSchema

import org.dmg.pmml.Model; //导入方法依赖的package包/类
/**
 * Validates that the encoded PMML model received matches expected schema.
 *
 * @param pmml {@link PMML} encoding of KMeans Clustering
 * @param schema expected schema attributes of KMeans Clustering
 */
public static void validatePMMLVsSchema(PMML pmml, InputSchema schema) {
  List<Model> models = pmml.getModels();
  Preconditions.checkArgument(models.size() == 1,
      "Should have exactly one model, but had %s", models.size());

  Model model = models.get(0);
  Preconditions.checkArgument(model instanceof ClusteringModel);
  Preconditions.checkArgument(model.getMiningFunction() == MiningFunction.CLUSTERING);

  DataDictionary dictionary = pmml.getDataDictionary();
  Preconditions.checkArgument(
      schema.getFeatureNames().equals(AppPMMLUtils.getFeatureNames(dictionary)),
      "Feature names in schema don't match names in PMML");

  MiningSchema miningSchema = model.getMiningSchema();
  Preconditions.checkArgument(schema.getFeatureNames().equals(
      AppPMMLUtils.getFeatureNames(miningSchema)));

}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:26,代码来源:KMeansPMMLUtils.java

示例2: getTargetField

import org.dmg.pmml.Model; //导入方法依赖的package包/类
static
private MiningField getTargetField(Model model){
	MiningSchema miningSchema = model.getMiningSchema();

	MiningField result = null;

	List<MiningField> miningFields = miningSchema.getMiningFields();
	for(MiningField miningField : miningFields){
		MiningField.UsageType usageType = miningField.getUsageType();

		switch(usageType){
			case TARGET:
			case PREDICTED:
				if(result != null){
					throw new UnsupportedElementException(miningSchema);
				}
				result = miningField;
				break;
			default:
				break;
		}
	}

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

示例3: validatePMMLVsSchema

import org.dmg.pmml.Model; //导入方法依赖的package包/类
/**
 * Validates that the encoded PMML model received matches expected schema.
 *
 * @param pmml {@link PMML} encoding of a decision forest
 * @param schema expected schema attributes of decision forest
 */
public static void validatePMMLVsSchema(PMML pmml, InputSchema schema) {
  List<Model> models = pmml.getModels();
  Preconditions.checkArgument(models.size() == 1,
                              "Should have exactly one model, but had %s", models.size());

  Model model = models.get(0);
  MiningFunction function = model.getMiningFunction();
  if (schema.isClassification()) {
    Preconditions.checkArgument(function == MiningFunction.CLASSIFICATION,
                                "Expected classification function type but got %s",
                                function);
  } else {
    Preconditions.checkArgument(function == MiningFunction.REGRESSION,
                                "Expected regression function type but got %s",
                                function);
  }

  DataDictionary dictionary = pmml.getDataDictionary();
  Preconditions.checkArgument(
      schema.getFeatureNames().equals(AppPMMLUtils.getFeatureNames(dictionary)),
      "Feature names in schema don't match names in PMML");

  MiningSchema miningSchema = model.getMiningSchema();
  Preconditions.checkArgument(schema.getFeatureNames().equals(
      AppPMMLUtils.getFeatureNames(miningSchema)));

  Integer pmmlIndex = AppPMMLUtils.findTargetIndex(miningSchema);
  if (schema.hasTarget()) {
    int schemaIndex = schema.getTargetFeatureIndex();
    Preconditions.checkArgument(
        pmmlIndex != null && schemaIndex == pmmlIndex,
        "Configured schema expects target at index %s, but PMML has target at index %s",
        schemaIndex, pmmlIndex);
  } else {
    Preconditions.checkArgument(pmmlIndex == null);
  }
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:44,代码来源:RDFPMMLUtils.java

示例4: extractTargetField

import org.dmg.pmml.Model; //导入方法依赖的package包/类
static
private FieldName extractTargetField(Model model){
	FieldName targetField = null;

	MiningSchema miningSchema = model.getMiningSchema();

	List<MiningField> miningFields = miningSchema.getMiningFields();
	for(Iterator<MiningField> it = miningFields.iterator(); it.hasNext(); ){
		MiningField miningField = it.next();

		FieldUsageType fieldUsage = miningField.getUsageType();
		switch(fieldUsage){
			case PREDICTED:
			case TARGET:
				{
					if(targetField != null){
						throw new IllegalArgumentException();
					}

					targetField = miningField.getName();

					it.remove();
				}
				break;
			default:
				break;
		}
	}

	return targetField;
}
 
开发者ID:vruusmann,项目名称:jpmml-toolkit,代码行数:32,代码来源:Aggregator.java

示例5: encodePMML

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

	pmml.addModels(model);

	List<? extends Visitor> visitors = Arrays.asList(new MiningSchemaCleaner(), new TransformationDictionaryCleaner(), new DataDictionaryCleaner());
	for(Visitor visitor : visitors){
		visitor.applyTo(pmml);
	}

	MiningSchema miningSchema = model.getMiningSchema();

	List<MiningField> miningFields = miningSchema.getMiningFields();
	for(MiningField miningField : miningFields){
		FieldName name = miningField.getName();

		List<Decorator> decorators = getDecorators(name);
		if(decorators == null){
			continue;
		}

		DataField dataField = getDataField(name);
		if(dataField == null){
			throw new IllegalArgumentException();
		}

		for(Decorator decorator : decorators){
			decorator.decorate(dataField, miningField);
		}
	}

	Collection<Map.Entry<FieldName, FieldName>> entries = this.renamedFields.entrySet();
	for(Map.Entry<FieldName, FieldName> entry : entries){
		FieldRenamer renamer = new FieldRenamer(entry.getKey(), entry.getValue());

		renamer.applyTo(pmml);
	}

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

示例6: processModel

import org.dmg.pmml.Model; //导入方法依赖的package包/类
private void processModel(Model model){
	Set<Field> targetFields = getTargetFields();

	MiningSchema miningSchema = model.getMiningSchema();
	if(miningSchema != null && miningSchema.hasMiningFields()){
		Set<FieldName> targetFieldNames = new LinkedHashSet<>();

		List<MiningField> miningFields = miningSchema.getMiningFields();
		for(MiningField miningField : miningFields){
			FieldName name = miningField.getName();

			MiningField.UsageType usageType = miningField.getUsageType();
			switch(usageType){
				case TARGET:
				case PREDICTED:
					targetFieldNames.add(name);
					break;
				default:
					break;
			}
		}

		if(targetFieldNames.size() > 0){
			Set<Field> modelFields = getFields(model);

			targetFields.addAll(FieldUtil.selectAll(modelFields, targetFieldNames));
		}
	}
}
 
开发者ID:jpmml,项目名称:jpmml-model,代码行数:30,代码来源:DataDictionaryCleaner.java

示例7: processMiningModel

import org.dmg.pmml.Model; //导入方法依赖的package包/类
private Set<FieldName> processMiningModel(MiningModel miningModel){
	Set<Field> activeFields = DeepFieldResolverUtil.getActiveFields(this, miningModel);

	Set<FieldName> activeFieldNames = new HashSet<>();

	Segmentation segmentation = miningModel.getSegmentation();

	List<Segment> segments = segmentation.getSegments();
	for(Segment segment : segments){
		Model model = segment.getModel();

		if(model == null){
			continue;
		}

		MiningSchema miningSchema = model.getMiningSchema();

		List<MiningField> miningFields = miningSchema.getMiningFields();
		for(MiningField miningField : miningFields){
			FieldName name = miningField.getName();

			MiningField.UsageType usageType = miningField.getUsageType();
			switch(usageType){
				case ACTIVE:
					activeFieldNames.add(name);
					break;
				default:
					break;
			}
		}
	}

	Set<Field> modelFields = getFields(miningModel);

	Set<Field> activeModelFields = FieldUtil.selectAll(modelFields, activeFieldNames, true);
	activeFields.addAll(activeModelFields);

	expandDerivedFields(miningModel, activeFields);

	return FieldUtil.nameSet(activeFields);
}
 
开发者ID:jpmml,项目名称:jpmml-model,代码行数:42,代码来源:MiningSchemaCleaner.java


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