public override Result Perform(InputData inputData) { int n, k; NPoint[] x; using (var sr = new StreamReader("input.txt")) { string f = sr.ReadLine(); n = int.Parse(f); f = sr.ReadLine(); k = int.Parse(f); x = new NPoint[n]; for (int i = 0; i < n; i++) { x[i] = new NPoint() { X = new double[k - 2] } } ; for (int i = 0; i < n; i++) { var str = sr.ReadLine().Split(new char[] { ' ', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries); for (int j = 0; j < k - 2; j++) { x[i].X[j] = double.Parse(str[j], CultureInfo.InvariantCulture); } x[i].Class = str[str.Length - 1]; } } NPoint np1 = new NPoint() { X = new double[] { 5.7, 4.4 } }; // Iris-setosa NPoint np2 = new NPoint() { X = new double[] { 6.1, 2.8 } }; // Iris-versicolor NPoint np3 = new NPoint() { X = new double[] { 6.4, 2.8 } }; // Iris-virginica Methods.KNearestNeighbor(x.ToList(), np1, 30); Methods.KNearestNeighbor(x.ToList(), np2, 30); Methods.KNearestNeighbor(x.ToList(), np3, 30); Console.WriteLine(np1.Class); Console.WriteLine(np2.Class); Console.WriteLine(np3.Class); string s1 = Methods.BayesClassificator <string, NPoint>(x.ToList(), np1, c => c.Class); string s2 = Methods.BayesClassificator <string, NPoint>(x.ToList(), np2, c => c.Class); string s3 = Methods.BayesClassificator <string, NPoint>(x.ToList(), np3, c => c.Class); Console.WriteLine(s1); Console.WriteLine(s2); Console.WriteLine(s3); string[][] table; using (var sr = new StreamReader("tree.txt", Encoding.Unicode)) { string f = sr.ReadLine(); n = int.Parse(f); f = sr.ReadLine(); k = int.Parse(f); table = new string[n][]; for (int i = 0; i < n; i++) { table[i] = new string[k + 1]; } for (int i = 0; i < n; i++) { var str = sr.ReadLine().Split(new char[] { ' ', '\t', ',' }, StringSplitOptions.RemoveEmptyEntries); for (int j = 0; j < k + 1; j++) { table[i][j] = str[j]; } } } Trees t = new Trees(); Node root = t.Build(table, new bool[k]); string[] qwestion = { "Ниже", "ВГостях", "НаМесте ", "Нет", "" }; Console.WriteLine(root.Find(qwestion)); Console.ReadLine(); throw new NotImplementedException(); }