Commit f7d1e6a3 authored by lafabregue's avatar lafabregue

Add Import of clustering from KMeans

parent dd622006
......@@ -66,7 +66,7 @@ public class ImageSession {
public SSHParameters sshparameters = null;
/** enable the image to display the image or not, for a memory usage matter */
private boolean displayEnable = false;
private boolean displayEnable = true;
/**
* @param aImage
......
......@@ -23,9 +23,13 @@ ClassifierPanel.105=error\! class:ClassifierPanel, method:getParameters
ClassifierPanel.106=INFO: AHC Selected
ClassifierPanel.107=ERROR: Vous avez selectionne une methode qui n'est pas dans jComboBoxMethods
ClassifierPanel.108=error\! class:ClassifierPanel, method:getParameters
ClassifierPanel.1041=You must select an ARFF file.
ClassifierPanel.1042=Warning
ClassifierPanel.11=Classifier parameters
ClassifierPanel.110=Select a data
ClassifierPanel.111=Error
ClassifierPanel.112=Open
ClassifierPanel.113=Browse
ClassifierPanel.117=Select a data
ClassifierPanel.118=Error
ClassifierPanel.12=Attributes selection and weigths configuration
......
......@@ -19,16 +19,20 @@ ClassifierPanel.100=Learning agents ne doit pas etre vide
ClassifierPanel.101=sequence...
ClassifierPanel.102=other...
ClassifierPanel.103=Erreur
ClassifierPanel.1041=Vous devez choisir un fichier ARFF.
ClassifierPanel.1042=Attention
ClassifierPanel.105=error\! class:ClassifierPanel, method:getParameters
ClassifierPanel.106=INFO: AHC Selected
ClassifierPanel.107=ERROR: Vous avez selectionne une methode qui n'est pas dans jComboBoxMethods
ClassifierPanel.108=error\! class:ClassifierPanel, method:getParameters
ClassifierPanel.11=Classifier parameters
ClassifierPanel.110=Select a data
ClassifierPanel.111=Error
ClassifierPanel.117=Select a data
ClassifierPanel.118=Error
ClassifierPanel.12=Attributes selection and weigths configuration
ClassifierPanel.11=Parametres de classification
ClassifierPanel.110=Selectionner une donne
ClassifierPanel.111=Erreur
ClassifierPanel.112=Ouvrir
ClassifierPanel.113=Ouvrir
ClassifierPanel.117=Selectionner une donne
ClassifierPanel.118=Erreur
ClassifierPanel.12=Selection des attributs et configuration des poids
ClassifierPanel.121=segmentation
ClassifierPanel.13=L'image initiale n'est pas modifiee,
ClassifierPanel.135=segmentation
......@@ -36,20 +40,20 @@ ClassifierPanel.14=seule la donnee intermediaire utilisee
ClassifierPanel.15=dans ce clustering est modifiee.
ClassifierPanel.16=Attribute Selection
ClassifierPanel.17=Seeds Selection
ClassifierPanel.174=Select a data
ClassifierPanel.175=Error
ClassifierPanel.174=Selectionner une donne
ClassifierPanel.175=Erreur
ClassifierPanel.18=sequence...
ClassifierPanel.19=sequence...
ClassifierPanel.2=Use preselected seeds
ClassifierPanel.20=Sequence options
ClassifierPanel.209=Open Parameters
ClassifierPanel.21=About the method...
ClassifierPanel.215=Unknown file format
ClassifierPanel.216=Warning
ClassifierPanel.217=Parameters not open \!
ClassifierPanel.218=ERROR
ClassifierPanel.219=Save Agents
ClassifierPanel.22=Computation
ClassifierPanel.2=Utiliser les graines preselctionnees
ClassifierPanel.20=Option de la sequence
ClassifierPanel.209=Ouvrir les parameters
ClassifierPanel.21=A propos de la methode ...
ClassifierPanel.215=Format de fichier inconnu
ClassifierPanel.216=Attention
ClassifierPanel.217=Parametres non ouverts \!
ClassifierPanel.218=ERREUR
ClassifierPanel.219=Sauvegarder les agents
ClassifierPanel.22=Calcul
ClassifierPanel.222=The file already exists \!
ClassifierPanel.223=\nErase the file ?
ClassifierPanel.224=Unable to save the parameters
......
......@@ -32,18 +32,18 @@ public class WriteDistancesPath {
System.out.println("\t===> i = " + i);
int j= 0;
Iterator<DataObject> dataObjectIter_j = data.iterator(i+1, data.getNbObjects());
String line = "";
while(dataObjectIter_j.hasNext()) {
//System.out.println("\t\t " + i + " ===> j = " + (i+1+j));
dataObject2 = dataObjectIter_j.next();
//distance = DistanceDTWMD.getInstance().compute(attMultiDimSequence1, attMultiDimSequence2, parameterDTW);
distance = dataObject1.distance(dataObject2);
writer.print(distance);
if (j + 1 < data.getNbObjects())
writer.print(",");
else
writer.println();
line += (distance);
if (dataObjectIter_j.hasNext())
line += ",";
j++;
}
writer.println(line);
i++;
}
writer.flush();
......
......@@ -151,6 +151,88 @@ public class DataArffExchange {
return result;
}
/**
* Return a set of DataObjects that is stored in an arff file.
*
* @param path
* the path of the arff file
* @return the set of DataObjects
*/
public static List<DataObject> arffToDataObjects(String path) {
System.out.println("__________________________________________________________________________________________\n"); //$NON-NLS-1$
System.out.println("Read \""+path+"\" to extract centroids "); //$NON-NLS-1$
System.out.println("__________________________________________________________________________________________"); //$NON-NLS-1$
List<DataObject> dataObjects = new ArrayList<DataObject>();
try {
BufferedReader reader = new BufferedReader(new FileReader(new File(path)));
ArffReader arff = new ArffReader(reader, 1000);
Instances data = arff.getStructure();
data.setClassIndex(0);
Instance inst;
while ((inst = arff.readInstance(data)) != null) {
DataObject obj = new DataObject(inst.numAttributes());
// the first attribute is ignored because it is the index
for(int i = 0 ; i < inst.numAttributes() ; i++) {
obj.setAttribute(i, getAttribute(inst, i));
}
dataObjects.add(obj);
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
return dataObjects;
}
/**
* Return a set of DataObjects that is stored in an arff file.
*
* @param path
* the path of the arff file
* @return the set of DataObjects
*/
public static int[][] arffToClusteredIndexes(String path) {
System.out.println("__________________________________________________________________________________________\n"); //$NON-NLS-1$
System.out.println("Read \""+path+"\" to extract clustering "); //$NON-NLS-1$
System.out.println("__________________________________________________________________________________________"); //$NON-NLS-1$
int[][] result = null;
try {
BufferedReader reader = new BufferedReader(new FileReader(new File(path)));
ArffReader arff = new ArffReader(reader, 1000);
Instances data = arff.getStructure();
data.setClassIndex(0);
List<List<Integer>> instances = new ArrayList<List<Integer>>();
// we don't know the size of the data a priori
// so we first need to write in a List Object
Instance inst;
while ((inst = arff.readInstance(data)) != null) {
List<Integer> couple = new ArrayList<Integer>();
couple.add((int) inst.value(0));
couple.add((int) inst.value(1));
instances.add(couple);
}
// then we transfer it to an array
result = new int[instances.size()][2];
for (int i = 0 ; i < instances.size() ; i++) {
result[i][0] = instances.get(i).get(0);
result[i][1] = instances.get(i).get(1);
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
private static jcl.data.attribute.Attribute getAttribute(Instance inst, int index) {
switch(inst.attribute(index).type()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment