private void confirm_Click(object sender, EventArgs e) { Metrics.metric metric; DataValidation dataValidation; int k; string userSampleString; List <double> attributesToCheck; int? decision; if (!DataValidation.isDataLoaded(dataLoader, out string dataError)) { MessageBox.Show(dataError); return; } dataValidation = new DataValidation(sampleColection, dataLoader, comboBox, kBox, attrBox); if (!dataValidation.isValid) { MessageBox.Show(dataValidation.message); return; } if ((string)comboBox.SelectedItem == "Minkowski Metric") { if (!DataValidation.isCorrectP(pBox, out string pError)) { MessageBox.Show(pError); return; } } p = int.Parse(pBox.Text); k = int.Parse(kBox.Text); userSampleString = attrBox.Text; metric = Metrics.chooseMetric(comboBox); attributesToCheck = Data.rowToList(userSampleString); decision = Algorithm.chooseDecision(attributesToCheck, sampleColection, k, metric, p); resultsTextBox.Text = ""; results.Add("Attributes: " + userSampleString + "\nK: " + k + "\nMetric: " + comboBox.SelectedItem + "\nDecision: " + (decision == null ? "Couldn't solve" : decision.ToString()) + "\n----------\n"); foreach (string result in results) { resultsTextBox.Text += result; } }
private void loadData_Click(object sender, EventArgs e) { dataLoader = new DataLoader(ofd); if (!DataValidation.isDataLoaded(dataLoader, out string dataError)) { dataInfo.Text = dataError; return; } sampleColection = new SampleColection(dataLoader.data); var samplesAmount = sampleColection.countSamples(); var decisionAmount = sampleColection.possibleDecisions().Count; var attributesAmount = sampleColection.samples.First().attributes.Count; var maxK = KChecker.maxK(sampleColection); dataInfo.Text = "File OK\n"; dataInfo.Text += "Loaded " + samplesAmount + " samples\n"; dataInfo.Text += "There are " + decisionAmount + " decisions possible\n"; dataInfo.Visible = true; attributesInfo.Text = "Attributes"; attributesInfo.Text += "\nEnter " + attributesAmount + " attributes"; kInfo.Text = "K"; kInfo.Text += "\nK must be between 1 and " + maxK; }