Package org.dmg.pmml

Examples of org.dmg.pmml.PMML


          }
          break;

        case "MODEL":
          // New model
          PMML pmml = PMMLUtils.fromString(message);
          int features = Integer.parseInt(PMMLUtils.getExtensionValue(pmml, "features"));
          boolean implicit = Boolean.valueOf(PMMLUtils.getExtensionValue(pmml, "implicit"));
          if (model == null) {

            log.info("No previous model");
View Full Code Here


                                    boolean implicit,
                                    Path candidatePath) {
    saveFeaturesRDD(model.userFeatures(), new Path(candidatePath, "X"));
    saveFeaturesRDD(model.productFeatures(), new Path(candidatePath, "Y"));

    PMML pmml = PMMLUtils.buildSkeletonPMML();
    PMMLUtils.addExtension(pmml, "X", "X/");
    PMMLUtils.addExtension(pmml, "Y", "Y/");
    PMMLUtils.addExtension(pmml, "features", Integer.toString(features));
    PMMLUtils.addExtension(pmml, "lambda", Double.toString(lambda));
    PMMLUtils.addExtension(pmml, "implicit", Boolean.toString(implicit));
View Full Code Here

          }
        }

      } else {

        PMML pmml = PMMLUtils.fromString(value);
        List<Extension> extensions = pmml.getExtensions();
        assertEquals(7, extensions.size());
        // Basic hyperparameters should match
        assertEquals(Integer.toString(FEATURES), PMMLUtils.getExtensionValue(pmml, "features"));
        assertEquals(Double.toString(LAMBDA),PMMLUtils.getExtensionValue(pmml, "lambda"));
        assertEquals("false", PMMLUtils.getExtensionValue(pmml, "implicit"));
View Full Code Here

    checkIntervals(modelInstanceDirs.size(), DATA_TO_WRITE, WRITE_INTERVAL_MSEC, GEN_INTERVAL_SEC);

    Path modelFile = modelInstanceDirs.get(0).resolve(MLUpdate.MODEL_FILE_NAME);
    assertTrue("No such model file: " + modelFile, Files.exists(modelFile));

    PMML pmml = PMMLUtils.read(modelFile);
    List<Extension> extensions = pmml.getExtensions();
    assertEquals(8, extensions.size());
    assertNotNull(PMMLUtils.getExtensionValue(pmml, "X"));
    assertNotNull(PMMLUtils.getExtensionValue(pmml, "Y"));
    assertTrue(Boolean.parseBoolean(PMMLUtils.getExtensionValue(pmml, "implicit")));
    assertEquals(0.001, Double.parseDouble(PMMLUtils.getExtensionValue(pmml, "lambda")));
View Full Code Here

  });

  @Override
  public Pair<String,String> generate(int id, RandomGenerator random) throws IOException {
    if (id % 10 == 0) {
      PMML pmml = PMMLUtils.buildSkeletonPMML();
      PMMLUtils.addExtension(pmml, "features", "2");
      PMMLUtils.addExtension(pmml, "implicit", "true");
      PMMLUtils.addExtensionContent(pmml, "XIDs", X.keySet());
      PMMLUtils.addExtensionContent(pmml, "YIDs", Y.keySet());
      return new Pair<>("MODEL", PMMLUtils.toString(pmml));
View Full Code Here

    String formattedDate =
        new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZZ", Locale.ENGLISH).format(new Date());
    Header header = new Header();
    header.setTimestamp(new Timestamp().withContent(formattedDate));
    header.setApplication(new Application("Oryx"));
    return new PMML(header, null, "4.2.1");
  }
View Full Code Here

  public static PMML buildDummyModel() {
    Node node = new Node();
    node.setRecordCount(123.0);
    TreeModel treeModel = new TreeModel(null, node, MiningFunctionType.CLASSIFICATION);
    PMML pmml = PMMLUtils.buildSkeletonPMML();
    pmml.getModels().add(treeModel);
    return pmml;
  }
View Full Code Here

    return pmml;
  }

  @Test
  public void testSkeleton() {
    PMML pmml = PMMLUtils.buildSkeletonPMML();
    assertEquals("Oryx", pmml.getHeader().getApplication().getName());
    assertNotNull(pmml.getHeader().getTimestamp());
  }
View Full Code Here

          }
          break;

        case "MODEL":
          // New model
          PMML pmml = PMMLUtils.fromString(message);
          int features = Integer.parseInt(PMMLUtils.getExtensionValue(pmml, "features"));
          if (model == null) {

            log.info("No previous model");
            model = new ALSSpeedModel(features);
View Full Code Here

  }

  @Test
  public void testReadWrite() throws Exception {
    Path tempModelFile = Files.createTempFile(getTempDir(), "model", ".pmml.gz");
    PMML model = buildDummyModel();
    PMMLUtils.write(model, tempModelFile);
    assertTrue(Files.exists(tempModelFile));
    PMML model2 = PMMLUtils.read(tempModelFile);
    List<Model> models = model2.getModels();
    assertEquals(1, models.size());
    assertTrue(models.get(0) instanceof TreeModel);
    TreeModel treeModel = (TreeModel) models.get(0);
    assertEquals(123.0, treeModel.getNode().getRecordCount().doubleValue());
    assertEquals(MiningFunctionType.CLASSIFICATION, treeModel.getFunctionName());
View Full Code Here

TOP

Related Classes of org.dmg.pmml.PMML

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.