Ejemplo n.º 1
0
        //Calculate button
        private void CalculateToolStripButton_Click(object sender, EventArgs e)
        {
            var selectColumns = SelectTextBox.Text.Replace(" ", string.Empty).Split(',');

            var classColumn = ClassTextBox.Text.Replace(" ", string.Empty);

            var kElement = KtextBox.Text.ToString().Replace(" ", string.Empty);

            if (string.IsNullOrEmpty(classColumn) || selectColumns == null || selectColumns.Length == 0 ||
                string.IsNullOrEmpty(kElement) || _newTestObject == null)
            {
                MessageBox.Show(@"Please add data");
            }
            else
            {
                ToConsole(@"Calculating");

                var knn    = new Knn();
                var answer = knn.Calculate(_newTestObject, int.Parse(kElement), _fileData, selectColumns, classColumn);

                ToConsole(@"Answer -> " + answer);
            }
        }