Exemplo n.º 1
0
        private void ClassificationButton_Click(object sender, EventArgs e)
        {
            List <Data> Trainingdataset = Utility.LoadDataset(DatasetType.Training);
            TrainModel  train           = null;

            if (comboBox1.SelectedIndex == 0)
            {
                train = new TrainModel(ViewModel.FeatureExtraction.FeatureExtractionType.EuclideanDistance, ClassifierType.Bayesian);
            }
            else if (comboBox1.SelectedIndex == 1)
            {
                train = new TrainModel(ViewModel.FeatureExtraction.FeatureExtractionType.EuclideanDistance, ClassifierType.KNearestNeighbour);
            }
            train.Train(Trainingdataset);
            OpenFileDialog f = new OpenFileDialog();

            if (DialogResult.OK == f.ShowDialog())
            {
                ScoreModel     score    = new ScoreModel(train, int.Parse(KNNTextBox.Text));
                List <Vector2> features = Utility.LoadPoints(f.FileName);

                int estimatedClass = score.Classify(features);
                ExpectedClassLabel.Text = estimatedClass.ToString();
                AppModel app = new AppModel(@"C:\Program Files (x86)\Notepad++\notepad++.exe");
                try
                {
                    if (estimatedClass == 0)
                    {
                        app.Close();
                    }
                    else if (estimatedClass == 1)
                    {
                        app.Minimize();
                    }
                    else if (estimatedClass == 2)
                    {
                        app.Open();
                    }
                    else if (estimatedClass == 3)
                    {
                        app.Restore();
                    }
                }
                catch
                {
                    MessageBox.Show("Couldn't take that action, please make sure that the specified program is already opened");
                }
            }

            /*for(int i=0;i<40;)
             * {
             *  Vector2 a = new Vector2();
             *  a.x = double.Parse(inputarr[i++].Text);
             *  a.y = double.Parse(inputarr[i++].Text);
             *  features.Add(a);
             * }*/
        }