Salut
j'ai une BDD "diabete.txt" où chaque ligne représente un patient et chaque colonne est une caractéristique:
j'ai représenté chaque patient par la classe Antigene:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 1.0000 89.0000 66.0000 23.0000 94.0000 28.1000 0.1670 21.0000 0 0 137.000 40.0000 35.0000 168.000 43.1000 2.2880 33.0000 1.000 3.0000 78.0000 50.0000 32.0000 88.0000 31.0000 0.2480 26.0000 2.000
et j'ai utilisé un ArrayList pour stoker tout les patient:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 public class Antigene implements Serializable{ private final double [] attributs;// les 8 premières colonnes private final int classId;// la 9eme colonne public Antigene (double [] aAttributs, int aClassIndex) { attributs = aAttributs; classId = aClassIndex; } public double [] getAttributes() { return attributs; } public int getClassIndex() { return classId; } }
le problème c'est que quand je parcours le tableau "antigenes" , pour la classe de chaque patient j'obtiens la classe correcte mais pour le le tableau aAttribut qui contient les 8 caractéristiques j'obtiens pour les 3 patients les caractéristiques du dernier patient:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 public class EnsembleAg implements Serializable{ protected final ArrayList<Antigene> antigenes; Scanner scanner; Antigene ag; int numAttribut; public EnsembleAg(String cheminFichier, int numAttributs){ numAttribut=numAttributs; double [] aAttributs = new double[numAttribut]; antigenes= new ArrayList<Antigene>(); int aClassIndex = 4; int i=0; try { scanner=new Scanner(new File(cheminFichier)); double champ; while (scanner.hasNext()) { for (int j=0; j<numAttribut; j++){ champ = Double.parseDouble(scanner.next()); aAttributs[j]=champ; } champ = Double.parseDouble(scanner.next()); aClassIndex=(int)champ; ag=new Antigene(aAttributs,aClassIndex); System.out.println(ag); antigenes.add(ag); } scanner.close(); for (int t=0; t<antigenes.size(); t++) { Antigene a=antigenes.get(t) ; System.out.println(a+" "+a.getClassIndex()); double [] aAttribut=a.getAttributes(); for(int j=0; j<numAttribut; j++){ System.out.println(j+" "+aAttribut[j]); } } } catch (Exception e) { e.printStackTrace(); } }
si quelqu'un vois où est le problème? car moi j'ai passé toute la journée à regarder ce code et rien
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 init.Antigene@503429 0 0 3.0 1 78.0 2 50.0 3 32.0 4 88.0 5 31.0 6 0.248 7 26.0 init.Antigene@1908ca1 1 0 3.0 1 78.0 2 50.0 3 32.0 4 88.0 5 31.0 6 0.248 7 26.0 init.Antigene@100ab23 2 0 3.0 1 78.0 2 50.0 3 32.0 4 88.0 5 31.0 6 0.248 7 26.0
merci pour votre aide
Partager