/** * @param path file to read PMML from * @return {@link PMML} model file from path * @throws IOException if an error occurs while reading the model from storage */ public static PMML read(Path path) throws IOException { try (InputStream in = Files.newInputStream(path)) { return read(in); } }
bestModel = PMMLUtils.read(in);
assertTrue("No such model file: " + modelFile, Files.exists(modelFile)); PMML pmml = PMMLUtils.read(modelFile); Model rootModel = pmml.getModels().get(0); ClusteringModel clusteringModel = (ClusteringModel) rootModel;
@Test public void testReadWrite() throws Exception { Path tempModelFile = Files.createTempFile(getTempDir(), "model", ".pmml"); 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()); assertInstanceOf(models.get(0), TreeModel.class); TreeModel treeModel = (TreeModel) models.get(0); assertEquals(123.0, treeModel.getNode().getRecordCount().doubleValue()); assertEquals(MiningFunction.CLASSIFICATION, treeModel.getMiningFunction()); }
assertTrue("No such model file: " + modelFile, Files.exists(modelFile)); PMML pmml = PMMLUtils.read(modelFile); assertEquals(9, pmml.getExtensions().size()); assertNotNull(AppPMMLUtils.getExtensionValue(pmml, "X"));
assertTrue("No such model file: " + modelFile, Files.exists(modelFile)); PMML pmml = PMMLUtils.read(modelFile);
assertTrue("No such model file: " + modelFile, Files.exists(modelFile)); PMML pmml = PMMLUtils.read(modelFile);
Path modelFile = modelInstanceDir.resolve(MLUpdate.MODEL_FILE_NAME); assertNonEmpty(modelFile); PMMLUtils.read(modelFile); // Shouldn't throw exception Path xDir = modelInstanceDir.resolve("X"); assertTrue(Files.exists(xDir));
Path modelFile = modelInstanceDir.resolve(MLUpdate.MODEL_FILE_NAME); assertNonEmpty(modelFile); PMMLUtils.read(modelFile); // Shouldn't throw exception
Path modelFile = modelInstanceDir.resolve(MLUpdate.MODEL_FILE_NAME); assertNonEmpty(modelFile); PMMLUtils.read(modelFile); // Shouldn't throw exception
/** * @param path file to read PMML from * @return {@link PMML} model file from path * @throws IOException if an error occurs while reading the model from storage */ public static PMML read(Path path) throws IOException { try (InputStream in = Files.newInputStream(path)) { return read(in); } }
bestModel = PMMLUtils.read(in);