Skip to content
Snippets Groups Projects
Commit d651db50 authored by Matisse DEKEISER's avatar Matisse DEKEISER
Browse files

Merge branch 'matiasmennecart' into 'master'

Fix bug ajout de données

See merge request sae302/2024/H4_SAE3.3!32
parents e44ea82c 306f6f35
No related branches found
No related tags found
No related merge requests found
...@@ -97,7 +97,7 @@ Pour obtenir le meilleur K, on appel la methode bestK(List<LoadableData> datas, ...@@ -97,7 +97,7 @@ Pour obtenir le meilleur K, on appel la methode bestK(List<LoadableData> datas,
En appliquant cette methode voici les resultats que nous avons obtenue avec: En appliquant cette methode voici les resultats que nous avons obtenue avec:
##### Iris ### Iris
...@@ -110,7 +110,9 @@ En appliquant cette methode voici les resultats que nous avons obtenue avec: ...@@ -110,7 +110,9 @@ En appliquant cette methode voici les resultats que nous avons obtenue avec:
On obtient donc un taux de reussiste plutôt élevé. A chaque fois l'algorithme choisit le K avec le plus haut taux de reussite. En cas d'égalité, il choisit le plus petit K parmis les égalités. On obtient donc un taux de reussiste plutôt élevé. A chaque fois l'algorithme choisit le K avec le plus haut taux de reussite. En cas d'égalité, il choisit le plus petit K parmis les égalités.
##### Pokemon ### Pokemon
**Classification selon le type**
| Distance \ K | 1 | 3 | 5 | 7 | 9 | 11 | 13 | 15 | 17 | 19 | 21 | K choisit | | Distance \ K | 1 | 3 | 5 | 7 | 9 | 11 | 13 | 15 | 17 | 19 | 21 | K choisit |
|---------------------------------|-------|-------|-------|-------|-------|-------|----|----|----|----|----|----| |---------------------------------|-------|-------|-------|-------|-------|-------|----|----|----|----|----|----|
...@@ -123,7 +125,20 @@ On obtient donc un taux de reussiste plutôt élevé. A chaque fois l'algorithme ...@@ -123,7 +125,20 @@ On obtient donc un taux de reussiste plutôt élevé. A chaque fois l'algorithme
Le taux de reussiste est ici plus bas, cela s'explique notement par le nombre d'attribut different et la complexité a identifier le type d'un pokemon. Le taux de reussiste est ici plus bas, cela s'explique notement par le nombre d'attribut different et la complexité a identifier le type d'un pokemon.
Cependant le taux de reussiste reste satisfaisant et stable. Cependant le taux de reussiste reste satisfaisant et stable.
Classification par isLegendary **Classification Legendaire ou Non Legendaire**
| Distance \ K | 1 | 3 | 5 | 7 | 9 | 11 | 13 | 15 | 17 | 19 | 21 | K choisit |
|---------------------------------|-------|-------|-------|-------|-------|-------|----|----|----|----|----|----|
| Distance Euclidienne | 0.986 | 0.978 | 0.984 | 0.980 | 0.984 | 0.984 | 0.984 | 0.984 | 0.984 | 0.984 | 0.984 | 1 |
| Distance Euclidienne Normalisée | 1.0 | 0.998 | 0.998 | 0.996 | 0.996 | 0.998 | 0.998 | 0.998 | 0.998 | 0.998 | 0.998 | 1 |
| Distance Manhattan | 0.978 | 0.972 | 0.984 | 0.980 | 0.984 | 0.984 | 0.984 | 0.984 | 0.984 | 0.984 | 0.984 | 5 |
| Distance Manhattan Normalisée | 0.980 | 0.984 | 0.988 | 0.984 | 0.984 | 0.986 | 0.986 | 0.986 | 0.986 | 0.986 | 0.984 | 5 |
On a ici des résultats bien meilleurs. En effet, estimer si un Pokemon est legendaire ou non est bien plus simple qu'estimer son type, les attributs des pokemons legendaires sont bien différent des pokemons non-legendaire contrairement aux types, ou selon les types, les valeurs ne fluctuent pas autant
---
## Efficacité ## Efficacité
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.*?> <?import javafx.scene.*?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
...@@ -9,16 +10,19 @@ ...@@ -9,16 +10,19 @@
<Stage fx:id="stage" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.univlille.sae.classification.controller.AddDataController"> <Stage fx:id="stage" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.univlille.sae.classification.controller.AddDataController">
<scene> <scene>
<Scene> <Scene>
<AnchorPane prefHeight="406.0" prefWidth="385.0"> <AnchorPane prefHeight="458.0" prefWidth="389.0">
<children> <children>
<VBox alignment="CENTER" layoutY="385.0" prefHeight="38.0" prefWidth="384.0" spacing="20.0"> <VBox alignment="CENTER" layoutX="1.0" layoutY="420.0" prefHeight="38.0" prefWidth="384.0" spacing="20.0">
<children> <children>
<Button fx:id="confirmAdd" mnemonicParsing="false" onAction="#validate" stylesheets="@../css/style.css" text="Valider" textFill="WHITE"> <Button fx:id="confirmAdd" mnemonicParsing="false" onAction="#validate" stylesheets="@../css/style.css" text="Valider" textFill="WHITE">
<font> <font>
<Font name="System Bold" size="13.0" /> <Font name="System Bold" size="13.0" />
</font></Button> </font></Button>
</children></VBox> </children></VBox>
<VBox fx:id="entries" layoutY="16.0" prefHeight="366.0" prefWidth="385.0" spacing="10.0" /> <VBox fx:id="entries" layoutY="-4.0" prefHeight="424.0" prefWidth="390.0" spacing="10.0">
<opaqueInsets>
<Insets top="1.0" />
</opaqueInsets></VBox>
</children></AnchorPane> </children></AnchorPane>
</Scene> </Scene>
</scene> </scene>
......
...@@ -169,6 +169,9 @@ public class MethodKNN { ...@@ -169,6 +169,9 @@ public class MethodKNN {
MethodKNN.updateModel(model.getDatas()); MethodKNN.updateModel(model.getDatas());
System.out.println(); System.out.println();
// Permet de definir l'attribut sur lequel ont souhaite classifier:
LoadableData.setClassificationTypeGlobal(12);
List<LoadableData> datas = ClassificationModel.getClassificationModel().getDatas(); List<LoadableData> datas = ClassificationModel.getClassificationModel().getDatas();
// On mélange les données pour tester sur differentes variétes car le fichier de base est trié. // On mélange les données pour tester sur differentes variétes car le fichier de base est trié.
Collections.shuffle(datas); Collections.shuffle(datas);
......
...@@ -3,7 +3,7 @@ package fr.univlille.sae.classification.model; ...@@ -3,7 +3,7 @@ package fr.univlille.sae.classification.model;
public enum DataType { public enum DataType {
IRIS(4, Iris.class), IRIS(4, Iris.class),
POKEMON(11, Pokemon.class); POKEMON(12, Pokemon.class);
private final int argumentSize; private final int argumentSize;
private final Class<? extends LoadableData> clazz; private final Class<? extends LoadableData> clazz;
......
...@@ -18,6 +18,10 @@ public abstract class LoadableData { ...@@ -18,6 +18,10 @@ public abstract class LoadableData {
protected static int classificationType = 1; protected static int classificationType = 1;
// Ho-Ho 130, 30720, 3, 90, 1250000, 106, 154, 90 fire, flying, 199s
/** /**
* Constructeur par défaut. * Constructeur par défaut.
*/ */
......
package fr.univlille.sae.classification.model; package fr.univlille.sae.classification.model;
import java.util.Arrays;
/** /**
* Usine pour créer des objets LoadableData en fonction du type de données. * Usine pour créer des objets LoadableData en fonction du type de données.
*/ */
...@@ -15,7 +17,7 @@ public class PointFactory { ...@@ -15,7 +17,7 @@ public class PointFactory {
public static LoadableData createPoint(DataType type, Object[] coords) throws IllegalArgumentException { public static LoadableData createPoint(DataType type, Object[] coords) throws IllegalArgumentException {
int size = coords.length; int size = coords.length;
LoadableData data; LoadableData data;
System.out.println("Arrays : " + Arrays.toString(coords) + " " + size);
switch (type) { switch (type) {
case IRIS: case IRIS:
if (size != DataType.IRIS.getArgumentSize()) { if (size != DataType.IRIS.getArgumentSize()) {
...@@ -25,14 +27,22 @@ public class PointFactory { ...@@ -25,14 +27,22 @@ public class PointFactory {
break; break;
case POKEMON: case POKEMON:
if(size != DataType.POKEMON.getArgumentSize()) { if(size != DataType.POKEMON.getArgumentSize()) {
throw new IllegalArgumentException("Le nombre de coordonnées doit être de 11 pour le type POKEMON."); throw new IllegalArgumentException("Le nombre de coordonnées doit être de 12 pour le type POKEMON.");
} }
data = null; data = null;
if (coords.length == 13) { if (coords.length == 13) {
data = new Pokemon(coords); try {
data = new Pokemon(coords);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException("Erreur lors de la création du Pokemon");
}
} }
else if (coords.length == 11) { else if (coords.length == 12) {
data = new Pokemon((String) coords[0], (Integer) coords[1], (Integer) coords[2], (Double) coords[3], (Integer) coords[4], (Integer) coords[5], (Integer) coords[6], (Integer) coords[7], (Integer) coords[8], "undefined", "", (Double) coords[9], (Boolean) coords[10]); try {
data = new Pokemon(coords);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException("Une erreur est survenue lors de la création du point");
}
} }
break; break;
default: default:
......
...@@ -2,6 +2,7 @@ package fr.univlille.sae.classification.model; ...@@ -2,6 +2,7 @@ package fr.univlille.sae.classification.model;
import com.opencsv.bean.CsvBindByName; import com.opencsv.bean.CsvBindByName;
import java.lang.reflect.Field;
import java.util.*; import java.util.*;
public class Pokemon extends LoadableData{ public class Pokemon extends LoadableData{
...@@ -34,7 +35,7 @@ public class Pokemon extends LoadableData{ ...@@ -34,7 +35,7 @@ public class Pokemon extends LoadableData{
@CsvBindByName(column = "speed") @CsvBindByName(column = "speed")
private double speed; private double speed;
@CsvBindByName(column = "is_legendary") @CsvBindByName(column = "is_legendary")
private boolean isLegendary; private Boolean isLegendary = null ;
...@@ -60,9 +61,23 @@ public class Pokemon extends LoadableData{ ...@@ -60,9 +61,23 @@ public class Pokemon extends LoadableData{
this.isLegendary = isLegendary; this.isLegendary = isLegendary;
} }
public Pokemon(Object[] list) { /** public Pokemon(Object[] list) {
this((String) list[0], (Integer) list[1], (Integer) list[2], (Double) list[3], (Integer) list[4], (Integer) list[5], (Integer) list[6], (Integer) list[7], (Integer) list[8], (String) list[9], (String) list[10], (Double) list[11], (Boolean) list[12]); this((String) list[0], (Integer) list[1], (Integer) list[2], (Double) list[3], (Integer) list[4], (Integer) list[5], (Integer) list[6], (Integer) list[7], (Integer) list[8], (String) list[9], (String) list[10], (Double) list[11], (Boolean) list[12]);
} }
*/
public Pokemon(Object[] list) throws IllegalAccessException {
Field[] fields = getClass().getDeclaredFields();
for(int i = 0; i<fields.length; i++) {
if(i != LoadableData.classificationType) {
fields[i].set(this, list[i]);
}else if(fields[i].getType().equals(String.class)) {
fields[i].set(this, "undefinied");
}
}
}
/** /**
* Constructeur par défaut. * Constructeur par défaut.
...@@ -88,7 +103,13 @@ public class Pokemon extends LoadableData{ ...@@ -88,7 +103,13 @@ public class Pokemon extends LoadableData{
*/ */
@Override @Override
public void setClassification(String classification) throws IllegalAccessException { public void setClassification(String classification) throws IllegalAccessException {
this.getClass().getDeclaredFields()[classificationType].set("", classification); Field field = this.getClass().getDeclaredFields()[classificationType];
if(field.getClass().equals(String.class)) {
field.set(this, classification);
}else if(field.getType().equals(Boolean.class)) {
field.set(this, Boolean.valueOf(classification));
}
} }
......
...@@ -23,7 +23,7 @@ import java.util.*; ...@@ -23,7 +23,7 @@ import java.util.*;
*/ */
public abstract class DataVisualizationView { public abstract class DataVisualizationView {
private static Set<DataVisualizationView> views = new HashSet<DataVisualizationView>(); private static Set<DataVisualizationView> views = new HashSet<>();
public DataVisualizationController controller; public DataVisualizationController controller;
...@@ -169,7 +169,7 @@ public abstract class DataVisualizationView { ...@@ -169,7 +169,7 @@ public abstract class DataVisualizationView {
if(editSerie == null){ if(editSerie == null){
editSerie = new ScatterChart.Series<Double, Double>(); editSerie = new ScatterChart.Series<Double, Double>();
} }
if(data.getClassification().equals("undefined") || model.getDataToClass().containsKey(data)) { if(data.getClassification().equals("undefined") || data.getClassification().equals("null") || model.getDataToClass().containsKey(data)) {
nodePoint = ViewUtil.getForm(data, new Rectangle(10,10), controller); nodePoint = ViewUtil.getForm(data, new Rectangle(10,10), controller);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment