private static void InputCommand() { while (true) { System.Console.WriteLine("Input command, e.g. CR"); System.Console.WriteLine("C to clear all views except last generation"); System.Console.WriteLine("R to run again with current dataset"); System.Console.WriteLine("Q to exit"); string s = Console.ReadLine(); if (s.ToLower().Contains("c")) { Points2DCollectionsViewer.CloseAllButLastView(); } if (s.ToLower().Contains("r")) { Retry = true; break; } if (s.ToLower().Contains("q")) { Retry = false; break; } } }
private static void Random2DPoints_OnGeneratePointGroups(IEnumerable <Point2D> Nodes) { Points2DCollectionsViewer View = Points2DCollectionsViewer.BuildViewer(Nodes, "RawData Generated", 0, NodesMaxValueSet); Points2DCollectionsViewer.ShowViewer(View); Points2DCollectionsViewer.CloseAllButLastView(); }
private static void Kmeans_OnIteration(IEnumerable <VectorCollection <Point2D> > Groups, int IterationCount) { List <Point2D> point2Ds = new List <Point2D>(); foreach (var Group in Groups) { point2Ds.AddRange(Group); } Points2DCollectionsViewer View = Points2DCollectionsViewer.BuildViewer(point2Ds, "Round:" + Round + ",Iteration:" + IterationCount, 0, NodesMaxValueSet); foreach (var Group in Groups) { View.AddMarkAt(Group.Center, 16, 1); } Points2DCollectionsViewer.ShowViewer(View); }
private static void Knn_OnClassify(Point2D NewNode, IEnumerable <Point2D> ClosestKPoints, string MostTag, IEnumerable <Point2D> ClassifiedNodes) { Console.WriteLine("NewPoint,x:{0},y:{1}\t,closet points in {2}", NewNode.x, NewNode.y, k); foreach (var ClosestPoint in ClosestKPoints) { Console.WriteLine("Point,x:{0},y:{1}\t,tag:{2},distance{3}", ClosestPoint.x, ClosestPoint.y, ClosestPoint.Tag, ClosestPoint.GetEuclideanDistance(NewNode)); } Console.WriteLine("MostTag:{0}", MostTag); Console.WriteLine("----------------------------------"); List <Point2D> point2Ds = new List <Point2D>(); point2Ds.AddRange(ClassifiedNodes); StringBuilder sb = new StringBuilder(); sb.Append("Round:"); sb.Append(Round++); sb.Append(" ,AddPoint At:"); sb.Append(NewNode.x); sb.Append(","); sb.Append(NewNode.y); sb.Append(",Tag:"); sb.Append(NewNode.Tag); Points2DCollectionsViewer View = Points2DCollectionsViewer.BuildViewer(point2Ds, sb.ToString(), 0, NodesMaxValueSet); View.AddMarkAt(NewNode, 20, 7); foreach (var ClosestPoint in ClosestKPoints) { View.AddMarkAt(ClosestPoint, 6, 7); } Points2DCollectionsViewer.ShowViewer(View); }