Exemplo n.º 1
0
        private void btnLoadTree_Click(object sender, EventArgs e)
        {
            if (!File.Exists(txtLoadTree.Text))
            {
                MessageBox.Show("Le chemin est invalid");
                return;
            }

            string json = "";

            try
            {
                json = File.ReadAllText(txtLoadTree.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Une erreur s'est produite lors de la lecture du fichier");
                return;
            }

            try
            {
                _tree = JsonConvert.DeserializeObject <SavingTree>(json, new JsonSerializerSettings
                {
                    ReferenceLoopHandling      = ReferenceLoopHandling.Serialize,
                    PreserveReferencesHandling = PreserveReferencesHandling.Objects
                });
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Une erreur lors de la désérialisation de l'arbre, {ex.Message}");
                return;
            }

            ShowTreeInfo();
            RebuildPredicate(_tree.Root);

            lblTree.Text            = _tree.Name + "( sauvegardé )";
            tabControl1.SelectedTab = tabPage3;
        }
 public DecisionTreePrediction(DrugDataset rawDataset, DrugDataset normalizedDataset, SavingTree tree)
 {
     _rawDataset        = rawDataset;
     _normalizedDataset = normalizedDataset;
     _tree = tree;
 }
Exemplo n.º 3
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;
        }