Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        private void OnTrain()
        {
            if (Files.Any())
            {
                var trainingData = ParseDYN.ParseDynData(Files);
                Model.TrainHiddenMarkovModel(trainingData);

                switch (TrainModel.TrainingMode)
                {
                case "bayes":
                    Model.TrainNaiveBayesClassifier(trainingData);
                    break;

                case "markov":
                    Model.TrainHiddenMarkovModel(trainingData);
                    break;
                }
            }
            else
            {
                // Initializes the variables to pass to the MessageBox.Show method.
                const string            message = "You did not select a folder yet, please specify";
                const string            caption = "Error Detected in Folder Selection";
                const MessageBoxButtons buttons = MessageBoxButtons.OK;

                // Displays the MessageBox.
                var result = MessageBox.Show(message, caption, buttons);

                if (result == DialogResult.Yes)
                {
                    // Closes the parent form.
                    Win?.Close();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handler for Train button. Parses selected DYN files to create train dataset.
        /// </summary>
        private void OnTrain()
        {
            if (Files.Any())
            {
                // (Aaron) Parse all the Dyns under DirectoryPath to CSV format
                var trainingData = ParseDYN.ParseDynData(Files);

                // (Konrad) Export the CSV to the %AppData%\thesaurus folder
                // That's the only location that we are sure user will have write access
                // This makes it possible for user to train his/her model on graphs
                // stored somewhere on the network where they are "read-only" for non-admins.
                ParseDYN.csvParser.ExportCSV();
                Model.TrainHiddenMarkovModel(trainingData);

                switch (TrainModel.TrainingMode)
                {
                case "bayes":
                    Model.TrainNaiveBayesClassifier(trainingData);
                    break;

                case "markov":
                    Model.TrainHiddenMarkovModel(trainingData);
                    break;
                }

                var                     message = Properties.Resources.Train_Success;
                const string            caption = "Success";
                const MessageBoxButtons buttons = MessageBoxButtons.OK;
                var                     result  = MessageBox.Show(message, caption, buttons, MessageBoxIcon.Information);
                if (result == DialogResult.OK)
                {
                    Win?.Close();
                }
            }
            else
            {
                var                     message = Properties.Resources.Train_FolderError;
                const string            caption = "Error";
                const MessageBoxButtons buttons = MessageBoxButtons.OK;
                MessageBox.Show(message, caption, buttons, MessageBoxIcon.Error);
            }
        }