use of org.apache.ignite.ml.FileExporter in project ignite by apache.
the class LocalModelsTest method importExportLinearRegressionModelTest.
/**
*/
@Test
public void importExportLinearRegressionModelTest() throws IOException {
executeModelTest(mdlFilePath -> {
LinearRegressionModel mdl = new LinearRegressionModel(new DenseVector(new double[] { 1, 2 }), 3);
Exporter<LinearRegressionModel, String> exporter = new FileExporter<>();
mdl.saveModel(exporter, mdlFilePath);
LinearRegressionModel load = exporter.load(mdlFilePath);
Assert.assertNotNull(load);
Assert.assertEquals("", mdl, load);
return null;
});
}
use of org.apache.ignite.ml.FileExporter in project ignite by apache.
the class LocalModelsTest method importExportLogisticRegressionModelTest.
/**
*/
@Test
public void importExportLogisticRegressionModelTest() throws IOException {
executeModelTest(mdlFilePath -> {
LogisticRegressionModel mdl = new LogisticRegressionModel(new DenseVector(new double[] { 1, 2 }), 3);
Exporter<LogisticRegressionModel, String> exporter = new FileExporter<>();
mdl.saveModel(exporter, mdlFilePath);
LogisticRegressionModel load = exporter.load(mdlFilePath);
Assert.assertNotNull(load);
Assert.assertEquals("", mdl, load);
return null;
});
}
use of org.apache.ignite.ml.FileExporter in project ignite by apache.
the class LocalModelsTest method importExportSVMBinaryClassificationModelTest.
/**
*/
@Test
public void importExportSVMBinaryClassificationModelTest() throws IOException {
executeModelTest(mdlFilePath -> {
SVMLinearClassificationModel mdl = new SVMLinearClassificationModel(new DenseVector(new double[] { 1, 2 }), 3);
Exporter<SVMLinearClassificationModel, String> exporter = new FileExporter<>();
mdl.saveModel(exporter, mdlFilePath);
SVMLinearClassificationModel load = exporter.load(mdlFilePath);
Assert.assertNotNull(load);
Assert.assertEquals("", mdl, load);
return null;
});
}
use of org.apache.ignite.ml.FileExporter 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;
});
}
use of org.apache.ignite.ml.FileExporter in project ignite by apache.
the class LocalModelsTest method importExportKMeansModelTest.
/**
*/
@Test
public void importExportKMeansModelTest() throws IOException {
executeModelTest(mdlFilePath -> {
KMeansModel mdl = getClusterModel();
Exporter<KMeansModelFormat, String> exporter = new FileExporter<>();
mdl.saveModel(exporter, mdlFilePath);
KMeansModelFormat load = exporter.load(mdlFilePath);
Assert.assertNotNull(load);
KMeansModel importedMdl = new KMeansModel(load.getCenters(), load.getDistance());
Assert.assertEquals("", mdl, importedMdl);
return null;
});
}
Aggregations