public static void KnnMain() { Console.WriteLine("Using demo setup?[y/n]"); string str = Console.ReadLine(); if (str.ToLower().Contains("y") == false) { Console.WriteLine("Input node maximum value:(Default:10000)"); NodesMaxValueSet = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Input node count:(Default:150)"); NodesSet = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Input groups count for random points to divid into:(Default:3, Min:1)"); DataGroupCount = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Input fluctuation ratio:(Default:0.5, Min:0.1)"); FluctuationRatio = Convert.ToSingle(Console.ReadLine()); Console.WriteLine("Input new node count:(Default:10)"); NewNodesCount = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Input k set:(Default:7)"); k = Convert.ToInt32(Console.ReadLine()); } //Gen grouped random nodes Random2DPoints.OnGeneratePointGroups += Random2DPoints_OnGeneratePointGroups; var ClassifiedPoints = Random2DPoints.GenerateRandomPointsGroup(NodesMaxValueSet, NodesSet, DataGroupCount, FluctuationRatio); var Dataset = new VectorCollection <Point2D>(ClassifiedPoints); Dataset.Print(); var knnTrainer = new KnnTrainer <Point2D>(Dataset); Knn <Point2D> knn = new Knn <Point2D>(knnTrainer.Train()); knn.OnClassify += Knn_OnClassify; while (Retry) { var NewNodes = Random2DPoints.GenerateRandomPoints(NodesMaxValueSet, NewNodesCount); foreach (var NewNode in NewNodes) { knn.Classify(k, NewNode); } InputCommand(); } }
public static void KmeansMain() { Console.WriteLine("Using demo setup?[y/n]"); string str = Console.ReadLine(); if (str.ToLower().Contains("y") == false) { Console.WriteLine("Input node maximum value:(Default:10000 , Min:0)"); NodesMaxValueSet = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Input node count:(Default:10000 , Min:0)"); NodesSet = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Input groups count for random points to divid into:(Default:3 , Min:0)"); DataGroupCount = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Input fluctuation ratio:(Default:0.18 , Min:0 , Max:0.5)"); FluctuationRatio = Convert.ToSingle(Console.ReadLine()); Console.WriteLine("Input k:( Default:3 , Min:1)"); k = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Input iteration limit:(Default:100)"); IterationLimit = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Input convergence distance:(Default:5)"); ConvDistance = Convert.ToInt32(Console.ReadLine()); } //Gen grouped random nodes Random2DPoints.OnGeneratePointGroups += Random2DPoints_OnGeneratePointGroups; var RandomPoints = Random2DPoints.GenerateRandomPointsGroup(NodesMaxValueSet, NodesSet, DataGroupCount, FluctuationRatio); var Dataset = new VectorCollection <Point2D>(RandomPoints); Dataset.Print(); while (Retry) { KmeansTrainer <Point2D> kmeansTrainer = new KmeansTrainer <Point2D>(Dataset, k, ConvDistance, IterationLimit); kmeansTrainer.OnIteration += Kmeans_OnIteration; var TrainResult = kmeansTrainer.Train(); //Kmeans<Point2D> kmeans = new Kmeans<Point2D>(TrainResult); InputCommand(); kmeansTrainer.OnIteration -= Kmeans_OnIteration; } }