Exemplo n.º 1
0
        static void ClusterPoints()
        {
            var points = Enumerable.Range(0, 100)
                         .Select(_ => Enumerable.Range(1, 3).Select(i => RandomUtility.NextDouble(0, i)).ToArray())
                         .ToArray();

            var records = points
                          .Select((p, i) => new Record <int> {
                Element = i, Features = p,
            })
                          .ToArray();

            var clustering = new KMeans <int>(10, 20);
            var clusters   = clustering.Train(records);

            foreach (var cluster in clusters)
            {
                Console.WriteLine(cluster.Key);
                Array.ForEach(cluster.Value, r => Console.WriteLine(FeaturesHelper.ToString(r.Features)));
            }
        }
Exemplo n.º 2
0
 string ToDebugString()
 {
     return(string.Format("{0}: {1}", Element, FeaturesHelper.ToString(Features)));
 }
Exemplo n.º 3
0
 string ToDebugString()
 {
     return(string.Format("{0}: {1}: {2} records", Id, FeaturesHelper.ToString(Centroid), Records.Count));
 }