Commit 7c38e5b9 authored by lafabregue's avatar lafabregue

fix in mask ietration and samarah

parent a2c981db
......@@ -18,7 +18,7 @@ public class LightCluster extends Cluster {
private int cardinal = -1;
/** indexes used to read object in the cluster */
private int clusterIndex = 0;
private int clusterIndex = -1;
/** iterator used to read object in the cluster */
private IntMaskIterator indexIterator = null;
......@@ -122,22 +122,25 @@ public class LightCluster extends Cluster {
}
@Override
public DataObject getObject(int objIndex) {
public DataObject getObject(int objIndex) {
boolean fromSample = result.getClusterMap().length == result.data.getNbObjects();
if(objIndex > clusterIndex) {
while(clusterIndex != objIndex && getIndexIterator(false).hasNext()) {
while(clusterIndex != objIndex && getIndexIterator(fromSample).hasNext()) {
clusterIndex++;
getIndexIterator(false).next();
getIndexIterator(fromSample).next();
}
return result.getData().getWholeDataDataObject(getIndexIterator(false).current());
} else if (objIndex < clusterIndex){
while(clusterIndex != objIndex && clusterIndex > 0) {
clusterIndex--;
getIndexIterator(false).previous();
}
return result.getData().getWholeDataDataObject(getIndexIterator(false).current());
getIndexIterator(fromSample).previous();
}
}
if (fromSample) {
return result.getData().getDataObject(getIndexIterator(fromSample).current());
} else {
return result.getData().getWholeDataDataObject(getIndexIterator(fromSample).current());
}
return result.getData().getWholeDataDataObject(getIndexIterator(false).current());
}
......
......@@ -568,7 +568,7 @@ public class SimpleData extends Data {
return this.currentView.get(i);
}
@Override
@Override
public DataObject getDataObject(int[] coordonneDataObject) {
int aux = 1;
int index = coordonneDataObject[coordonneDataObject.length - 1];
......
......@@ -160,12 +160,13 @@ public class IntArrayMask implements Mask {
private final int[] mask;
private final int id;
private final boolean ignore;
private boolean first = true;
public IntMaskIterator(final int[] mask, final int id, final boolean ignore) {
this.id = id;
this.mask = mask;
this.ignore = ignore;
this.cursor = 0;
this.cursor = -1;
this.end = getLastIndex(0, mask.length-1);
}
......@@ -174,7 +175,7 @@ public class IntArrayMask implements Mask {
this.id = id;
this.mask = mask;
this.ignore = ignore;
this.cursor = start;
this.cursor = start-1;
this.end = getLastIndex(start, end);
}
......@@ -206,16 +207,16 @@ public class IntArrayMask implements Mask {
}
public boolean hasNext() {
return this.cursor <= end;
return this.cursor < end;
}
public Integer next() {
int next = -1;
cursor++;
if (ignore) {
while(cursor <= end) {
if(mask[cursor] != id) {
next = cursor;
cursor++;
break;
} else {
cursor++;
......@@ -225,7 +226,6 @@ public class IntArrayMask implements Mask {
while(cursor <= end) {
if(mask[cursor] == id) {
next = cursor;
cursor++;
break;
} else {
cursor++;
......@@ -255,6 +255,12 @@ public class IntArrayMask implements Mask {
}
/**
* Return the last index called by next() method
* Warning : if no next() have been called it returns -1
*
* @return the last index returned by next() method
*/
public Integer current() {
return new Integer(cursor);
}
......
......@@ -944,9 +944,9 @@ public class LearningResultKmeans extends LearningResult {
}
// create Weights section
model = JCLModelExchange.addSection(model,
JCLModelExchange.MODEL_WEIGHT_SECTION,
JCLModelExchange.weightsToString(this.weights.getGlobalWeights()));
// model = JCLModelExchange.addSection(model,
// JCLModelExchange.MODEL_WEIGHT_SECTION,
// JCLModelExchange.weightsToString(this.weights.getGlobalWeights()));
// create dataObject section
List<DataObject> dataObjects = new ArrayList<DataObject>();
......
......@@ -245,6 +245,8 @@ public class HybridClassification extends Classification implements Runnable, It
// Choix des conflits a resoudre
this.conflicts = this.worthConflicts();
int a = 5;
a = 6;
for (int i = 0; i < this.conflicts.size(); i++) {
final SamarahConflict conf = this.conflicts.get(i);
......@@ -1309,6 +1311,7 @@ public class HybridClassification extends Classification implements Runnable, It
final int km = this.evalMax.alpha[i][j].maxColumn(k);
a = this.getAgent(j);
final int kj = clustermaps[j][p];
vote[j][km] += 1;
if (kj == km) {
stat[p] += 1;
......
......@@ -111,7 +111,7 @@ public class HybridClassificationConstrained extends jcl.learning.methods.multis
lastCstIndex++;
}
try {
c.injectConstraints(constraints);
c.injectConstraints(tmpSet);
} catch (MethodNotImplementedException e) {
e.printStackTrace();
}
......
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