Commit 540054ed authored by lafabregue's avatar lafabregue

minor modifications

parent 5f890291
......@@ -23,6 +23,7 @@ import jcl.data.mask.Mask;
import jcl.data.mask.MultiIDIntArrayMask;
import jcl.evaluation.clustering.ClusteringEvaluation;
import jcl.learning.LearningResult;
import jcl.utils.RandomizeTools;
import jcl.utils.exceptions.JCLFormatException;
import jcl.utils.io.JCLModelExchange;
import jcl.weights.ClassificationWeights;
......@@ -446,18 +447,18 @@ public class LearningResultKmeans extends LearningResult {
private void initSeeds(Data data, Vector samples, int nbClusters) {
DataObject[] seeds = new DataObject[nbClusters];
int nbClustersLeft = nbClusters;
int remaining = data.getNbObjects();
int index = 0;
if (samples == null || samples.contains(new Integer(-1))) {
for (int i = 0; i < data.getNbObjects(); i++) {
if (Math.random() < ((double) nbClustersLeft / (double) remaining)) {
seeds[index] = data.getDataObject(i);
index++;
nbClustersLeft--;
}
remaining--;
List<Integer> seedsIndexes = RandomizeTools.getReservoirSamplingIndex(data.getNbObjects(), nbClusters);
for (int i = 0; i < nbClusters ; i++) {
//TODO : <<<remove, was for test purpose
if (seedsIndexes.size() < i+1)
System.out.println("seeds too small");
if (data.getNbObjects() < seedsIndexes.get(i))
System.out.println("data too small");
// >>>
seeds[i] = data.getDataObject(seedsIndexes.get(i));
}
} else {// Dans le cas ou les centre initiaux sont donnes
// if centers are given by index
......@@ -482,26 +483,6 @@ public class LearningResultKmeans extends LearningResult {
this.seeds.add(new LightHardSeed(seeds[i], data, i));
}
/*
* private void initSeeds (Data data, Vector samples, int nbClusters) {
* this.seeds = new Vector<KmeansSeed> (); if ( (
* (ParametersKmeans)this.params).fuzzy) for (int i = 0; i < nbClusters;
* i++) { FuzzySeed s = null; if (samples == null || i >= samples.size ()) {
* boolean loop = true; while (loop) { s = new FuzzySeed (data.randomChoice
* (), data); loop = false; for (int j = 0; j < i; j++) if ( ( (
* (FuzzySeed)this.seeds.get (j)).distance (s.center, this.getWeights
* ().getGlobalWeights ())) == 0) loop = true; } } else { DataObject sample
* = (DataObject) samples.get (i); s = new FuzzySeed (sample, data); }
* this.seeds.add (s); } else { for (int i = 0; i < nbClusters; i++) {
* HardSeed s = null; if ( (samples == null) || (i >= samples.size ())) {
* boolean loop = true; while (loop) { s = new HardSeed (data.randomChoice
* (), data); loop = false; for (int j = 0; j < i; j++) if ( ( (
* (HardSeed)this.seeds.get (j)).distance (s.center, this.getWeights
* ().getGlobalWeights ())) == 0) loop = true; } } else { DataObject sample
* = (DataObject) (samples.get (i)); s = new HardSeed (sample, data); }
* this.seeds.add (s); } } }
*/
/**
* <p>
* Methode fusionnant les noyaux passes en parametre.
......@@ -521,22 +502,12 @@ public class LearningResultKmeans extends LearningResult {
newSeed.initialize();
newSeed.setId(this.seeds.size());
// for (int i = 0; i < newClusterMap.length; i++) {
// for(int j = 1 ; j < cr.size() ; j++) {
// if (newClusterMap[i] == (int) cr.get(0)) {
// newClusterMap[i] = newSeed.getId();
// break;
// }
// }
// }
for(int j = 0 ; j < cr.size() ; j++) {
idsToMerge[j] = (int) cr.get(j);
seedsToMerge.add(this.seeds.get((int)cr.get(j)));
}
this.seeds.removeAll(seedsToMerge);
// for(KmeansSeed s : this.seeds) {
// ((LightHardSeed) s).setClusterMap(newClusterMap, ((LightHardSeed) s).getNbObjects());
// }
Mask mask;
if (this.seeds.size() > 0) {
mask = new MultiIDIntArrayMask(clustermap, idsToMerge, false);
......
......@@ -209,6 +209,7 @@ public class HybridClassification extends Classification implements Runnable, It
for (int i = 0; i < this.agents.size(); i++) {
final LearningAgent c = this.getAgent(i);
threads[i] = new Thread(c);
threads[i].start();
}
try {
......@@ -1233,6 +1234,7 @@ public class HybridClassification extends Classification implements Runnable, It
*/
public ClusteringResult unification(boolean onSample) {
return unification_relative(this.data, onSample);
// return unification(this.data, onSample);
}
/**
......
......@@ -4,59 +4,56 @@
<samarah-config>
<!-- modes de raffinement proposés :
0 - raffinement standard
1 - coherence directe
2 - coherence de classe
3 - coherence de zone (pas encore implanté)
4 - ponderation de decisions
-->
<!-- NOMBRE DE PARAMETREs A LIRE (hors celui-ci) : -->
<NBVAR value = "15" />
<refinement-mode value = "0" />
<verbose-mode value = "true" />
<importance-Kinterne value = "0.5" />
<importance-Kexterne value = "0.5" />
<critere_qualite_inter value = "1" />
<!-- Voir classe ClusteringEvaluation : 0-"WG", 1-"Square error", 2-"Compactness",
"Fuzzy square error", "Predictivity", "Log-Likelihood Sum", "XB",
"Fuzzy XB", "Dunn", "Bezdek", "DB", "PE", "Modified Hubert", "Tradeoff", "Rand from knowledge",
"Jarque-Bera" -->
<!-- Si -1 non utilises -->
<ninf value = "5" />
<nsup value = "8" />
<!-- modes de raffinement proposés : 0 - raffinement standard 1 - coherence
directe 2 - coherence de classe 3 - coherence de zone (pas encore implanté)
4 - ponderation de decisions -->
<!-- NOMBRE DE PARAMETREs A LIRE (hors celui-ci) : -->
<NBVAR value="15" />
<refinement-mode value="0" />
<verbose-mode value="true" />
<importance-Kinterne value="0.5" />
<importance-Kexterne value="0.5" />
<critere_qualite_inter value="1" />
<!-- Voir classe ClusteringEvaluation : 0-"WG", 1-"Square error", 2-"Compactness",
"Fuzzy square error", "Predictivity", "Log-Likelihood Sum", "XB", "Fuzzy
XB", "Dunn", "Bezdek", "DB", "PE", "Modified Hubert", "Tradeoff", "Rand from
knowledge", "Jarque-Bera" -->
<!-- Si -1 non utilises -->
<ninf value="5" />
<nsup value="8" />
<standard-refinement>
<!-- parametrage pour le raffinement standard,
pour plus de details, voir la description du systeme SAMARAH -->
<ps-similarity value = "0.3" />
<pq-quality value = "0.7" />
<min-conflict-importance value = "0.40" />
<max-nb-useless-iterations value = "8" />
<representative-cluster-threshold value = "0.05" />
<!-- parametrage pour le raffinement standard, pour plus de details, voir
la description du systeme SAMARAH -->
<ps-similarity value="0.3" />
<pq-quality value="0.7" />
<min-conflict-importance value="0.40" />
<max-nb-useless-iterations value="8" />
<representative-cluster-threshold
value="0.05" />
</standard-refinement>
<cluster-coherence>
<!-- parametrage pour l'utilisation de la coherence de classe
voir p.17 du rapport d'etape 2 (projet CNES) -->
<split-threshold value = "2.4" />
<merge-threshold value = "0.8" />
<max-nb-ope value = "16" />
<!-- parametrage pour l'utilisation de la coherence de classe voir p.17
du rapport d'etape 2 (projet CNES) -->
<split-threshold value="2.4" />
<merge-threshold value="0.8" />
<max-nb-ope value="16" />
</cluster-coherence>
</samarah-config>
\ No newline at end of file
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