예제 #1
0
        // Called when the user tries to open a file to test the classifier.
        private void testingFile_button_Click(object sender, EventArgs e)
        {
            // Scroll to the end of the text box.
            classificationLog_richTextBox.SelectionStart = classificationLog_richTextBox.Text.Length;
            classificationLog_richTextBox.ScrollToCaret();

            if (testing_openFileDialog.ShowDialog() == DialogResult.OK)
            {
                testingData = new ClassificationData();

                // Return if file was not open and parsed correctly.
                if (!testingData.OpenAndParseFile(testing_openFileDialog.FileName, true))
                {
                    classificationLog_richTextBox.SelectionColor = Color.Red;
                    classificationLog_richTextBox.SelectedText   =
                        "=====> Testing file: " +
                        testing_openFileDialog.FileName +
                        " was not opened or parsed correctly." +
                        Environment.NewLine;
                    return;
                }
                testingFileLoaded = true;
                classificationLog_richTextBox.SelectionColor = Color.Green;
                classificationLog_richTextBox.SelectedText   =
                    "=====> Testing file: " +
                    testing_openFileDialog.FileName +
                    " was opened successfully." +
                    Environment.NewLine;

                reset_button.Enabled          = true;
                testClassifier_button.Enabled = trainingFileLoaded && testingFileLoaded && dataTrained;
            }
        }
예제 #2
0
        // Called when the user tries to open a file to train the classifier.
        private void trainingFile_button_Click(object sender, EventArgs e)
        {
            // Scroll to the end of the text box.
            classificationLog_richTextBox.SelectionStart = classificationLog_richTextBox.Text.Length;
            classificationLog_richTextBox.ScrollToCaret();

            if (training_openFileDialog.ShowDialog() == DialogResult.OK)
            {
                trainingData = new ClassificationData();

                // Return if the file was not open and parsed correctly.
                if (!trainingData.OpenAndParseFile(training_openFileDialog.FileName, true))
                {
                    classificationLog_richTextBox.SelectionColor = Color.Red;
                    classificationLog_richTextBox.SelectedText   =
                        "=====> Training file: " +
                        training_openFileDialog.FileName +
                        " was not opened or parsed correctly." +
                        Environment.NewLine;
                    return;
                }
                trainingFileLoaded = true;
                classificationLog_richTextBox.SelectionColor = Color.Green;
                classificationLog_richTextBox.SelectedText   =
                    "=====> Training file: " +
                    training_openFileDialog.FileName +
                    " was opened successfully. " +
                    Environment.NewLine;

                // Activate some window's controls if the file was loaded successfully.
                attributeToPredict_comboBox.DataSource    = trainingData.AllColumnNames;
                attributeToPredict_comboBox.SelectedIndex = -1;
                attributeToPredict_comboBox.Enabled       = true;
                classifierToUse_comboBox.DataSource       = classificationMethods;
                classifierToUse_comboBox.SelectedIndex    = -1;
                classifierToUse_comboBox.Enabled          = true;
                dataset_dataGridView.DataSource           = trainingData.ExtractedDataset;
                dataset_dataGridView.Enabled          = true;
                classificationLog_richTextBox.Enabled = true;
                trainClassifier_button.Enabled        = attributeChosen && classifierChosen;
                reset_button.Enabled          = true;
                testClassifier_button.Enabled = trainingFileLoaded && testingFileLoaded && dataTrained;
            }
        }