use of org.apache.ignite.ml.selection.scoring.metric.regression.Rmse in project ignite by apache.
the class KNNRegressionExample method main.
/**
* Run example.
*/
public static void main(String[] args) throws IOException {
System.out.println();
System.out.println(">>> kNN regression over cached dataset usage example started.");
// Start ignite grid.
try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
System.out.println(">>> Ignite grid started.");
IgniteCache<Integer, Vector> dataCache = null;
try {
dataCache = new SandboxMLCache(ignite).fillCacheWith(MLSandboxDatasets.CLEARED_MACHINES);
KNNRegressionTrainer trainer = new KNNRegressionTrainer().withK(5).withDistanceMeasure(new ManhattanDistance()).withIdxType(SpatialIndexType.BALL_TREE).withWeighted(true);
Vectorizer<Integer, Vector, Integer, Double> vectorizer = new DummyVectorizer<Integer>().labeled(Vectorizer.LabelCoordinate.FIRST);
KNNRegressionModel knnMdl = trainer.fit(ignite, dataCache, vectorizer);
double rmse = Evaluator.evaluate(dataCache, knnMdl, vectorizer, new Rmse());
System.out.println("\n>>> Rmse = " + rmse);
} finally {
if (dataCache != null)
dataCache.destroy();
}
} finally {
System.out.flush();
}
}
Aggregations