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

Merge remote-tracking branch 'origin/master' into matissedekeiser

# Conflicts:
#	DevEfficace/rapport.md
parents ba685f92 d651db50
No related branches found
No related tags found
No related merge requests found
......@@ -90,7 +90,7 @@ Pour obtenir le meilleur **K**, on appelle la méthode `bestK(List<LoadableData>
En appliquant cette méthode, voici les résultats que nous avons obtenus avec :
##### Iris
### Iris
| Distance \ k | 1 | 3 | 5 | 7 | 9 | 11 | k choisi |
|-----------------------------------|-------|-------|-------|-------|-------|-------|----------|
......@@ -101,7 +101,9 @@ En appliquant cette méthode, voici les résultats que nous avons obtenus avec :
On obtient donc un taux de réussite plutôt élevé. À chaque fois, l'algorithme choisit le K avec le plus haut taux de réussite. En cas d'égalité, il choisit le plus petit K parmi les égalités.
##### Pokémon
### Pokemon
**Classification selon le type**
| Distance \ k | 1 | 3 | 5 | 7 | 9 | 11 | 13 | 15 | 17 | 19 | 21 | k choisi |
|-----------------------------------|-------|-------|-------|-------|-------|-------|----|----|----|----|----|----------|
......@@ -114,7 +116,20 @@ On obtient donc un taux de réussite plutôt élevé. À chaque fois, l'algorith
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.
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é
......
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
......@@ -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">
<scene>
<Scene>
<AnchorPane prefHeight="406.0" prefWidth="385.0">
<AnchorPane prefHeight="458.0" prefWidth="389.0">
<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>
<Button fx:id="confirmAdd" mnemonicParsing="false" onAction="#validate" stylesheets="@../css/style.css" text="Valider" textFill="WHITE">
<font>
<Font name="System Bold" size="13.0" />
</font></Button>
</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>
</Scene>
</scene>
......
......@@ -91,7 +91,7 @@ public class LoadDataController {
ClassificationModel.getClassificationModel().setType(typeChoisi);
try {
DataVisualizationView.resetAxis();
DataVisualizationView.resetEachAxis();
LoadableData.setClassificationTypeGlobal(-1);
ClassificationModel.getClassificationModel().loadData(file);
ChooseAttributesView chooseAttributesView = new ChooseAttributesView(ClassificationModel.getClassificationModel(), (Stage) stage.getOwner());
......
......@@ -169,6 +169,9 @@ public class MethodKNN {
MethodKNN.updateModel(model.getDatas());
System.out.println();
// Permet de definir l'attribut sur lequel ont souhaite classifier:
LoadableData.setClassificationTypeGlobal(12);
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é.
Collections.shuffle(datas);
......
......@@ -3,7 +3,7 @@ package fr.univlille.sae.classification.model;
public enum DataType {
IRIS(4, Iris.class),
POKEMON(11, Pokemon.class);
POKEMON(12, Pokemon.class);
private final int argumentSize;
private final Class<? extends LoadableData> clazz;
......
......@@ -18,6 +18,10 @@ public abstract class LoadableData {
protected static int classificationType = 1;
// Ho-Ho 130, 30720, 3, 90, 1250000, 106, 154, 90 fire, flying, 199s
/**
* Constructeur par défaut.
*/
......
package fr.univlille.sae.classification.model;
import java.util.Arrays;
/**
* Usine pour créer des objets LoadableData en fonction du type de données.
*/
......@@ -15,7 +17,7 @@ public class PointFactory {
public static LoadableData createPoint(DataType type, Object[] coords) throws IllegalArgumentException {
int size = coords.length;
LoadableData data;
System.out.println("Arrays : " + Arrays.toString(coords) + " " + size);
switch (type) {
case IRIS:
if (size != DataType.IRIS.getArgumentSize()) {
......@@ -25,14 +27,22 @@ public class PointFactory {
break;
case POKEMON:
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;
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) {
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]);
else if (coords.length == 12) {
try {
data = new Pokemon(coords);
} catch (IllegalAccessException e) {
throw new IllegalArgumentException("Une erreur est survenue lors de la création du point");
}
}
break;
default:
......
......@@ -2,6 +2,7 @@ package fr.univlille.sae.classification.model;
import com.opencsv.bean.CsvBindByName;
import java.lang.reflect.Field;
import java.util.*;
public class Pokemon extends LoadableData{
......@@ -34,7 +35,7 @@ public class Pokemon extends LoadableData{
@CsvBindByName(column = "speed")
private double speed;
@CsvBindByName(column = "is_legendary")
private boolean isLegendary;
private Boolean isLegendary = null ;
......@@ -60,9 +61,23 @@ public class Pokemon extends LoadableData{
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]);
}
*/
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.
......@@ -88,7 +103,13 @@ public class Pokemon extends LoadableData{
*/
@Override
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));
}
}
......
......@@ -8,6 +8,7 @@ import fr.univlille.sae.classification.model.LoadableData;
import fr.univlille.sae.classification.utils.Observable;
import fr.univlille.sae.classification.utils.ViewUtil;
import javafx.scene.Node;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.ScatterChart;
import javafx.scene.chart.XYChart;
import javafx.scene.layout.HBox;
......@@ -22,7 +23,7 @@ import java.util.*;
*/
public abstract class DataVisualizationView {
private static Set<DataVisualizationView> views;
private static Set<DataVisualizationView> views = new HashSet<>();
public DataVisualizationController controller;
......@@ -49,8 +50,18 @@ public abstract class DataVisualizationView {
}
public static void resetAxis() {
public static void resetEachAxis() {
// call method resetAxis for each instance of DataVisualizationView (views)
for(DataVisualizationView view : views) {
view.resetAxis();
}
}
public void resetAxis(){
setActualY("");
setActualX("");
((NumberAxis) scatterChart.getXAxis()).setLabel("");
((NumberAxis) scatterChart.getYAxis()).setLabel("");
}
/**
......@@ -158,7 +169,7 @@ public abstract class DataVisualizationView {
if(editSerie == null){
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);
}
......@@ -195,8 +206,6 @@ public abstract class DataVisualizationView {
return;
}
LoadableData newData = (LoadableData) data;
if (actualX == null || actualY == null) {
controller.setAxesSelected("Aucuns axes sélectionnés");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment