Exemple #1
0
        private void btnEvaluateFile_Click(object sender, EventArgs e)
        {
            if (!File.Exists(txtEvaluationFile.Text))
            {
                MessageBox.Show("Chemin invalide");
                return;
            }

            int neighborInConsideration = 0;

            if (!int.TryParse(txtNbNeighbor.Text, out neighborInConsideration) || neighborInConsideration <= 0)
            {
                MessageBox.Show("Le nombre de voisin à prendre en considération est invalide");
                return;
            }


            var columnsInConsideration = new List <string>();

            for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                if (checkedListBox1.GetItemCheckState(i) == CheckState.Checked)
                {
                    columnsInConsideration.Add(checkedListBox1.Items[i].ToString());
                }
            }

            if (columnsInConsideration.Contains("Nicotine"))
            {
                MessageBox.Show("Les colonnes en considération ne peuvent pas contenir la colonne Nicotine");
                return;
            }

            var dataset = new DrugDataset();

            var lines = File.ReadAllLines(txtEvaluationFile.Text).Select(x => x.Split(',')).ToList();

            Logger.LogMessage($"All lines were read from evaluation file ${txtEvaluationFile.Text}");

            try
            {
                dataset.CreateDataset(lines);
            }
            catch (Exception ex)
            {
                Logger.LogError($"Error happened while creating Dataset: ${ex.Message}");
            }

            KNNInterpretation interpretation = KNNInterpretation.Mode;

            if (rbMediane.Checked)
            {
                interpretation = KNNInterpretation.Median;
            }
            else if (rbMode.Checked)
            {
                interpretation = KNNInterpretation.Mode;
            }
            else if (rbMoyenne.Checked)
            {
                interpretation = KNNInterpretation.Mean;
            }

            Logger.BringToFront();
            _knn2 = new KNN2(_drugDataset, columnsInConsideration, dataset, neighborInConsideration, interpretation);
        }
Exemple #2
0
        private void btnBuild_Click(object sender, EventArgs e)
        {
            List <string> columnsInConsideration = new List <string>();

            for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                if (checkedListBox1.GetItemCheckState(i) == CheckState.Checked)
                {
                    columnsInConsideration.Add(checkedListBox1.Items[i].ToString());
                }
            }

            double entropie;

            if (!double.TryParse(txtEpsilon.Text, out entropie))
            {
                MessageBox.Show("Entropie format est pas valide");
                return;
            }
            if (entropie < 0 || entropie > 1)
            {
                MessageBox.Show("Entropie doit etre entre 0 et 1");
                return;
            }

            TrainingRatio ratio = TrainingRatio.T1_E1;

            if (rb11.Checked)
            {
                ratio = TrainingRatio.T1_E1;
            }
            if (rb21.Checked)
            {
                ratio = TrainingRatio.T2_E1;
            }
            if (rb31.Checked)
            {
                ratio = TrainingRatio.T3_E1;
            }
            if (rb41.Checked)
            {
                ratio = TrainingRatio.T4_E1;
            }
            if (rb12.Checked)
            {
                ratio = TrainingRatio.T1_E2;
            }
            if (rb13.Checked)
            {
                ratio = TrainingRatio.T1_E3;
            }
            if (rb14.Checked)
            {
                ratio = TrainingRatio.T1_E4;
            }
            if (rb23.Checked)
            {
                ratio = TrainingRatio.T2_E3;
            }
            if (rb34.Checked)
            {
                ratio = TrainingRatio.T3_E4;
            }


            Logger.BringToFront();

            _drugDataset.CleanAllColumns();

            DecisionTree decisionTree = new DecisionTree(_drugDataset, columnsInConsideration, entropie, ratio);

            _tree = decisionTree.RunTraining();

            lblTree.ForeColor = Color.Green;
            lblTree.Text      = _tree.Name + "( non sauvegardé )";

            ShowTreeInfo();
            tabControl1.SelectedTab = tabPage3;
        }