/** * @param model {@link KMeansModel} to translate to PMML * @return PMML representation of a KMeans cluster model */ private PMML kMeansModelToPMML(KMeansModel model, Map<Integer,Long> clusterSizesMap) { ClusteringModel clusteringModel = pmmlClusteringModel(model, clusterSizesMap); PMML pmml = PMMLUtils.buildSkeletonPMML(); pmml.setDataDictionary(AppPMMLUtils.buildDataDictionary(inputSchema, null)); pmml.addModels(clusteringModel); return pmml; }
public static PMML buildDummyModel() { Node node = new Node().setRecordCount(123.0); TreeModel treeModel = new TreeModel(MiningFunction.CLASSIFICATION, null, node); PMML pmml = PMMLUtils.buildSkeletonPMML(); pmml.addModels(treeModel); return pmml; }
private static PMML buildDummyModel() { Node node = new Node().setRecordCount(123.0); TreeModel treeModel = new TreeModel(MiningFunction.CLASSIFICATION, null, node); PMML pmml = PMMLUtils.buildSkeletonPMML(); pmml.addModels(treeModel); return pmml; }
pmml.addModels(model);
clusters.add(new Cluster().setId("2").setSize(3).setArray(AppPMMLUtils.toArray(-1.0, 0.0))); pmml.addModels(new ClusteringModel( MiningFunction.CLUSTERING, ClusteringModel.ModelClass.CENTER_BASED,
.setMiningSchema(miningSchema); pmml.addModels(treeModel);
@Test public void inspectTypeAnnotations(){ PMML pmml = createPMML(); assertVersionRange(pmml, Version.PMML_3_0, Version.PMML_4_3); pmml.addModels(new AssociationModel(), //new ClusteringModel(), //new GeneralRegressionModel(), //new MiningModel(), new NaiveBayesModel(), new NeuralNetwork(), new RegressionModel(), new RuleSetModel(), new SequenceModel(), //new SupportVectorMachineModel(), new TextModel(), new TreeModel()); assertVersionRange(pmml, Version.PMML_3_0, Version.PMML_4_3); pmml.addModels(new TimeSeriesModel()); assertVersionRange(pmml, Version.PMML_4_0, Version.PMML_4_3); pmml.addModels(new BaselineModel(), new Scorecard(), new NearestNeighborModel()); assertVersionRange(pmml, Version.PMML_4_1, Version.PMML_4_3); pmml.addModels(new BayesianNetworkModel(), new GaussianProcessModel()); assertVersionRange(pmml, Version.PMML_4_3, Version.PMML_4_3); }
@Test public void inspectFieldAnnotations(){ PMML pmml = createPMML(); AssociationModel model = new AssociationModel(); pmml.addModels(model); assertVersionRange(pmml, Version.PMML_3_0, Version.PMML_4_3); Output output = new Output(); model.setOutput(output); assertVersionRange(pmml, Version.PMML_4_0, Version.PMML_4_3); model.setScorable(Boolean.FALSE); assertVersionRange(pmml, Version.PMML_4_1, Version.PMML_4_3); model.setScorable(null); assertVersionRange(pmml, Version.PMML_4_0, Version.PMML_4_3); OutputField outputField = new OutputField() .setRuleFeature(OutputField.RuleFeature.AFFINITY); output.addOutputFields(outputField); assertVersionRange(pmml, Version.PMML_4_1, Version.PMML_4_2); outputField.setDataType(DataType.DOUBLE); assertVersionRange(pmml, Version.PMML_4_1, Version.PMML_4_3); model.setOutput(null); assertVersionRange(pmml, Version.PMML_3_0, Version.PMML_4_3); }
@Test public void inspectValueAnnotations(){ PMML pmml = createPMML(); FieldName name = FieldName.create("y"); Target target = new Target() .setField(name) .addTargetValues(createTargetValue("no event"), createTargetValue("event")); Targets targets = new Targets() .addTargets(target); GeneralRegressionModel model = new GeneralRegressionModel() .setTargets(targets); pmml.addModels(model); assertVersionRange(pmml, Version.PMML_3_0, Version.PMML_3_0); PPMatrix ppMatrix = new PPMatrix() .addPPCells(new PPCell(), new PPCell()); model.setPPMatrix(ppMatrix); assertVersionRange(pmml, Version.PMML_3_0, Version.PMML_4_3); target.setField(null); assertVersionRange(pmml, Version.PMML_4_3, Version.PMML_4_3); }
@Test public void copyState(){ PMML pmml = new PMML(Version.PMML_4_3.getVersion(), new Header(), new DataDictionary()); // Initialize the live list instance pmml.getModels(); CustomPMML customPmml = new CustomPMML(); ReflectionUtil.copyState(pmml, customPmml); assertSame(pmml.getVersion(), customPmml.getVersion()); assertSame(pmml.getHeader(), customPmml.getHeader()); assertSame(pmml.getDataDictionary(), customPmml.getDataDictionary()); assertFalse(pmml.hasModels()); assertFalse(customPmml.hasModels()); pmml.addModels(new RegressionModel()); assertTrue(pmml.hasModels()); assertTrue(customPmml.hasModels()); assertSame(pmml.getModels(), customPmml.getModels()); try { ReflectionUtil.copyState(customPmml, pmml); fail(); } catch(IllegalArgumentException iae){ // Ignored } }
.addModels(treeModel);
.addModels(treeModel);