/** * @return {@link PMML} with common {@link Header} fields like {@link Application}, * {@link Timestamp}, and version filled out */ public static PMML buildSkeletonPMML() { String formattedDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZ", Locale.ENGLISH).format(new Date()); Header header = new Header() .setTimestamp(new Timestamp().addContent(formattedDate)) .setApplication(new Application("Oryx")); return new PMML(VERSION, header, null); }
protected static void checkHeader(Header header) { assertNotNull(header); assertNotNull(header.getTimestamp()); assertEquals("Oryx", header.getApplication().getName()); }
@Override public VisitorAction accept(Visitor visitor) { VisitorAction status = visitor.visit(this); if (status == VisitorAction.CONTINUE) { visitor.pushParent(this); if ((status == VisitorAction.CONTINUE)&&hasExtensions()) { status = org.dmg.pmml.PMMLObject.traverse(visitor, getExtensions()); } if (status == VisitorAction.CONTINUE) { status = org.dmg.pmml.PMMLObject.traverse(visitor, getApplication()); } if ((status == VisitorAction.CONTINUE)&&hasAnnotations()) { status = org.dmg.pmml.PMMLObject.traverse(visitor, getAnnotations()); } if (status == VisitorAction.CONTINUE) { status = org.dmg.pmml.PMMLObject.traverse(visitor, getTimestamp()); } visitor.popParent(); } if (status == VisitorAction.TERMINATE) { return VisitorAction.TERMINATE; } return VisitorAction.CONTINUE; }
public PMML build(BasicML basicML) { PMML pmml = new PMML(); Header header = new Header(); pmml.setHeader(header); header.setCopyright(" Copyright [2013-2017] PayPal Software Foundation\n" + "\n" + " Licensed under the Apache License, Version 2.0 (the \"License\");\n" + " you may not use this file except in compliance with the License.\n" + " limitations under the License.\n"); Application application = new Application(); header.setApplication(application);
/** * Create an instance of {@link Header } * */ public Header createHeader() { return new Header(); }
FieldName whatIdo = FieldName.create("whatIDo"); Header header = new Header() .setCopyright("www.dmg.org") .setDescription("A very small binary tree model to show structure.");
static private PMML createPMML(){ Header header = new Header() .setCopyright("ACME Corporation"); DataDictionary dataDictionary = new DataDictionary(); PMML pmml = new PMML(Version.PMML_4_3.getVersion(), header, dataDictionary); return pmml; }
@Test public void testFromString() throws Exception { PMML model = buildDummyModel(); PMML model2 = PMMLUtils.fromString(PMMLUtils.toString(model)); assertEquals(model.getHeader().getApplication().getName(), model2.getHeader().getApplication().getName()); assertEquals(model.getModels().get(0).getMiningFunction(), model2.getModels().get(0).getMiningFunction()); }
@Test public void testToString() throws Exception { PMML model = buildDummyModel(); model.getHeader().setTimestamp(null); assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" + "<PMML version=\"4.3\" xmlns=\"http://www.dmg.org/PMML-4_3\">" + "<Header>" + "<Application name=\"Oryx\"/>" + "</Header>" + "<TreeModel functionName=\"classification\">" + "<Node recordCount=\"123.0\"/>" + "</TreeModel>" + "</PMML>", PMMLUtils.toString(model)); }
@Override public VisitorAction accept(Visitor visitor) { VisitorAction status = visitor.visit(this); if (status == VisitorAction.CONTINUE) { visitor.pushParent(this); if ((status == VisitorAction.CONTINUE)&&hasExtensions()) { status = org.dmg.pmml.PMMLObject.traverse(visitor, getExtensions()); } if (status == VisitorAction.CONTINUE) { status = org.dmg.pmml.PMMLObject.traverse(visitor, getApplication()); } if ((status == VisitorAction.CONTINUE)&&hasAnnotations()) { status = org.dmg.pmml.PMMLObject.traverse(visitor, getAnnotations()); } if (status == VisitorAction.CONTINUE) { status = org.dmg.pmml.PMMLObject.traverse(visitor, getTimestamp()); } visitor.popParent(); } if (status == VisitorAction.TERMINATE) { return VisitorAction.TERMINATE; } return VisitorAction.CONTINUE; }
Header header = new Header(); pmml.setHeader(header); header.setCopyright(" Copyright [2013-2018] PayPal Software Foundation\n" + "\n" + " Licensed under the Apache License, Version 2.0 (the \"License\");\n" + " you may not use this file except in compliance with the License.\n" + " limitations under the License.\n"); Application application = new Application(); header.setApplication(application);
/** * Create an instance of {@link Header } * */ public Header createHeader() { return new Header(); }
/** * @return {@link PMML} with common {@link Header} fields like {@link Application}, * {@link Timestamp}, and version filled out */ public static PMML buildSkeletonPMML() { String formattedDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZ", Locale.ENGLISH).format(new Date()); Header header = new Header() .setTimestamp(new Timestamp().addContent(formattedDate)) .setApplication(new Application("Oryx")); return new PMML(VERSION, header, null); }
@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 } }
@Test public void testSkeleton() { PMML pmml = PMMLUtils.buildSkeletonPMML(); assertEquals("Oryx", pmml.getHeader().getApplication().getName()); assertNotNull(pmml.getHeader().getTimestamp()); }
.setSplitCharacteristic(TreeModel.SplitCharacteristic.BINARY_SPLIT); PMML pmml = new PMML(Version.PMML_4_3.getVersion(), new Header(), new DataDictionary()) .addModels(treeModel);