Search in sources :

Example 1 with Rmse

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();
    }
}
Also used : SandboxMLCache(org.apache.ignite.examples.ml.util.SandboxMLCache) KNNRegressionTrainer(org.apache.ignite.ml.knn.regression.KNNRegressionTrainer) KNNRegressionModel(org.apache.ignite.ml.knn.regression.KNNRegressionModel) Rmse(org.apache.ignite.ml.selection.scoring.metric.regression.Rmse) Ignite(org.apache.ignite.Ignite) Vector(org.apache.ignite.ml.math.primitives.vector.Vector) ManhattanDistance(org.apache.ignite.ml.math.distances.ManhattanDistance)

Aggregations

Ignite (org.apache.ignite.Ignite)1 SandboxMLCache (org.apache.ignite.examples.ml.util.SandboxMLCache)1 KNNRegressionModel (org.apache.ignite.ml.knn.regression.KNNRegressionModel)1 KNNRegressionTrainer (org.apache.ignite.ml.knn.regression.KNNRegressionTrainer)1 ManhattanDistance (org.apache.ignite.ml.math.distances.ManhattanDistance)1 Vector (org.apache.ignite.ml.math.primitives.vector.Vector)1 Rmse (org.apache.ignite.ml.selection.scoring.metric.regression.Rmse)1