Implémenter algorithme arbre de décision

Fermé
hamma.manel1 - Modifié le 7 juin 2019 à 08:46
 hamma.manel1 - 7 juin 2019 à 20:22
Bonjour,

j'ai un algorithme de l'arbre de décision qui est appliqué sur une table de listeview comme suite
private string[][] Data = {
             new string[] {"mma","nul", "chomage"},
            new string[] {"sigl","nul", "travail"},
            new string[] {"mma", "nul",  "chomage"},
           new string[] {"mma", "bon", "travail"}};

je veut l'appliquer sur une table Sql comment je peut faire ca aider moi s'il vous plait c'est tres important une question de vie ou mort <lol>

Configuration: Windows / Firefox 67.0

1 réponse

yg_be Messages postés 22707 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 19 avril 2024 1 471
7 juin 2019 à 17:57
bonjour, comment pouvons-nous t'aider à modifier quelque chose que tu ne nous montres pas?
0
hamma.manel1
7 juin 2019 à 20:22
bonjour
j'ai cette partie de code que je veut l'appliquer sure une table que j'ai fais la connexion avec Sql Server et je l'ai afficher dans DataGrideView comment faire pour appliquer se programme sur ma table

namespace Entropie
{
/// <summary>
/// Classe d'affichage
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
#region Data
private System.Windows.Forms.TreeView ID3Tree;
private TreeNode _root;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.ComponentModel.Container components = null;
LabelNode _tree;

private string[][] ecole = {
new string[] {"scia","moyen","travail"},
new string[] {"scia", "bon", "travail"},
new string[] {"mma","nul", "chomage"},
new string[] {"sigl","nul", "travail"},
new string[] {"mma", "nul", "chomage"},
new string[] {"mma", "bon", "travail"}};
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;

private int[] reste = {0,1};
#endregion

#region constructeur
public Form1()
{
InitializeComponent();
this._root = new TreeNode("Arbre de décision résultant de ID3");
this.ID3Tree.Nodes.Add(this._root);
this.ID3Tree.Nodes[0].Tag="ROOT";
}
#endregion

#region Dispose
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#endregion

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.ID3Tree = new System.Windows.Forms.TreeView();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// ID3Tree
//
this.ID3Tree.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.ID3Tree.Location = new System.Drawing.Point(8, 16);
this.ID3Tree.Name = "ID3Tree";
this.ID3Tree.Size = new System.Drawing.Size(392, 336);
this.ID3Tree.TabIndex = 0;
this.ID3Tree.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.ID3Tree_AfterSelect);
//
// button1
//
this.button1.Location = new System.Drawing.Point(16, 368);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(96, 23);
this.button1.TabIndex = 1;
this.button1.Text = "Créer arbre ID3";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(320, 368);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(80, 24);
this.button2.TabIndex = 2;
this.button2.Text = "Quitter";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(224, 368);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(80, 23);
this.button3.TabIndex = 3;
this.button3.Text = "Classification";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button4
//
this.button4.Location = new System.Drawing.Point(128, 368);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(80, 24);
this.button4.TabIndex = 4;
this.button4.Text = "SGBD";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(408, 398);
this.Controls.Add(this.button4);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.ID3Tree);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);

}
#endregion

#region Main
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
#endregion

#region ID3Tree_AfterSelect
private void ID3Tree_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
{

}
#endregion

#region fermeture de fenetre
/// <summary>
/// Bouton de fermeture de fenetre
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button2_Click(object sender, System.EventArgs e)
{
this.Close();
}
#endregion

#region Parcours_tree
/// <summary>
/// Fonction recusive d'affichage de l'arbr ID3
/// </summary>
/// <param name="temp"></param>
/// <param name="tempA"></param>
public void Parcours_tree(LabelNode temp,TreeNode tempA)
{

if ((temp.Get_SonNode() == null) || (temp.Get_SonNode().Count == 0))
{
}
else
{
for (int i = 0; i < temp.Get_SonNode().Count; i++)
{
string aff = (string)temp.Get_label()[i];
LabelNode ID3temp= (LabelNode)temp.Get_SonNode()[i];
this.ID3Tree.SelectedNode = tempA;
TreeNode tmp =new TreeNode(aff +"->"+ ID3temp.Get_NodeName());
this.ID3Tree.SelectedNode.Nodes.Add(tmp);
Parcours_tree(ID3temp, tmp);
}
}
}
#endregion

#region button1_Click
/// <summary>
/// Lance la création de l'arbre ID3
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, System.EventArgs e)
{
ID3 temp = new ID3();
this._root.Nodes.Clear();
this._tree = temp.ID3algorithme(ecole,reste, 2);
this.Parcours_tree(this._tree,this._root);
}
#endregion

private void button3_Click(object sender, System.EventArgs e)
{
Resultat temp = new Resultat(this._tree);
temp.Activate();
temp.ShowDialog();
}

private void button4_Click(object sender, System.EventArgs e)
{
BD Tempt = new BD(ecole);
Tempt.Activate();
Tempt.ShowDialog();
}

private void Form1_Load(object sender, EventArgs e)
{

}
}
}
0