### Question:
RDFPMMLUtils { 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); } } private  RDFPMMLUtils(); static void validatePMMLVsSchema(PMML pmml, InputSchema schema); static Pair<DecisionForest,CategoricalValueEncodings> read(PMML pmml);  }### Answer:
@Test public void testValidateClassification() { PMML pmml = buildDummyClassificationModel(); Map<String,Object> overlayConfig = new HashMap<>(); overlayConfig.put("oryx.input-schema.feature-names", "[\"color\",\"fruit\"]"); overlayConfig.put("oryx.input-schema.numeric-features", "[]"); overlayConfig.put("oryx.input-schema.target-feature", "fruit"); Config config = ConfigUtils.overlayOn(overlayConfig, ConfigUtils.getDefault()); InputSchema schema = new InputSchema(config); RDFPMMLUtils.validatePMMLVsSchema(pmml, schema); }
@Test public void testValidateRegression() { PMML pmml = buildDummyRegressionModel(); Map<String,Object> overlayConfig = new HashMap<>(); overlayConfig.put("oryx.input-schema.feature-names", "[\"foo\",\"bar\"]"); overlayConfig.put("oryx.input-schema.categorical-features", "[]"); overlayConfig.put("oryx.input-schema.target-feature", "bar"); Config config = ConfigUtils.overlayOn(overlayConfig, ConfigUtils.getDefault()); InputSchema schema = new InputSchema(config); RDFPMMLUtils.validatePMMLVsSchema(pmml, schema); }