Compare commits
1 Commits
master
...
08.04.26-m
| Author | SHA1 | Date | |
|---|---|---|---|
| c13bb289ed |
@@ -27,8 +27,8 @@ public class Application {
|
||||
Function<Poisson,Double> getInfes = Poisson::getInfestation;
|
||||
BiConsumer<Poisson,Double> setInfes = Poisson::setInfestation;
|
||||
|
||||
mackerelSet = Nettoyage.nettoieColumns( mackerelSet, getInfes, setInfes, false );
|
||||
mackerelSet = Completion.completeColumnsLinear( mackerelSet, getLength, getInfes, setInfes );
|
||||
mackerelSet = Nettoyage.nettoieColumnsLinear( mackerelSet, getLength, getInfes, setInfes, false );
|
||||
|
||||
HashSet<ValeursXY> mackerelXY = ValeursXY.convertToXY( mackerelSet, getLength, getInfes );
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public class LectureEval {
|
||||
|
||||
public static void main(String[] args) throws RawDataOverflow {
|
||||
|
||||
RawData popRaw; int index;
|
||||
RawData popRaw;
|
||||
try {
|
||||
popRaw = InputFactory.readData("test3.csv", "," );
|
||||
} catch(InputFileException e) {
|
||||
@@ -91,32 +91,30 @@ public class LectureEval {
|
||||
|
||||
// System.out.println( popRaw.getEntry(1) );
|
||||
|
||||
index = 1;
|
||||
for( Population p: pop){
|
||||
System.out.println(String.valueOf(index++) + p);
|
||||
System.out.println(p);
|
||||
}
|
||||
|
||||
// Nettoyage de la masse.
|
||||
// Complétion de la masse.
|
||||
Function<Population,Double> getWeight = population -> {
|
||||
return population.getTotal().getWidth() != null ? population.getTotal().getWidth().transformToDouble() : null;
|
||||
};
|
||||
BiConsumer<Population,Double> setWeight = (population, aDouble) -> {
|
||||
population.getTotal().setWidth(aDouble != null ? new PopulationArgInterval(aDouble,aDouble) : null);
|
||||
population.getTotal().setWidth(new PopulationArgInterval(aDouble,aDouble));
|
||||
};
|
||||
|
||||
pop = Nettoyage.nettoieColumns(pop, getWeight, setWeight, false);
|
||||
System.out.println("---");
|
||||
index = 1;
|
||||
for( Population p: pop){
|
||||
System.out.println(String.valueOf(index++) + p);
|
||||
}
|
||||
|
||||
// Complétion de la masse.
|
||||
pop = Completion.completeColumnsMoyenne(pop, getWeight, setWeight);
|
||||
System.out.println("---");
|
||||
index = 1;
|
||||
for( Population p: pop){
|
||||
System.out.println(String.valueOf(index++) + p);
|
||||
System.out.println(p);
|
||||
}
|
||||
|
||||
// Nettoyage de la masse.
|
||||
pop = Nettoyage.nettoieColumnsMoyenne(pop, getWeight, setWeight, false);
|
||||
System.out.println("---");
|
||||
for( Population p: pop){
|
||||
System.out.println(p);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,31 +14,6 @@ import java.util.function.Function;
|
||||
*/
|
||||
public class Nettoyage {
|
||||
|
||||
public static <T,V extends Number> HashSet<T> nettoieColumns(HashSet<T> list, Function<T,V> getValue, BiConsumer<T,V> setValue, boolean allowNegative ){
|
||||
|
||||
ArrayList<Double> array = new ArrayList<>();
|
||||
for ( T item : list) {
|
||||
if (getValue.apply(item)!= null){ //Test des valeurs null pour les Tests Unitaires. Je ne devrais pas en avoir.
|
||||
array.add(getValue.apply(item).doubleValue());
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(array);
|
||||
|
||||
int quartIndex = array.size()/4;
|
||||
Double firstQuart = array.get(quartIndex);
|
||||
Double thirdQuart = array.get(quartIndex *3);
|
||||
Double IQR = thirdQuart - firstQuart;
|
||||
|
||||
for(T item : list){
|
||||
if( getValue.apply(item) == null || getValue.apply(item).doubleValue() < firstQuart - (IQR * 1.5) || getValue.apply(item).doubleValue() > thirdQuart + (IQR * 1.5) || ( !allowNegative && getValue.apply(item).doubleValue() < 0 ) ){
|
||||
setValue.accept( item, null);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de remplacer les valeurs abérrantes d'un paramètre d'un HashSet par la moyenne des autres valeurs (non nulles).
|
||||
* Exemple d'utilisation : T = Poisson, V = Double, getValue = Poisson::getInfestation, setValue = Poisson::setInfestation.
|
||||
@@ -51,7 +26,6 @@ public class Nettoyage {
|
||||
* @param <T> Le type de données cobaye. Exemple : Poisson, Population
|
||||
* @param <V> Le type de la donnée à vérifier, doit être un Wrapper Number. Exemple : Double.
|
||||
*/
|
||||
/*
|
||||
public static <T,V extends Number> HashSet<T> nettoieColumnsMoyenne(HashSet<T> list, Function<T,V> getValue, BiConsumer<T,V> setValue, boolean allowNegative ){
|
||||
|
||||
Double mean = Completion.calculateMean(list, getValue);
|
||||
@@ -78,7 +52,6 @@ public class Nettoyage {
|
||||
|
||||
return list;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Polymorphisme de la fonction précédente. Autorise les valeurs abérrantes à être négative.
|
||||
@@ -89,10 +62,10 @@ public class Nettoyage {
|
||||
* @param <T>
|
||||
* @param <V>
|
||||
*
|
||||
* @see Nettoyage::nettoieColumns
|
||||
* @see Nettoyage::nettoieColumnsMoyenne
|
||||
*/
|
||||
public static <T,V extends Number> HashSet<T> nettoieColumns(HashSet<T> list, Function<T,V> getValue, BiConsumer<T,V> setValue){
|
||||
return nettoieColumns(list, getValue, setValue, true);
|
||||
public static <T,V extends Number> HashSet<T> nettoieColumnsMoyenne(HashSet<T> list, Function<T,V> getValue, BiConsumer<T,V> setValue){
|
||||
return nettoieColumnsMoyenne(list, getValue, setValue, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,7 +81,6 @@ public class Nettoyage {
|
||||
* @param <T> Le type de données cobaye. Exemple : Poisson, Population
|
||||
* @param <V> Le type de la donnée à vérifier, doit être un Wrapper Number. Exemple : Double.
|
||||
*/
|
||||
/*
|
||||
public static <T,V extends Number> HashSet<T> nettoieColumnsLinear(HashSet<T> list, Function<T,V> getX, Function<T,V> getY, BiConsumer<T,V> setY, boolean allowNegative ){
|
||||
|
||||
double meanX = Completion.calculateMean(list, getX);
|
||||
@@ -140,7 +112,6 @@ public class Nettoyage {
|
||||
|
||||
return list;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Polymorphisme de la fonction nettoyage de colonne linéaire avec par défaut, l'autorisation des valeurs négatives.
|
||||
@@ -152,9 +123,7 @@ public class Nettoyage {
|
||||
* @param <T>
|
||||
* @param <V>
|
||||
*/
|
||||
/*
|
||||
public static <T,V extends Number> HashSet<T> nettoieColumnsLinear(HashSet<T> list, Function<T,V> getX, Function<T,V> getY, BiConsumer<T,V> setY){
|
||||
return nettoieColumnsLinear(list, getX, getY, setY, true);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -77,6 +77,13 @@ public class Poisson{
|
||||
this.infestation = infestation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter de l'attribut length
|
||||
* @param length le Double de la nouvelle valeur de la length
|
||||
*/
|
||||
public void setLength(Double length) {
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter de l'attribut des parties de poisson.
|
||||
@@ -95,4 +102,6 @@ public class Poisson{
|
||||
String result = "[ %5s : %4f mm, %4f g, %4f taux d'infestation ]";
|
||||
return String.format(result, this.getClass().getSimpleName(), this.getLength(), this.getWeight(), this.getInfestation() );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -36,11 +36,4 @@ public class ValeursXY {
|
||||
return xy;
|
||||
}
|
||||
|
||||
/*
|
||||
public static ValeursXY getMinX( HashSet<ValeursXY> list ){
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
package ecoparasite.svg;
|
||||
|
||||
import ecoparasite.representation.ValeursXY;
|
||||
import ecoparasite.svg.elements.Element;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SVGFactory {
|
||||
@@ -73,4 +76,59 @@ public class SVGFactory {
|
||||
|
||||
}
|
||||
|
||||
public static HashMap< String ,HashSet<ValeursXY>> PointAXES(HashSet<ValeursXY> h){
|
||||
|
||||
//Définition initial
|
||||
HashSet<ValeursXY> x = new HashSet<>();
|
||||
HashSet<ValeursXY> y = new HashSet<>();
|
||||
HashSet<ValeursXY> offset = new HashSet<>();
|
||||
HashMap< String, HashSet<ValeursXY> > map = new HashMap<>();
|
||||
|
||||
//Définition des min et max
|
||||
double max_x = Double.MIN_VALUE;
|
||||
double min_x = Double.MAX_VALUE;
|
||||
double max_y = Double.MIN_VALUE;
|
||||
double min_y = Double.MAX_VALUE;
|
||||
|
||||
//Trouvé les min et max
|
||||
for (ValeursXY var : h) {
|
||||
|
||||
if (max_x < var.getX()){
|
||||
max_x = var.getX();
|
||||
} else if (min_x > var.getX()){
|
||||
min_x = var.getX();
|
||||
}
|
||||
|
||||
if (max_y < var.getY()){
|
||||
max_y = var.getY();
|
||||
} else if (min_y > var.getY()){
|
||||
min_y = var.getY();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
double step_x = (max_x - min_x); //TODO
|
||||
double step_y = (max_y - min_y); //TODO
|
||||
|
||||
|
||||
//TODO
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* retourne une valeur arrondi "joli" adapter à un graphique
|
||||
* @param value
|
||||
* @param step
|
||||
* @return
|
||||
*/
|
||||
public static double roundMin(double value, double step) {
|
||||
return Math.floor(value / step) * step;
|
||||
}
|
||||
|
||||
public static double roundMax(double value, double step) {
|
||||
return Math.ceil(value / step) * step;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import ecoparasite.input.InputFactory;
|
||||
import ecoparasite.input.InputFileException;
|
||||
import ecoparasite.input.RawData;
|
||||
import ecoparasite.input.RawDataOverflow;
|
||||
import ecoparasite.nettoyage.Nettoyage;
|
||||
import ecoparasite.poisson.Mackerel;
|
||||
import ecoparasite.poisson.Poisson;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -45,7 +44,6 @@ class CompletionTest {
|
||||
Function<Poisson,Double> getInfes = Poisson::getInfestation;
|
||||
BiConsumer<Poisson,Double> setInfes = Poisson::setInfestation;
|
||||
|
||||
testp = Nettoyage.nettoieColumns(testp,getInfes,setInfes,false);
|
||||
testp = Completion.completeColumnsLinear(testp,getLength,getInfes,setInfes);
|
||||
System.out.println(testp);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,11 @@ class NettoyageTest {
|
||||
Function<Poisson,Double> getInfes = Poisson::getInfestation;
|
||||
BiConsumer<Poisson,Double> setInfes = Poisson::setInfestation;
|
||||
|
||||
testp = Nettoyage.nettoieColumns( testp, getInfes, setInfes, false );
|
||||
testp = Completion.completeColumnsLinear( testp, getLength, getInfes, setInfes );
|
||||
|
||||
System.out.println(testp);
|
||||
|
||||
testp = Nettoyage.nettoieColumnsLinear( testp, getLength, getInfes, setInfes, false );
|
||||
|
||||
System.out.println(testp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user