Skip to content

Instantly share code, notes, and snippets.

@OlegJakushkin
Last active February 18, 2016 17:30
Show Gist options
  • Save OlegJakushkin/8d2c72eb1701e5c08aba to your computer and use it in GitHub Desktop.
Save OlegJakushkin/8d2c72eb1701e5c08aba to your computer and use it in GitHub Desktop.
using System;
using System.Linq;
using Accord.MachineLearning.Structures;
namespace KD_test {
class Program {
public static void Main() {
double[][] points = {
new double[] {5, 5, 4},
new double[] {4, 7, 5},
new double[] {7, 2, 9},
new double[] {2, 3, 5},
new double[] {8, 5, 1},
new double[] {9, 6, 5},
};
double[][] values = {
new double[] {0, 1, 0},
new double[] {1, 7, 5},
new double[] {7, 1, 9},
new double[] {2, 3, 1},
new double[] {8, 5, 1},
new double[] {9, 0, 5},
};
var tree = KDTree.FromData( points, values );
var newPosition = new double[] {5, 5, 5};
var speedValue = tree.ApproximateNearest(newPosition, 1 ).Value; // 90% probabilety
var speedAsString = speedValue.Aggregate("", (s, d) =>s + d + " ");
Console.WriteLine( speedAsString );
Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment