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


Java ModelEvaluator类代码示例

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


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

示例1: newModelEvaluator

import org.jpmml.evaluator.ModelEvaluator; //导入依赖的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

示例2: init

import org.jpmml.evaluator.ModelEvaluator; //导入依赖的package包/类
@Override
public StructField init(Evaluator evaluator){
	OutputField field = getField();

	DataType dataType = field.getDataType();
	if(dataType == null){

		try {
			dataType = OutputUtil.getDataType(field.getOutputField(), (ModelEvaluator<?>)evaluator);

			this.formatString = false;
		} catch(PMMLException pe){
			dataType = DataType.STRING;

			this.formatString = true;
		}
	}

	return DataTypes.createStructField(getColumnName(), SchemaUtil.translateDataType(dataType), false);
}
 
开发者ID:jeremyore,项目名称:spark-pmml-import,代码行数:21,代码来源:OutputColumnProducer.java

示例3: doGetOutputFieldsForPMMLStream

import org.jpmml.evaluator.ModelEvaluator; //导入依赖的package包/类
private List<MLModelField> doGetOutputFieldsForPMMLStream(String pmmlContents) throws SAXException, JAXBException {
    List<MLModelField> fieldNames = new ArrayList<>();
    PMMLManager pmmlManager = new PMMLManager(IOUtil.unmarshal(new ByteArrayInputStream(pmmlContents.getBytes())));
    Evaluator modelEvaluator = (ModelEvaluator<?>) pmmlManager.getModelManager(null, ModelEvaluatorFactory.getInstance());
    modelEvaluator.getPredictedFields().forEach((f) -> fieldNames.add(getModelField(modelEvaluator.getDataField(f))));

    modelEvaluator.getOutputFields().forEach((f) -> {
        OutputField outputField = modelEvaluator.getOutputField(f);
        ResultFeatureType resultFeatureType = outputField.getFeature();
        if (resultFeatureType != ResultFeatureType.PREDICTED_VALUE &&
                resultFeatureType != ResultFeatureType.PREDICTED_DISPLAY_VALUE) {
            fieldNames.add(getModelField(outputField));
        }
    });

    return fieldNames;
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:18,代码来源:MLModelRegistryService.java

示例4: doGetOutputFieldsForPMMLStream

import org.jpmml.evaluator.ModelEvaluator; //导入依赖的package包/类
private List<MLModelField> doGetOutputFieldsForPMMLStream(String pmmlContents) throws SAXException, JAXBException, UnsupportedEncodingException {
    List<MLModelField> fieldNames = new ArrayList<>();
    PMMLManager pmmlManager = new PMMLManager(IOUtil.unmarshal(new ByteArrayInputStream(pmmlContents.getBytes("UTF-8"))));
    Evaluator modelEvaluator = (ModelEvaluator<?>) pmmlManager.getModelManager(null, ModelEvaluatorFactory.getInstance());
    modelEvaluator.getPredictedFields().forEach((f) -> fieldNames.add(getModelField(modelEvaluator.getDataField(f))));

    modelEvaluator.getOutputFields().forEach((f) -> {
        OutputField outputField = modelEvaluator.getOutputField(f);
        ResultFeatureType resultFeatureType = outputField.getFeature();
        if (resultFeatureType != ResultFeatureType.PREDICTED_VALUE &&
                resultFeatureType != ResultFeatureType.PREDICTED_DISPLAY_VALUE) {
            fieldNames.add(getModelField(outputField));
        }
    });

    return fieldNames;
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:18,代码来源:MLModelRegistryService.java

示例5: SegmentHandler

import org.jpmml.evaluator.ModelEvaluator; //导入依赖的package包/类
private SegmentHandler(ModelEvaluator<?> modelEvaluator){
	setModelEvaluator(modelEvaluator);

	boolean compatible = true;

	List<InputField> inputFields = modelEvaluator.getInputFields();
	for(InputField inputField : inputFields){
		Field field = inputField.getField();

		if(field instanceof DataField){
			MiningField miningField = inputField.getMiningField();

			compatible &= MiningFieldUtil.isDefault(miningField);
		}
	}

	setCompatible(compatible);
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:19,代码来源:MiningModelEvaluator.java

示例6: evaluate

import org.jpmml.evaluator.ModelEvaluator; //导入依赖的package包/类
@Test
public void evaluate() throws Exception {
	ModelEvaluator<?> evaluator = createModelEvaluator();

	Map<FieldName, ?> arguments = createArguments("Integer", null, "Double", 76.45d);

	Map<FieldName, ?> result = evaluator.evaluate(arguments);

	NodeScoreDistribution<?> targetValue = (NodeScoreDistribution<?>)result.get(evaluator.getTargetFieldName());

	assertEquals("Result1", targetValue.getResult());
	assertEquals("10", targetValue.getEntityId());

	assertEquals(21d / 42d, targetValue.getProbability("Result1"), 1e-8);
	assertEquals(15d / 42d, targetValue.getProbability("Result2"), 1e-8);
	assertEquals(6d / 42d, targetValue.getProbability("Result3"), 1e-8);
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:18,代码来源:DefaultChildTest.java

示例7: evaluate

import org.jpmml.evaluator.ModelEvaluator; //导入依赖的package包/类
@Test
public void evaluate() throws Exception {
	ModelEvaluator<?> evaluator = createModelEvaluator();

	Map<FieldName, ?> arguments = createArguments("item", Arrays.asList("Cracker", "Coke"));

	Map<FieldName, ?> result = evaluator.evaluate(arguments);

	assertEquals("1", getOutput(result, "entityId"));

	checkValue(Arrays.asList("Cracker"), result, "antecedent");
	checkValue(Arrays.asList("Water"), result, "consequent");

	checkValue("{Cracker}->{Water}", result, "rule");
	checkValue("1", result, "ruleId");

	checkValue(1d, result, "support");
	checkValue(1d, result, "confidence");
	checkValue(1d, result, "lift");
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:21,代码来源:AssociationOutputTest.java

示例8: evaluate

import org.jpmml.evaluator.ModelEvaluator; //导入依赖的package包/类
@Test
public void evaluate() throws Exception {
	ModelEvaluator<?> evaluator = createModelEvaluator();

	Map<FieldName, ?> arguments = createArguments("input", 4d);

	Map<FieldName, ?> result = evaluator.evaluate(arguments);

	assertEquals(8d, getTarget(result, "result"));

	assertEquals(8d, getOutput(result, "RawResult"));
	assertEquals(8, getOutput(result, "RawIntegerResult"));
	assertEquals(35d, getOutput(result, "FinalResult"));
	assertEquals(35, getOutput(result, "FinalIntegerResult"));
	assertEquals("waive", getOutput(result, "BusinessDecision"));
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:17,代码来源:RegressionOutputTest.java

示例9: load

import org.jpmml.evaluator.ModelEvaluator; //导入依赖的package包/类
@SuppressWarnings (
	value = {"resource"}
)
public Model load(InputStream is) throws Exception {
	CountingInputStream countingIs = new CountingInputStream(is);

	HashingInputStream hashingIs = new HashingInputStream(Hashing.md5(), countingIs);

	ModelEvaluator<?> evaluator = unmarshal(hashingIs, this.validate);

	PMML pmml = evaluator.getPMML();

	for(Class<? extends Visitor> visitorClazz : this.visitorClazzes){
		Visitor visitor = visitorClazz.newInstance();

		visitor.applyTo(pmml);
	}

	evaluator.verify();

	Model model = new Model(evaluator);
	model.putProperty(Model.PROPERTY_FILE_SIZE, countingIs.getCount());
	model.putProperty(Model.PROPERTY_FILE_MD5SUM, (hashingIs.hash()).toString());

	return model;
}
 
开发者ID:openscoring,项目名称:openscoring,代码行数:27,代码来源:ModelRegistry.java

示例10: createEvaluator

import org.jpmml.evaluator.ModelEvaluator; //导入依赖的package包/类
static
public Evaluator createEvaluator(InputStream is) throws SAXException, JAXBException {
	Source source = ImportFilter.apply(new InputSource(is));

	PMML pmml = JAXBUtil.unmarshalPMML(source);

	// If the SAX Locator information is available, then transform it to java.io.Serializable representation
	LocatorTransformer locatorTransformer = new LocatorTransformer();
	locatorTransformer.applyTo(pmml);

	ModelEvaluatorFactory modelEvaluatorFactory = ModelEvaluatorFactory.newInstance();

	ModelEvaluator<?> modelEvaluator = modelEvaluatorFactory.newModelManager(pmml);
	modelEvaluator.verify();

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

示例11: createEvaluator

import org.jpmml.evaluator.ModelEvaluator; //导入依赖的package包/类
static
public Evaluator createEvaluator(InputStream is) throws Exception {
	PMML pmml = SerializationUtil.deserializePMML(is);

	ModelEvaluatorFactory modelEvaluatorFactory = ModelEvaluatorFactory.newInstance();

	ModelEvaluator<?> modelEvaluator = modelEvaluatorFactory.newModelEvaluator(pmml);
	modelEvaluator.verify();

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

示例12: doGetInputFieldsFromPMMLStream

import org.jpmml.evaluator.ModelEvaluator; //导入依赖的package包/类
private List<MLModelField> doGetInputFieldsFromPMMLStream(String pmmlContents) throws SAXException, JAXBException {
    final List<MLModelField> fieldNames = new ArrayList<>();
    PMMLManager pmmlManager = new PMMLManager(IOUtil.unmarshal(new ByteArrayInputStream(pmmlContents.getBytes())));
    Evaluator modelEvaluator = (ModelEvaluator<?>) pmmlManager.getModelManager(null, ModelEvaluatorFactory.getInstance());
    for (FieldName predictedField : modelEvaluator.getActiveFields()) {
        fieldNames.add(getModelField(modelEvaluator.getDataField(predictedField)));
    }
    return fieldNames;
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:10,代码来源:MLModelRegistryService.java

示例13: doGetInputFieldsFromPMMLStream

import org.jpmml.evaluator.ModelEvaluator; //导入依赖的package包/类
private List<MLModelField> doGetInputFieldsFromPMMLStream(String pmmlContents) throws SAXException, JAXBException, UnsupportedEncodingException {
    final List<MLModelField> fieldNames = new ArrayList<>();
    PMMLManager pmmlManager = new PMMLManager(IOUtil.unmarshal(new ByteArrayInputStream(pmmlContents.getBytes("UTF-8"))));
    Evaluator modelEvaluator = (ModelEvaluator<?>) pmmlManager.getModelManager(null, ModelEvaluatorFactory.getInstance());
    for (FieldName predictedField: modelEvaluator.getActiveFields()) {
        fieldNames.add(getModelField(modelEvaluator.getDataField(predictedField)));
    }
    return fieldNames;
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:10,代码来源:MLModelRegistryService.java

示例14: createNestedOutputFields

import org.jpmml.evaluator.ModelEvaluator; //导入依赖的package包/类
private List<OutputField> createNestedOutputFields(List<Segment> segments){
	List<OutputField> result = new ArrayList<>();

	BiMap<String, Segment> entityRegistry = getEntityRegistry();

	for(int i = 0, max = segments.size(); i < max; i++){
		Segment segment = segments.get(i);

		Model model = segment.getModel();
		if(model == null){
			throw new MissingElementException(MissingElementException.formatMessage(XPathUtil.formatElement(segment.getClass()) + "/<Model>"), segment);
		}

		String segmentId = EntityUtil.getId(segment, entityRegistry);

		SegmentHandler segmentHandler = this.segmentHandlers.get(segmentId);
		if(segmentHandler == null){
			segmentHandler = createSegmentHandler(model);

			this.segmentHandlers.putIfAbsent(segmentId, segmentHandler);
		}

		ModelEvaluator<?> modelEvaluator = segmentHandler.getModelEvaluator();

		List<OutputField> outputFields = modelEvaluator.getOutputFields();
		for(OutputField outputField : outputFields){
			OutputField nestedOutputField = new OutputField(outputField);

			result.add(nestedOutputField);
		}
	}

	return ImmutableList.copyOf(result);
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:35,代码来源:MiningModelEvaluator.java

示例15: createSegmentHandler

import org.jpmml.evaluator.ModelEvaluator; //导入依赖的package包/类
private SegmentHandler createSegmentHandler(Model model){
	ModelEvaluatorFactory modelEvaluatorFactory = getModelEvaluatorFactory();

	if(modelEvaluatorFactory == null){
		modelEvaluatorFactory = ModelEvaluatorFactory.newInstance();
	}

	ModelEvaluator<?> modelEvaluator = modelEvaluatorFactory.newModelEvaluator(getPMML(), model);

	return new SegmentHandler(modelEvaluator);
}
 
开发者ID:jpmml,项目名称:jpmml-evaluator,代码行数:12,代码来源:MiningModelEvaluator.java


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