Bonjour à tous,
Je construits des classifieur avec Weka sous un projet Java. En faite, le problème de IllegalArgumentException sur une variable du type String persiste meme en imposant au code un boucle while pour me trouver une variable String qui est contenu dans la liste : en plus le String qu'il déclenche toujours l'exception a le caractère "N" (n majuscule) qui manque à la variable String
Voila l'erreur qui me génère 1 fois sur 3 en moyenne cette exception :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 java.lang.IllegalArgumentException: Value not defined for given nominal attribute! at weka.core.Instance.setValue(Instance.java:692) at reconstructingData.RandReconstructedInstance.updateRandInstWithOutMissingValues(RandReconstructedInstance.java:202)
Sinon voila le bout du code où le programme leve cette Exception
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 if (attToUpdate.isNominal() || attToUpdate.isString()) { String stringUpdate = ""; boolean trouve = true; int indexUpdate =0; while (trouve) { int j = rand.nextInt(tabUpdating.size()); stringUpdate = tabUpdating.get(j); if (tabUpdating.contains(stringUpdate)) { indexUpdate = tabUpdating.indexOf(stringUpdate); trouve = false; } else { trouve = true; }//end if else }//en while try{ toUpdate.setValue(index, tabUpdating.get(indexUpdate)); }catch(IllegalArgumentException e){ e.printStackTrace(); JOptionPane.showMessageDialog(null," "+tabUpdating.get(indexUpdate)+ "\nWARNING ! Exception de type"+ e +"\n"+ e.getLocalizedMessage() + "\nValue not defined for given nominal attribute!\n", "ERROR", JOptionPane.ERROR_MESSAGE); System.exit(0); } }
A bientôt,
Partager