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


Java Model类代码示例

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


Model类属于org.dmg.pmml包,在下文中一共展示了Model类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createModelChain

import org.dmg.pmml.Model; //导入依赖的package包/类
static
public MiningModel createModelChain(List<? extends Model> models, Schema schema){

	if(models.size() < 1){
		throw new IllegalArgumentException();
	}

	Segmentation segmentation = createSegmentation(Segmentation.MultipleModelMethod.MODEL_CHAIN, models);

	Model lastModel = Iterables.getLast(models);

	MiningModel miningModel = new MiningModel(lastModel.getMiningFunction(), ModelUtil.createMiningSchema(schema.getLabel()))
		.setMathContext(ModelUtil.simplifyMathContext(lastModel.getMathContext()))
		.setSegmentation(segmentation);

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

示例3: encodeModel

import org.dmg.pmml.Model; //导入依赖的package包/类
@Override
public MiningModel encodeModel(Schema schema){
	List<? extends Regressor> estimators = getEstimators();
	List<? extends Number> estimatorWeights = getEstimatorWeights();

	Schema segmentSchema = schema.toAnonymousSchema();

	List<Model> models = new ArrayList<>();

	for(Regressor estimator : estimators){
		Model model = estimator.encodeModel(segmentSchema);

		models.add(model);
	}

	MiningModel miningModel = new MiningModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema.getLabel()))
		.setSegmentation(MiningModelUtil.createSegmentation(MultipleModelMethod.WEIGHTED_MEDIAN, models, estimatorWeights));

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

示例4: transform

import org.dmg.pmml.Model; //导入依赖的package包/类
static
public <E extends Estimator & HasTreeOptions, M extends Model> M transform(E estimator, M model){
	Boolean compact = (Boolean)estimator.getOption(HasTreeOptions.OPTION_COMPACT, Boolean.TRUE);
	Boolean flat = (Boolean)estimator.getOption(HasTreeOptions.OPTION_FLAT, Boolean.FALSE);

	List<Visitor> visitors = new ArrayList<>();

	if(compact){
		visitors.add(new TreeModelCompactor());
	} // End if

	if(flat){
		visitors.add(new TreeModelFlattener());
	}

	for(Visitor visitor : visitors){
		visitor.applyTo(model);
	}

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

示例5: createModelChain

import org.dmg.pmml.Model; //导入依赖的package包/类
static
public MiningModel createModelChain(List<? extends Model> models, Schema schema){

    if(models.size() < 1){
        throw new IllegalArgumentException();
    }

    Segmentation segmentation = createSegmentation(Segmentation.MultipleModelMethod.MODEL_CHAIN, models);

    Model lastModel = Iterables.getLast(models);

    MiningModel miningModel = new MiningModel(lastModel.getMiningFunction(), ModelUtil.createMiningSchema(schema.getLabel()))
            .setMathContext(ModelUtil.simplifyMathContext(lastModel.getMathContext()))
            .setSegmentation(segmentation);

    return miningModel;
}
 
开发者ID:cheng-li,项目名称:pyramid,代码行数:18,代码来源:MiningModelUtil.java

示例6: getActiveFields

import org.dmg.pmml.Model; //导入依赖的package包/类
static
public Set<Field> getActiveFields(DeepFieldResolver resolver, Model model){
	Set<Field> modelFields = getModelFields(resolver, model);

	FieldReferenceFinder fieldReferenceFinder = new FieldReferenceFinder(){

		@Override
		public VisitorAction visit(LocalTransformations localTransformations){
			return VisitorAction.SKIP;
		}
	};
	fieldReferenceFinder.applyTo(model);

	Set<Field> activeFields = FieldUtil.selectAll(modelFields, fieldReferenceFinder.getFieldNames());

	Output output = model.getOutput();
	if(output != null){
		activeFields.removeAll(output.getOutputFields());
	}

	return activeFields;
}
 
开发者ID:jpmml,项目名称:jpmml-model,代码行数:23,代码来源:DeepFieldResolverUtil.java

示例7: popParent

import org.dmg.pmml.Model; //导入依赖的package包/类
@Override
public PMMLObject popParent(){
	PMMLObject parent = super.popParent();

	if(parent instanceof MiningModel){
		MiningModel miningModel = (MiningModel)parent;

		processMiningModel(miningModel);
	} else

	if(parent instanceof Model){
		Model model = (Model)parent;

		processModel(model);
	}

	return parent;
}
 
开发者ID:jpmml,项目名称:jpmml-model,代码行数:19,代码来源:ModelCleaner.java

示例8: popParent

import org.dmg.pmml.Model; //导入依赖的package包/类
@Override
public PMMLObject popParent(){
	PMMLObject parent = super.popParent();

	if(parent instanceof Model){
		Model model = (Model)parent;

		processModel(model);
	} else

	if(parent instanceof PMML){
		PMML pmml = (PMML)parent;

		DataDictionary dataDictionary = pmml.getDataDictionary();
		if(dataDictionary != null){
			processDataDictionary(dataDictionary);
		}
	}

	return parent;
}
 
开发者ID:jpmml,项目名称:jpmml-model,代码行数:22,代码来源:DataDictionaryCleaner.java

示例9: selectModel

import org.dmg.pmml.Model; //导入依赖的package包/类
static
protected <M extends Model> M selectModel(PMML pmml, Class<? extends M> clazz){

	if(!pmml.hasModels()){
		throw new MissingElementException(MissingElementException.formatMessage(XPathUtil.formatElement(pmml.getClass()) + "/" + XPathUtil.formatElement(clazz)), pmml);
	}

	List<Model> models = pmml.getModels();

	Iterable<? extends M> filteredModels = Iterables.filter(models, clazz);

	M model = Iterables.getFirst(filteredModels, null);
	if(model == null){
		throw new MissingElementException(MissingElementException.formatMessage(XPathUtil.formatElement(pmml.getClass()) + "/" + XPathUtil.formatElement(clazz)), pmml);
	}

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

示例10: newModelEvaluator

import org.dmg.pmml.Model; //导入依赖的package包/类
@Override
public ModelEvaluator<? extends Model> newModelEvaluator(PMML pmml, Model model){
	ModelEvaluator<?> modelEvaluator = super.newModelEvaluator(pmml, model);

	if(modelEvaluator instanceof MiningModelEvaluator){
		this.miningModelCount++;
	} else

	if(modelEvaluator instanceof TreeModelEvaluator){
		this.treeModelCount++;
	} else

	{
		throw new AssertionError();
	}

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

示例11: 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

示例12: read

import org.dmg.pmml.Model; //导入依赖的package包/类
/**
 * @param pmml PMML representation of Clusters
 * @return List of {@link ClusterInfo}
 */
public static List<ClusterInfo> read(PMML pmml) {
  Model model = pmml.getModels().get(0);
  Preconditions.checkArgument(model instanceof ClusteringModel);
  ClusteringModel clusteringModel = (ClusteringModel) model;

  return clusteringModel.getClusters().stream().map(cluster ->
    new ClusterInfo(Integer.parseInt(cluster.getId()),
                    VectorMath.parseVector(TextUtils.parseDelimited(cluster.getArray().getValue(), ' ')),
                    cluster.getSize())
  ).collect(Collectors.toList());
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:16,代码来源:KMeansPMMLUtils.java

示例13: 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

示例14: testReadWrite

import org.dmg.pmml.Model; //导入依赖的package包/类
@Test
public void testReadWrite() throws Exception {
  Path tempModelFile = Files.createTempFile(getTempDir(), "model", ".pmml");
  PMML model = buildDummyModel();
  PMMLUtils.write(model, tempModelFile);
  assertTrue(Files.exists(tempModelFile));
  PMML model2 = PMMLUtils.read(tempModelFile);
  List<Model> models = model2.getModels();
  assertEquals(1, models.size());
  assertInstanceOf(models.get(0), TreeModel.class);
  TreeModel treeModel = (TreeModel) models.get(0);
  assertEquals(123.0, treeModel.getNode().getRecordCount().doubleValue());
  assertEquals(MiningFunction.CLASSIFICATION, treeModel.getMiningFunction());
}
 
开发者ID:oncewang,项目名称:oryx2,代码行数:15,代码来源:PMMLUtilsTest.java

示例15: selectModel

import org.dmg.pmml.Model; //导入依赖的package包/类
private Model selectModel(Message<?> input) {
	String modelName = properties.getModelName();
	if (modelName == null && properties.getModelNameExpression() == null) {
		return pmml.getModels().get(0);
	}
	else if (properties.getModelNameExpression() != null) {
		modelName = properties.getModelNameExpression().getValue(evaluationContext, input, String.class);
	}
	for (Model model : pmml.getModels()) {
		if (model.getModelName().equals(modelName)) {
			return model;
		}
	}
	throw new RuntimeException("Unable to use model named '" + modelName + "'");
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:16,代码来源:PmmlProcessorConfiguration.java


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