本文整理汇总了Java中org.dmg.pmml.PMML.getDataDictionary方法的典型用法代码示例。如果您正苦于以下问题:Java PMML.getDataDictionary方法的具体用法?Java PMML.getDataDictionary怎么用?Java PMML.getDataDictionary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dmg.pmml.PMML
的用法示例。
在下文中一共展示了PMML.getDataDictionary方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validatePMMLVsSchema
import org.dmg.pmml.PMML; //导入方法依赖的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)));
}
示例2: popParent
import org.dmg.pmml.PMML; //导入方法依赖的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;
}
示例3: validatePMMLVsSchema
import org.dmg.pmml.PMML; //导入方法依赖的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);
}
}
示例4: encodePMML
import org.dmg.pmml.PMML; //导入方法依赖的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;
}
示例5: visit
import org.dmg.pmml.PMML; //导入方法依赖的package包/类
@Override
public VisitorAction visit(PMML pmml){
DataDictionary dataDictionary = pmml.getDataDictionary();
if(dataDictionary != null && dataDictionary.hasDataFields()){
declare(pmml, dataDictionary.getDataFields());
}
TransformationDictionary transformationDictionary = pmml.getTransformationDictionary();
if(transformationDictionary != null && transformationDictionary.hasDerivedFields()){
declare(pmml, transformationDictionary.getDerivedFields());
}
return super.visit(pmml);
}
示例6: cleanChained
import org.dmg.pmml.PMML; //导入方法依赖的package包/类
@Test
public void cleanChained() throws Exception {
PMML pmml = ResourceUtil.unmarshal(ChainedSegmentationTest.class);
DataDictionary dataDictionary = pmml.getDataDictionary();
checkFields(FieldNameUtil.create("y", "x1", "x2", "x3", "x4"), dataDictionary.getDataFields());
DataDictionaryCleaner cleaner = new DataDictionaryCleaner();
cleaner.applyTo(pmml);
checkFields(FieldNameUtil.create("y", "x1", "x2", "x3"), dataDictionary.getDataFields());
List<Model> models = pmml.getModels();
models.clear();
cleaner.applyTo(pmml);
checkFields(Collections.<FieldName>emptySet(), dataDictionary.getDataFields());
}
示例7: cleanNested
import org.dmg.pmml.PMML; //导入方法依赖的package包/类
@Test
public void cleanNested() throws Exception {
PMML pmml = ResourceUtil.unmarshal(NestedSegmentationTest.class);
DataDictionary dataDictionary = pmml.getDataDictionary();
checkFields(FieldNameUtil.create("y", "x1", "x2", "x3", "x4", "x5"), dataDictionary.getDataFields());
DataDictionaryCleaner cleaner = new DataDictionaryCleaner();
cleaner.applyTo(pmml);
checkFields(FieldNameUtil.create("x1", "x2", "x3", "x4", "x5"), dataDictionary.getDataFields());
List<Model> models = pmml.getModels();
models.clear();
cleaner.applyTo(pmml);
checkFields(Collections.<FieldName>emptySet(), dataDictionary.getDataFields());
}
示例8: ModelEvaluator
import org.dmg.pmml.PMML; //导入方法依赖的package包/类
protected ModelEvaluator(PMML pmml, M model){
setPMML(Objects.requireNonNull(pmml));
setModel(Objects.requireNonNull(model));
DataDictionary dataDictionary = pmml.getDataDictionary();
if(dataDictionary == null){
throw new MissingElementException(pmml, PMMLElements.PMML_DATADICTIONARY);
} // End if
if(dataDictionary.hasDataFields()){
this.dataFields = CacheUtil.getValue(dataDictionary, ModelEvaluator.dataFieldCache);
}
TransformationDictionary transformationDictionary = pmml.getTransformationDictionary();
if(transformationDictionary != null && transformationDictionary.hasDerivedFields()){
this.derivedFields = CacheUtil.getValue(transformationDictionary, ModelEvaluator.derivedFieldCache);
} // End if
if(transformationDictionary != null && transformationDictionary.hasDefineFunctions()){
this.defineFunctions = CacheUtil.getValue(transformationDictionary, ModelEvaluator.defineFunctionCache);
}
MiningFunction miningFunction = model.getMiningFunction();
if(miningFunction == null){
throw new MissingAttributeException(MissingAttributeException.formatMessage(XPathUtil.formatElement(model.getClass()) + "@miningFunction"), model);
}
MiningSchema miningSchema = model.getMiningSchema();
if(miningSchema == null){
throw new MissingElementException(MissingElementException.formatMessage(XPathUtil.formatElement(model.getClass()) + "/" + XPathUtil.formatElement(MiningSchema.class)), model);
} // End if
if(miningSchema.hasMiningFields()){
this.miningFields = CacheUtil.getValue(miningSchema, ModelEvaluator.miningFieldCache);
}
LocalTransformations localTransformations = model.getLocalTransformations();
if(localTransformations != null && localTransformations.hasDerivedFields()){
this.localDerivedFields = CacheUtil.getValue(localTransformations, ModelEvaluator.localDerivedFieldCache);
}
Targets targets = model.getTargets();
if(targets != null && targets.hasTargets()){
this.targets = CacheUtil.getValue(targets, ModelEvaluator.targetCache);
}
Output output = model.getOutput();
if(output != null && output.hasOutputFields()){
this.outputFields = CacheUtil.getValue(output, ModelEvaluator.outputFieldCache);
}
}
示例9: processRegressionModel
import org.dmg.pmml.PMML; //导入方法依赖的package包/类
private void processRegressionModel(Model model){
PMML pmml = getPMML();
MiningField miningField = getTargetField(model);
if(miningField == null){
return;
}
FieldName name = miningField.getName();
DataDictionary dataDictionary = pmml.getDataDictionary();
DataField dataField = IndexableUtil.find(dataDictionary.getDataFields(), name);
if(dataField == null){
throw new MissingFieldException(name, miningField);
}
DataType dataType = dataField.getDataType();
switch(dataType){
case INTEGER:
break;
case FLOAT:
case DOUBLE:
return;
default:
throw new UnsupportedAttributeException(dataField, dataType);
}
Targets targets = model.getTargets();
if(targets != null){
Target target = IndexableUtil.find(targets.getTargets(), name);
if(target != null){
if(target.getCastInteger() != null){
return;
} else
{
target.setCastInteger(getCastInteger());
}
} else
{
targets.addTargets(createTarget(name));
}
} else
{
targets = new Targets()
.addTargets(createTarget(name));
model.setTargets(targets);
}
}