use of org.apache.ignite.ml.knn.ann.KNNModelFormat in project ignite by apache.
the class LocalModelsTest method importExportANNModelTest.
/**
*/
@Test
public void importExportANNModelTest() throws IOException {
executeModelTest(mdlFilePath -> {
final LabeledVectorSet<LabeledVector> centers = new LabeledVectorSet<>();
NNClassificationModel mdl = new ANNClassificationModel(centers, new ANNClassificationTrainer.CentroidStat()).withK(4).withDistanceMeasure(new ManhattanDistance()).withWeighted(true);
Exporter<KNNModelFormat, String> exporter = new FileExporter<>();
mdl.saveModel(exporter, mdlFilePath);
ANNModelFormat load = (ANNModelFormat) exporter.load(mdlFilePath);
Assert.assertNotNull(load);
NNClassificationModel importedMdl = new ANNClassificationModel(load.getCandidates(), new ANNClassificationTrainer.CentroidStat()).withK(load.getK()).withDistanceMeasure(load.getDistanceMeasure()).withWeighted(true);
Assert.assertEquals("", mdl, importedMdl);
return null;
});
}
Aggregations