static void Main(string[] args) { if (args.Length < 3) { Console.WriteLine("args"); Console.WriteLine("[TrainSet] [TestSet] [outfilename] [N]"); return; } TrainDataLoader loader = new TrainDataLoader(); var TrainSet = loader.LoadData(args[0]); var TestSet = loader.LoadData(args[1]); int n = 5; if (args.Length == 4) { if (!int.TryParse(args[3], out n)) { n = 5; } } TestSet = TestSet.TakeEverNth(n).Cast <Point>().ToList(); goodRes = TestSet.Select(x => x.Cluster).ToArray(); test.GoodClassification = goodRes; var alg = new AlgorithmEngine <Point, int>(2, 2, TrainSet, TestSet); K_Test(alg, args[2]); alg.K = 6; P_Test(alg, args[2]); All_Test(alg, args[2]); Console.Read(); }
static void Main(string[] args) { string trainFilePath; string testFilePath; int k; if (!CheckAndResolveArgs(args, out trainFilePath, out testFilePath, out k)) { return; } TrainDataLoader dataLoader = new TrainDataLoader(); List <Point> trainData; List <Point> testData; try { trainData = dataLoader.LoadData(trainFilePath); testData = dataLoader.LoadData(testFilePath); } catch (Exception e) { Console.WriteLine(e.Message); return; } AlgorithmEngine <Point, int> engine = new AlgorithmEngine <Point, int>(k, 2, trainData, testData); var results = engine.KnnRunParallel(); PressAnyKey(false); }