Commit bd1cc665 authored by lafabregue's avatar lafabregue

finalisation of merge with master

parent 119b5fee
This diff is collapsed.
...@@ -20,6 +20,7 @@ import jcl.learning.methods.monostrategy.som.ParametersSOM; ...@@ -20,6 +20,7 @@ import jcl.learning.methods.monostrategy.som.ParametersSOM;
import jcl.weights.ClassificationWeights; import jcl.weights.ClassificationWeights;
import jcl.weights.GlobalWeights; import jcl.weights.GlobalWeights;
import jcl.weights.Weights; import jcl.weights.Weights;
import mustic.gui.DataDesktopFrame;
import mustic.gui.DesktopFrame; import mustic.gui.DesktopFrame;
import mustic.gui.ImageDesktopFrame; import mustic.gui.ImageDesktopFrame;
import mustic.gui.MainFrame; import mustic.gui.MainFrame;
...@@ -861,52 +862,52 @@ public class ClassifierHandler extends DefaultHandler { ...@@ -861,52 +862,52 @@ public class ClassifierHandler extends DefaultHandler {
} else if (qName.equals("InitMethod")) { //$NON-NLS-1$ } else if (qName.equals("InitMethod")) { //$NON-NLS-1$
Data data = null; Data data = null;
DesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop() DataDesktopFrame[] desktopFrames = MainFrame.getInstance().getDesktop()
.getAllDesktopFrames(); .getAllDataDesktopFrames();
int nbSessions = desktopFrames.length; int nbSessions = desktopFrames.length;
for (int i = 0; i < nbSessions; i++) { for (int i = 0; i < nbSessions; i++) {
if (this.listData.get(0).equals( if (this.listData.get(0).equals(
desktopFrames[i].getImageSession().getRawImage() desktopFrames[i].getDataSession().getAssociatedImageSessions().get(0)
.getPath())) { .getRawImage().getPath())) {
data = desktopFrames[i].getImageSession().getImageData(); data = desktopFrames[i].getDataSession().getData();
break; break;
} }
} }
if (data == null) { if (data == null) {
File f = new File(this.listData.get(0)); File f = new File(this.listData.get(0));
try { try {
MainFrame.getInstance().createSession( MainFrame.getInstance().createImageSession(
MainFrame.getInstance().open(f), null); MainFrame.getInstance().open(f), null);
if (MainFrame.getInstance().getCurrentSession() if (MainFrame.getInstance().getCurrentImageSession()
.getRawImage().getNbBands() > 1) { .getRawImage().getNbBands() > 1) {
MainFrame.getInstance().getCurrentSession() MainFrame.getInstance().getCurrentImageSession()
.getBirdViewPanel().setR(0); .getBirdViewPanel().setR(0);
MainFrame.getInstance().getCurrentSession() MainFrame.getInstance().getCurrentImageSession()
.getBirdViewPanel().setG(1); .getBirdViewPanel().setG(1);
MainFrame.getInstance().getCurrentSession() MainFrame.getInstance().getCurrentImageSession()
.getBirdViewPanel().setB(2); .getBirdViewPanel().setB(2);
MainFrame MainFrame
.getInstance() .getInstance()
.getCurrentSession() .getCurrentImageSession()
.getBirdViewPanel() .getBirdViewPanel()
.syncImage( .syncImage(
MainFrame.getInstance() MainFrame.getInstance()
.getCurrentSession()); .getCurrentImageSession());
PictureTool.setR(MainFrame.getInstance() PictureTool.setR(MainFrame.getInstance()
.getCurrentSession().getRawImage() .getCurrentImageSession().getRawImage()
.getBirdview(), 0); .getBirdview(), 0);
PictureTool.setG(MainFrame.getInstance() PictureTool.setG(MainFrame.getInstance()
.getCurrentSession().getRawImage() .getCurrentImageSession().getRawImage()
.getBirdview(), 1); .getBirdview(), 1);
PictureTool.setB(MainFrame.getInstance() PictureTool.setB(MainFrame.getInstance()
.getCurrentSession().getRawImage() .getCurrentImageSession().getRawImage()
.getBirdview(), 2); .getBirdview(), 2);
MainFrame.getInstance().getCurrentSession() MainFrame.getInstance().getCurrentImageSession()
.getBirdViewPanel().refresh(); .getBirdViewPanel().refresh();
MainFrame.getInstance().getCurrentSession().associatedFrame MainFrame.getInstance().getCurrentImageSession().associatedFrame
.toBack(); .toBack();
data = MainFrame.getInstance().getCurrentSession() data = MainFrame.getInstance().getCurrentImageSession()
.getData(); .getData();
} }
} catch (Exception e) { } catch (Exception e) {
......
...@@ -18,17 +18,9 @@ import jcl.Classification; ...@@ -18,17 +18,9 @@ import jcl.Classification;
import jcl.data.Data; import jcl.data.Data;
import jcl.data.DataObject; import jcl.data.DataObject;
import jcl.data.attribute.AttributeMultiDimSequence; import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.data.attribute.AttributeSequence;
import jcl.data.distance.Distance;
import jcl.data.distance.DistanceModel; import jcl.data.distance.DistanceModel;
import jcl.data.distance.DistanceParameter; import jcl.data.distance.DistanceParameter;
import jcl.data.distance.EmptyDistanceParameter;
import jcl.data.distance.average.AverageParameter; import jcl.data.distance.average.AverageParameter;
import jcl.data.distance.average.EmptyAverageParameter;
import jcl.data.distance.average.ParameterDBAMean;
import jcl.data.distance.sequential.DistanceDTW;
import jcl.data.distance.sequential.DistanceDTWMD;
import jcl.data.distance.sequential.ParameterDTW;
import jcl.io.arff.ClassificationParametersIO; import jcl.io.arff.ClassificationParametersIO;
import jcl.jcld.RmiServer; import jcl.jcld.RmiServer;
import jcl.learning.LearningParameters; import jcl.learning.LearningParameters;
...@@ -955,25 +947,9 @@ public class ClassifierPanel extends JPanel { ...@@ -955,25 +947,9 @@ public class ClassifierPanel extends JPanel {
} }
/* generates distance parameters */ /* generates distance parameters */
// DistanceParameter[][] distanceParameters = new DistanceParameter[1][model.getDistances().length];
// int i = 0;
// for (Distance d : model.getDistances()) {
// if(d instanceof DistanceDTWMD) {
// AttributeMultiDimSequence seq = (AttributeMultiDimSequence) data.getOneDataObject().getAttribute(i);//need the corresponding attribute to get the sequence length
// distanceParameters[0][i] = new ParameterDTW(new double[seq.getNbTuples()][seq.getNbTuples()]); //special attribute for DTW distances (requires a matrix to work in)
// }
// else if(d instanceof DistanceDTW) {
// AttributeSequence seq = (AttributeSequence) data.getOneDataObject().getAttribute(i);//need the corresponding attribute to get the sequence length
// distanceParameters[0][i] = new ParameterDTW(new double[seq.getNbTuples()][seq.getNbTuples()]); //special attribute for DTW distances (requires a matrix to work in)
// }
// else {
// distanceParameters[0][i] = EmptyDistanceParameter.getInstance();//no parameter for a numerical euclidean distance
// }
// i++;
// }
int nbThreads = Runtime.getRuntime().availableProcessors(); int nbThreads = Runtime.getRuntime().availableProcessors();
DistanceParameter[][] distanceParameters = DistanceModel.generateDefaultDistanceParameters(nbThreads, model, data); DistanceParameter[][] distanceParameters = DistanceModel.generateDefaultDistanceParameters(nbThreads, model, data);
AverageParameter[] averageParameters = DistanceModel.generateDefaultAverageParameters(model, data);
int choice = this.modele.getSelectedApproach(); int choice = this.modele.getSelectedApproach();
...@@ -996,7 +972,8 @@ public class ClassifierPanel extends JPanel { ...@@ -996,7 +972,8 @@ public class ClassifierPanel extends JPanel {
System.out.println(nbClassifications + " " + nbClustersMin + " " //$NON-NLS-1$ //$NON-NLS-2$ System.out.println(nbClassifications + " " + nbClustersMin + " " //$NON-NLS-1$ //$NON-NLS-2$
+ nbClustersMax); + nbClustersMax);
params = new ParametersEvidence(nbClassifications, nbClustersMax, nbClustersMin, pourcentage, model, distanceParameters); params = new ParametersEvidence(nbClassifications, nbClustersMax, nbClustersMin, pourcentage,
model, distanceParameters, averageParameters);
return params; return params;
} }
...@@ -1022,7 +999,6 @@ public class ClassifierPanel extends JPanel { ...@@ -1022,7 +999,6 @@ public class ClassifierPanel extends JPanel {
if (filePath.endsWith(".arff")) { //$NON-NLS-1$ if (filePath.endsWith(".arff")) { //$NON-NLS-1$
int[][] clustering = DataArffExchange.arffToClusteredIndexes(filePath); int[][] clustering = DataArffExchange.arffToClusteredIndexes(filePath);
List<DataObject> result = ClassifierKmeans.getCentroidsFromClustering(data, clustering, model, null );//TODO List<DataObject> result = ClassifierKmeans.getCentroidsFromClustering(data, clustering, model, null );//TODO
AverageParameter[] averageParameters = DistanceModel.generateDefaultAverageParameters(model, data);
params = new ParametersKmeans(result.size(), 0, model, distanceParameters, averageParameters); params = new ParametersKmeans(result.size(), 0, model, distanceParameters, averageParameters);
params.setSamples(new Vector<DataObject>(result)); params.setSamples(new Vector<DataObject>(result));
} else { } else {
...@@ -1066,7 +1042,6 @@ public class ClassifierPanel extends JPanel { ...@@ -1066,7 +1042,6 @@ public class ClassifierPanel extends JPanel {
// } // }
// distanceParametersK[th] = distanceParameters; // distanceParametersK[th] = distanceParameters;
// } // }
AverageParameter[] averageParameters = DistanceModel.generateDefaultAverageParameters(model, data);
params = new ParametersKmeans(nbClusters, nbIters, nbThreads, model, distanceParameters, averageParameters); params = new ParametersKmeans(nbClusters, nbIters, nbThreads, model, distanceParameters, averageParameters);
params.setModel(model); params.setModel(model);
break; break;
...@@ -1075,7 +1050,6 @@ public class ClassifierPanel extends JPanel { ...@@ -1075,7 +1050,6 @@ public class ClassifierPanel extends JPanel {
int nbClusters = Integer.valueOf(((JTextField) comp[1]).getText()).intValue(); int nbClusters = Integer.valueOf(((JTextField) comp[1]).getText()).intValue();
int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue(); int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue();
double m = Double.valueOf(((JTextField) comp[5]).getText()).doubleValue(); double m = Double.valueOf(((JTextField) comp[5]).getText()).doubleValue();
AverageParameter[] averageParameters = DistanceModel.generateDefaultAverageParameters(model, data);
params = new ParametersKmeans(nbClusters, nbIters, m, model, distanceParameters, averageParameters); params = new ParametersKmeans(nbClusters, nbIters, m, model, distanceParameters, averageParameters);
break; break;
} }
...@@ -1085,7 +1059,7 @@ public class ClassifierPanel extends JPanel { ...@@ -1085,7 +1059,7 @@ public class ClassifierPanel extends JPanel {
int maxDepth = Integer.valueOf(((JTextField) comp[5]).getText()).intValue(); int maxDepth = Integer.valueOf(((JTextField) comp[5]).getText()).intValue();
int nombre_passes = Integer.valueOf(((JTextField) comp[7]).getText()).intValue(); int nombre_passes = Integer.valueOf(((JTextField) comp[7]).getText()).intValue();
int minCard = Integer.valueOf(((JTextField) comp[9]).getText()).intValue(); int minCard = Integer.valueOf(((JTextField) comp[9]).getText()).intValue();
params = new ParametersCobweb(acuteness, mapi, maxDepth, nombre_passes, minCard, model, distanceParameters); params = new ParametersCobweb(acuteness, mapi, maxDepth, nombre_passes, minCard);
break; break;
} }
case ClassifierUtils.SOM: { case ClassifierUtils.SOM: {
...@@ -1093,7 +1067,7 @@ public class ClassifierPanel extends JPanel { ...@@ -1093,7 +1067,7 @@ public class ClassifierPanel extends JPanel {
int heigth = Integer.valueOf(((JTextField) comp[3]).getText()).intValue(); int heigth = Integer.valueOf(((JTextField) comp[3]).getText()).intValue();
int nbIters = Integer.valueOf(((JTextField) comp[5]).getText()).intValue(); int nbIters = Integer.valueOf(((JTextField) comp[5]).getText()).intValue();
double epsilon = Double.valueOf(((JTextField) comp[7]).getText()).doubleValue(); double epsilon = Double.valueOf(((JTextField) comp[7]).getText()).doubleValue();
params = new ParametersSOM(width, heigth, nbIters, epsilon, weights); params = new ParametersSOM(width, heigth, nbIters, epsilon, model, distanceParameters);
break; break;
} }
case ClassifierUtils.PERCEPTRON: { case ClassifierUtils.PERCEPTRON: {
...@@ -1105,19 +1079,18 @@ public class ClassifierPanel extends JPanel { ...@@ -1105,19 +1079,18 @@ public class ClassifierPanel extends JPanel {
case ClassifierUtils.EM: { case ClassifierUtils.EM: {
int nbClusters = Integer.valueOf(((JTextField) comp[1]).getText()).intValue(); int nbClusters = Integer.valueOf(((JTextField) comp[1]).getText()).intValue();
int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue(); int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue();
params = new ParametersEM(nbClusters, nbIters, model, distanceParameters); params = new ParametersEM(nbClusters, nbIters, model, distanceParameters, averageParameters);
break; break;
} }
case ClassifierUtils.RANDOM: { case ClassifierUtils.RANDOM: {
int nbClusters = Integer.valueOf(((JTextField) comp[1]).getText()).intValue(); int nbClusters = Integer.valueOf(((JTextField) comp[1]).getText()).intValue();
params = new ParametersRandom(nbClusters, weights); params = new ParametersRandom(nbClusters);
break; break;
} }
case ClassifierUtils.GWKMEANS: { case ClassifierUtils.GWKMEANS: {
int nbClusters = Integer.valueOf(((JTextField) comp[1]).getText()).intValue(); int nbClusters = Integer.valueOf(((JTextField) comp[1]).getText()).intValue();
int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue(); int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue();
double beta = Double.valueOf(((JTextField) comp[5]).getText()).doubleValue(); double beta = Double.valueOf(((JTextField) comp[5]).getText()).doubleValue();
AverageParameter[] averageParameters = DistanceModel.generateDefaultAverageParameters(model, data);
params = new ParametersKmeans(nbClusters, nbIters, beta, ParametersKmeans.GLOBAL_FEATURE_WEIGHTING, params = new ParametersKmeans(nbClusters, nbIters, beta, ParametersKmeans.GLOBAL_FEATURE_WEIGHTING,
model, distanceParameters, averageParameters); model, distanceParameters, averageParameters);
break; break;
...@@ -1127,7 +1100,6 @@ public class ClassifierPanel extends JPanel { ...@@ -1127,7 +1100,6 @@ public class ClassifierPanel extends JPanel {
int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue(); int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue();
double m = Double.valueOf(((JTextField) comp[5]).getText()).doubleValue(); double m = Double.valueOf(((JTextField) comp[5]).getText()).doubleValue();
double beta = Double.valueOf(((JTextField) comp[7]).getText()).doubleValue(); double beta = Double.valueOf(((JTextField) comp[7]).getText()).doubleValue();
AverageParameter[] averageParameters = DistanceModel.generateDefaultAverageParameters(model, data);
params = new ParametersKmeans(nbClusters, nbIters, m, beta, ParametersKmeans.GLOBAL_FEATURE_WEIGHTING, params = new ParametersKmeans(nbClusters, nbIters, m, beta, ParametersKmeans.GLOBAL_FEATURE_WEIGHTING,
model, distanceParameters, averageParameters); model, distanceParameters, averageParameters);
break; break;
...@@ -1136,7 +1108,6 @@ public class ClassifierPanel extends JPanel { ...@@ -1136,7 +1108,6 @@ public class ClassifierPanel extends JPanel {
int nbClusters = Integer.valueOf(((JTextField) comp[1]).getText()).intValue(); int nbClusters = Integer.valueOf(((JTextField) comp[1]).getText()).intValue();
int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue(); int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue();
double beta = Double.valueOf(((JTextField) comp[5]).getText()).doubleValue(); double beta = Double.valueOf(((JTextField) comp[5]).getText()).doubleValue();
AverageParameter[] averageParameters = DistanceModel.generateDefaultAverageParameters(model, data);
params = new ParametersKmeans(nbClusters, nbIters, beta, ParametersKmeans.LOCAL_FEATURE_WEIGHTING, params = new ParametersKmeans(nbClusters, nbIters, beta, ParametersKmeans.LOCAL_FEATURE_WEIGHTING,
model, distanceParameters, averageParameters); model, distanceParameters, averageParameters);
break; break;
...@@ -1146,7 +1117,6 @@ public class ClassifierPanel extends JPanel { ...@@ -1146,7 +1117,6 @@ public class ClassifierPanel extends JPanel {
int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue(); int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue();
double m = Double.valueOf(((JTextField) comp[5]).getText()).doubleValue(); double m = Double.valueOf(((JTextField) comp[5]).getText()).doubleValue();
double beta = Double.valueOf(((JTextField) comp[7]).getText()).doubleValue(); double beta = Double.valueOf(((JTextField) comp[7]).getText()).doubleValue();
AverageParameter[] averageParameters = DistanceModel.generateDefaultAverageParameters(model, data);
params = new ParametersKmeans(nbClusters, nbIters, m, beta, ParametersKmeans.LOCAL_FEATURE_WEIGHTING, params = new ParametersKmeans(nbClusters, nbIters, m, beta, ParametersKmeans.LOCAL_FEATURE_WEIGHTING,
model, distanceParameters, averageParameters); model, distanceParameters, averageParameters);
break; break;
......
...@@ -115,15 +115,12 @@ public class MaclawClassificationParametersPanel extends JPanel { ...@@ -115,15 +115,12 @@ public class MaclawClassificationParametersPanel extends JPanel {
break; break;
} }
ClassificationWeights weights = new GlobalWeights(new Weights(
this.data.getOneDataObject().getNbAttributes()));
this.param = new ParametersMaclaw(distributed, nbGenerations, this.param = new ParametersMaclaw(distributed, nbGenerations,
nbIndividuals, nbClusters, nbRefs, nbIndividuals, nbClusters, nbRefs,
ClassifierModular.PRODUCT, nbCpu, initParams, initParams, ClassifierModular.PRODUCT, nbCpu, initParams, initParams,
fuzzy, alpha, phi, clusterQualityCriterion, fuzzy, alpha, phi, clusterQualityCriterion,
ClassifierMaclaw.WEIGHTING, ClassifierMaclaw.GENETIC, 1., ClassifierMaclaw.WEIGHTING, ClassifierMaclaw.GENETIC, 1.,
weights); initParams.getModel(), initParams.getDistanceParameters());
} }
return this.param; return this.param;
} }
......
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