private void Go_Metrics(object sender, RoutedEventArgs e) { int randomNumberWhat = -5000; var cl = new MetricClass(randomNumberWhat, randomNumberWhat, currentModel); Metrics.PreformMetrics(int.Parse(kParameter.Text), cl, models, int.Parse(ExpectedClassResultTextBox.Text)); }
public static void PreformMetrics(int k, MetricClass the_one, List <MetricClass> models, int _debug_expected_class) { Console.WriteLine(the_one); List <MetricData> euclidean = new List <MetricData>(); List <MetricData> manhattan = new List <MetricData>(); List <MetricData> chebyshev = new List <MetricData>(); List <MetricData> braycurtis = new List <MetricData>(); //List<MetricData> chebyshev = new List<MetricData>(); foreach (MetricClass item in models) { euclidean.Add(new MetricData(item.DataId, Euclidean(the_one.Values, item.Values), item.Id)); manhattan.Add(new MetricData(item.DataId, Manhattan(the_one.Values, item.Values), item.Id)); chebyshev.Add(new MetricData(item.DataId, Chebyshev(the_one.Values, item.Values), item.Id)); braycurtis.Add(new MetricData(item.DataId, BrayCurtis(the_one.Values, item.Values), item.Id)); } euclidean.Sort((a, b) => a.Result.CompareTo(b.Result)); manhattan.Sort((a, b) => a.Result.CompareTo(b.Result)); chebyshev.Sort((a, b) => a.Result.CompareTo(b.Result)); braycurtis.Sort((a, b) => a.Result.CompareTo(b.Result)); Console.WriteLine("Euclidean"); for (int i = 0; i < euclidean.Count; i++) { Console.WriteLine(euclidean[i].ToString()); } Console.WriteLine("Manhattan"); for (int i = 0; i < manhattan.Count; i++) { Console.WriteLine(manhattan[i].ToString()); } Console.WriteLine("Chebyshev"); for (int i = 0; i < chebyshev.Count; i++) { Console.WriteLine(chebyshev[i].ToString()); } Console.WriteLine("Bray Curtis"); for (int i = 0; i < braycurtis.Count; i++) { Console.WriteLine(braycurtis[i].ToString()); } MetricData basedata = euclidean[0]; euclidean.RemoveAt(0); manhattan.RemoveAt(0); chebyshev.RemoveAt(0); braycurtis.RemoveAt(0); MetricsSummary summary = new MetricsSummary { K = k, BaseData = basedata, EuclideanSummary = euclidean, ManhattanSummary = manhattan, ChebyshevSummary = chebyshev, BrayCurtisSummary = braycurtis }; summary.ShowResults(); summary.Show(); }