Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

Commit 3b7e6baf authored by balanche's avatar balanche
Browse files

Partial migration to DistanceModel utilisation

parent 7482508b
......@@ -26,11 +26,14 @@ import jcl.clustering.Cluster;
import jcl.clustering.ClusteringResult;
import jcl.data.Data;
import jcl.data.DataObject;
import jcl.data.DistanceModel;
import jcl.data.SimpleData;
import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.data.distance.DistanceParameter;
import jcl.learning.LearningMethod;
import jcl.learning.methods.monostrategy.SingleClassification;
import jcl.weights.ClassificationWeights;
import jcl.weights.GlobalWeights;
import jsl.Segmentation;
import mustic.gui.dialog.*;
import mustic.gui.dialog.arff.ArffLoadDialog;
......@@ -2989,7 +2992,13 @@ public class MainFrame extends JFrame {
result = ClusteringResult.gerenerateDefaultClusteringResult(clusters);
result.setClusterMap(clusterMap);
result.setWeights(weights);
Classification classif = new SingleClassification(name, new SimpleData(dataObjects), method, result);
Classification classif = new SingleClassification(name,
new SimpleData(dataObjects, null, null), method, result);
DistanceModel model = DistanceModel.generateDefaultModel(dataObjects.get(0),
new GlobalWeights(dataObjects.get(0)));
DistanceParameter[][] parameters = DistanceModel.generateDefaultDistanceParameters(1,
model, classif.getData());
classif.getData().setDistanceModel(model, parameters);
// fichierImage = new File(fileName);
if (MainFrame.DEBUG_MODE)
......@@ -3065,7 +3074,12 @@ public class MainFrame extends JFrame {
}
else {
Data data = new SimpleData(dataObjects);
Data data = new SimpleData(dataObjects, null, null);
DistanceModel distModel = DistanceModel.generateDefaultModel(dataObjects.get(0),
new GlobalWeights(dataObjects.get(0)));
DistanceParameter[][] distParameters = DistanceModel
.generateDefaultDistanceParameters(1, model, data);
data.setDistanceModel(distModel, distParameters);
data.setDataName(file.getName());
MainFrame.getInstance().createDataSession(data);
......@@ -3086,7 +3100,8 @@ public class MainFrame extends JFrame {
// classif.setClusteringResult(result);
ci.addResult(classif, name);
// System.out.println("Resultat ajoute a la classif");
ImageResultPanel irp = (ImageResultPanel) ci.tabbedPane.getTabAt(ci.tabbedPane.getTabCount() - 1).getContentComponent();
ImageResultPanel irp = (ImageResultPanel) ci.tabbedPane
.getTabAt(ci.tabbedPane.getTabCount() - 1).getContentComponent();
if (MainFrame.DEBUG_MODE)
System.out.println(qualities);
irp.setQualityPanel(new QualityPanel(classif, qualities));
......
......@@ -138,7 +138,7 @@ public class ArffToDataDialog extends JInternalFrame implements ToUpdateObject {
}
}
@SuppressWarnings({ "unchecked", "deprecation" })
@SuppressWarnings({ "unchecked" })
protected void buttonOk_actionPerformed() {
try {
Object[] result = DataArffExchange.arffToData(this.textFile.getText());
......
......@@ -56,6 +56,9 @@ import jcl.clustering.constraints.LabelConstraint;
import jcl.clustering.constraints.MustLinkConstraint;
import jcl.clustering.constraints.NbClusterConstraint;
import jcl.data.Data;
import jcl.data.DistanceModel;
import jcl.data.distance.DistanceParameter;
import jcl.weights.GlobalWeights;
import mustic.utils.image.ImageAddOn;
import mustic.utils.image.ImageDisplayer;
import mustic.utils.tools.ProgressPropertyChangeListener;
......@@ -161,11 +164,15 @@ public class ConstraintsSelectionFrame extends JFrame implements ImageAddOn {
this.imageDisplayer = imgDisplayer;
this.constraintsContainer = constraintsContainer;
if (data != null) {
// case of Data provided
minDistance = data.getEstimatedMinDistance();
maxDistance = data.getEstimatedMaxDistance();
DistanceModel model = DistanceModel.generateDefaultModel(data.getOneDataObject(),
new GlobalWeights(data.getOneDataObject()));
DistanceParameter[][] parameters = DistanceModel.generateDefaultDistanceParameters(1,model, data);
minDistance = data.getEstimatedMinDistance(model, parameters[0]);
maxDistance = data.getEstimatedMaxDistance(model, parameters[0]);
this.data = data;
} else {
// otherwise we base our estimation on the image
......
......@@ -22,8 +22,11 @@ import javax.swing.JTextField;
import jcl.data.Data;
import jcl.data.DataObject;
import jcl.data.DistanceModel;
import jcl.data.SimpleData;
import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.data.distance.DistanceParameter;
import jcl.weights.GlobalWeights;
import mustic.gui.MainFrame;
import mustic.gui.dialog.Messages;
import mustic.utils.documentFilter.ToUpdateObject;
......@@ -140,7 +143,6 @@ public class CSVToDataDialog extends JInternalFrame implements ToUpdateObject {
}
}
@SuppressWarnings({"deprecation"})
protected void buttonOk_actionPerformed() {
try {
List<DataObject> result = new ArrayList<DataObject>();
......@@ -160,7 +162,11 @@ public class CSVToDataDialog extends JInternalFrame implements ToUpdateObject {
}
if(result != null) {
data = new SimpleData(result);
data = new SimpleData(result, null, null);
DistanceModel model = DistanceModel.generateDefaultModel(data.getOneDataObject(),
new GlobalWeights(data.getOneDataObject()));
DistanceParameter[][] parameters = DistanceModel.generateDefaultDistanceParameters(1,model, data);
data.setDistanceModel(model, parameters);
if (this.textData.getText().length() == 0) {
this.textData.setText(ImageHelper.extractFileName(
......
......@@ -4,8 +4,6 @@ import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Observable;
import java.util.Observer;
import java.util.Vector;
......@@ -949,10 +947,11 @@ public class ImageResultPanel extends ResultPanel implements TreeSelectionListen
*/
public void hClustering_actionPerformed(boolean newResult) {
try {
LearningParameters learningParameters = new ParametersAHC(null);
LearningParameters learningParameters = new ParametersAHC(imgData.getDistanceModel(),
imgData.getDistanceParameters());
LearningMethod learningMethod = learningParameters.getLearningMethodInstance();
@SuppressWarnings("deprecation")
Data classificationData = new SimpleData(this.result.getClusterCenters());
Data classificationData = new SimpleData(this.result.getClusterCenters(),
imgData.getDistanceModel(), imgData.getDistanceParameters());
LearningResult learningResult = learningMethod.learn(classificationData);
this.result.hierarchy = ((LearningResultAHC) learningResult).getHierarchy();
Classification classif = new SingleClassification("", classificationData, learningMethod, this.result);
......
......@@ -674,7 +674,7 @@ public class ClassifierPanel extends JPanel {
classification = importedClassification;
classification.setData(dataSession.getData());
if (classification instanceof SingleClassification) {
ClassificationWeights weights = new GlobalWeights(dataSession.getData());
ClassificationWeights weights = new GlobalWeights(dataSession.getData().getOneDataObject());
if (this.attributeSelectionPanel != null)
weights = this.attributeSelectionPanel.getWeights();
((SingleClassification) classification).setWeights(weights);
......@@ -939,7 +939,7 @@ public class ClassifierPanel extends JPanel {
Component[] comp = this.paramsPanel.getComponents();
ClassificationWeights weights = new GlobalWeights(data);
ClassificationWeights weights = new GlobalWeights(data.getOneDataObject());
if (this.attributeSelectionPanel != null)
weights = this.attributeSelectionPanel.getWeights();
......@@ -948,14 +948,31 @@ public class ClassifierPanel extends JPanel {
/* generates model */
if (this.useNaiveDist) {
// AttributeMultiDimSequence.setMode(AttributeMultiDimSequence.EUCLIDIEN);
model = DistanceModel.generateNaiveModel(data.getOneDataObject(), weights);
}
else {
// AttributeMultiDimSequence.setMode(AttributeMultiDimSequence.DTW_BARYCENTRE);
model = DistanceModel.generateDefaultModel(data.getOneDataObject(), weights);
}
/* 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();
DistanceParameter[][] distanceParameters = DistanceModel.generateDefaultDistanceParameters(nbThreads, model, data);
int choice = this.modele.getSelectedApproach();
......@@ -979,7 +996,7 @@ public class ClassifierPanel extends JPanel {
System.out.println(nbClassifications + " " + nbClustersMin + " " //$NON-NLS-1$ //$NON-NLS-2$
+ nbClustersMax);
params = new ParametersEvidence(nbClassifications, nbClustersMax, nbClustersMin, pourcentage, weights);
params = new ParametersEvidence(nbClassifications, nbClustersMax, nbClustersMin, pourcentage, model, distanceParameters);
return params;
}
......@@ -1004,8 +1021,8 @@ public class ClassifierPanel extends JPanel {
String filePath = ((JTextField) ((JPanel) comp[1]).getComponent(0)).getText();
if (filePath.endsWith(".arff")) { //$NON-NLS-1$
int[][] clustering = DataArffExchange.arffToClusteredIndexes(filePath);
List<DataObject> result = ClassifierKmeans.getCentroidsFromClustering(data, clustering);
params = new ParametersKmeans(result.size(), 0, weights);
List<DataObject> result = ClassifierKmeans.getCentroidsFromClustering(data, clustering, model, null );//TODO
params = new ParametersKmeans(result.size(), 0, model, distanceParameters);
params.setSamples(new Vector<DataObject>(result));
} else {
JOptionPane.showMessageDialog(this,
......@@ -1025,30 +1042,31 @@ public class ClassifierPanel extends JPanel {
case ClassifierUtils.KMEANS: {
int nbClusters = Integer.valueOf(((JTextField) comp[1]).getText()).intValue();
int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue();
int nbThreads = 2;
DistanceParameter[][] distanceParameters = new DistanceParameter[nbThreads][model.getDistances().length];
AverageParameter[] averageParameters = new AverageParameter[model.getDistances().length];
for (int th = 0; th < nbThreads; th++) {
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[th][i] = new ParameterDTW(new double[seq.getNbTuples()][seq.getNbTuples()]); //special attribute for DTW distances (requires a matrix to work in)
averageParameters[i] = new ParameterDBAMean(seq.getNbTuples(), 15);
}
else if(d instanceof DistanceDTW) {
AttributeSequence seq = (AttributeSequence) data.getOneDataObject().getAttribute(i);//need the corresponding attribute to get the sequence length
distanceParameters[th][i] = new ParameterDTW(new double[seq.getNbTuples()][seq.getNbTuples()]); //special attribute for DTW distances (requires a matrix to work in)
averageParameters[i] = new ParameterDBAMean(seq.getNbTuples(), 15);
}
else {
distanceParameters[th][i] = EmptyDistanceParameter.getInstance();//no parameter for a numerical euclidean distance
averageParameters[i] = EmptyAverageParameter.getInstance();
}
i++;
}
}
params = new ParametersKmeans(nbClusters, nbIters, nbThreads, weights, distanceParameters, averageParameters);
// DistanceParameter[][] distanceParametersK = new DistanceParameter[nbThreads][model.getDistances().length];
// AverageParameter[] averageParameters = new AverageParameter[model.getDistances().length];
// for (int th = 0; th < nbThreads; th++) {
// int j = 0;
// for (Distance d : model.getDistances()) {
// if(d instanceof DistanceDTWMD) {
// AttributeMultiDimSequence seq = (AttributeMultiDimSequence) data.getOneDataObject().getAttribute(j);//need the corresponding attribute to get the sequence length
//// distanceParameters[th][i] = new ParameterDTW(new double[seq.getNbTuples()][seq.getNbTuples()]); //special attribute for DTW distances (requires a matrix to work in)
// averageParameters[j] = new ParameterDBAMean(seq.getNbTuples(), 15);
// }
// else if(d instanceof DistanceDTW) {
// AttributeSequence seq = (AttributeSequence) data.getOneDataObject().getAttribute(j);//need the corresponding attribute to get the sequence length
//// distanceParameters[th][i] = new ParameterDTW(new double[seq.getNbTuples()][seq.getNbTuples()]); //special attribute for DTW distances (requires a matrix to work in)
// averageParameters[j] = new ParameterDBAMean(seq.getNbTuples(), 15);
// }
// else {
//// distanceParameters[th][i] = EmptyDistanceParameter.getInstance();//no parameter for a numerical euclidean distance
// averageParameters[j] = EmptyAverageParameter.getInstance();
// }
// j++;
// }
// distanceParametersK[th] = distanceParameters;
// }
AverageParameter[] averageParameters = DistanceModel.generateDefaultAverageParameters(model, data);
params = new ParametersKmeans(nbClusters, nbIters, nbThreads, model, distanceParameters, averageParameters);
params.setModel(model);
break;
}
......@@ -1056,7 +1074,7 @@ public class ClassifierPanel extends JPanel {
int nbClusters = Integer.valueOf(((JTextField) comp[1]).getText()).intValue();
int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue();
double m = Double.valueOf(((JTextField) comp[5]).getText()).doubleValue();
params = new ParametersKmeans(nbClusters, nbIters, m, weights);
params = new ParametersKmeans(nbClusters, nbIters, m, model, distanceParameters);
break;
}
case ClassifierUtils.COBWEB: {
......@@ -1065,7 +1083,7 @@ public class ClassifierPanel extends JPanel {
int maxDepth = Integer.valueOf(((JTextField) comp[5]).getText()).intValue();
int nombre_passes = Integer.valueOf(((JTextField) comp[7]).getText()).intValue();
int minCard = Integer.valueOf(((JTextField) comp[9]).getText()).intValue();
params = new ParametersCobweb(acuteness, mapi, maxDepth, nombre_passes, minCard, weights);
params = new ParametersCobweb(acuteness, mapi, maxDepth, nombre_passes, minCard, model, distanceParameters);
break;
}
case ClassifierUtils.SOM: {
......@@ -1079,13 +1097,13 @@ public class ClassifierPanel extends JPanel {
case ClassifierUtils.PERCEPTRON: {
int nbClusters = Integer.valueOf(((JTextField) comp[1]).getText()).intValue();
int nbEpochs = Integer.valueOf(((JTextField) comp[3]).getText()).intValue();
params = new ParametersPerceptron(nbClusters, nbEpochs, 1, .99, weights);
params = new ParametersPerceptron(nbClusters, nbEpochs, 1, .99, model, distanceParameters);
break;
}
case ClassifierUtils.EM: {
int nbClusters = Integer.valueOf(((JTextField) comp[1]).getText()).intValue();
int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue();
params = new ParametersEM(nbClusters, nbIters, weights);
params = new ParametersEM(nbClusters, nbIters, model, distanceParameters);
break;
}
case ClassifierUtils.RANDOM: {
......@@ -1097,7 +1115,7 @@ public class ClassifierPanel extends JPanel {
int nbClusters = Integer.valueOf(((JTextField) comp[1]).getText()).intValue();
int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue();
double beta = Double.valueOf(((JTextField) comp[5]).getText()).doubleValue();
params = new ParametersKmeans(nbClusters, nbIters, beta, ParametersKmeans.GLOBAL_FEATURE_WEIGHTING, weights);
params = new ParametersKmeans(nbClusters, nbIters, beta, ParametersKmeans.GLOBAL_FEATURE_WEIGHTING, model, distanceParameters);
break;
}
case ClassifierUtils.GWFCM: {
......@@ -1105,14 +1123,14 @@ public class ClassifierPanel extends JPanel {
int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue();
double m = Double.valueOf(((JTextField) comp[5]).getText()).doubleValue();
double beta = Double.valueOf(((JTextField) comp[7]).getText()).doubleValue();
params = new ParametersKmeans(nbClusters, nbIters, m, beta, ParametersKmeans.GLOBAL_FEATURE_WEIGHTING, weights);
params = new ParametersKmeans(nbClusters, nbIters, m, beta, ParametersKmeans.GLOBAL_FEATURE_WEIGHTING, model, distanceParameters);
break;
}
case ClassifierUtils.LWKMEANS: {
int nbClusters = Integer.valueOf(((JTextField) comp[1]).getText()).intValue();
int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue();
double beta = Double.valueOf(((JTextField) comp[5]).getText()).doubleValue();
params = new ParametersKmeans(nbClusters, nbIters, beta, ParametersKmeans.LOCAL_FEATURE_WEIGHTING, weights);
params = new ParametersKmeans(nbClusters, nbIters, beta, ParametersKmeans.LOCAL_FEATURE_WEIGHTING, model, distanceParameters);
break;
}
case ClassifierUtils.LWFCM: {
......@@ -1120,7 +1138,7 @@ public class ClassifierPanel extends JPanel {
int nbIters = Integer.valueOf(((JTextField) comp[3]).getText()).intValue();
double m = Double.valueOf(((JTextField) comp[5]).getText()).doubleValue();
double beta = Double.valueOf(((JTextField) comp[7]).getText()).doubleValue();
params = new ParametersKmeans(nbClusters, nbIters, m, beta, ParametersKmeans.LOCAL_FEATURE_WEIGHTING, weights);
params = new ParametersKmeans(nbClusters, nbIters, m, beta, ParametersKmeans.LOCAL_FEATURE_WEIGHTING, model, distanceParameters);
break;
}
case ClassifierUtils.GNG: {
......@@ -1128,7 +1146,7 @@ public class ClassifierPanel extends JPanel {
int ageMax = Integer.valueOf(((JTextField) comp[3]).getText());
int steps = Integer.valueOf(((JTextField) comp[5]).getText());
int freq = Integer.valueOf(((JTextField) comp[7]).getText());
params = new ParametersGNG(nbNodes, ageMax, steps, freq, weights);
params = new ParametersGNG(nbNodes, ageMax, steps, freq, model, distanceParameters);
break;
}
/*
......@@ -1140,7 +1158,7 @@ public class ClassifierPanel extends JPanel {
*/
case ClassifierUtils.AHC: {
int nbClusters = Integer.valueOf(((JTextField) comp[1]).getText()).intValue();
params = new ParametersAHC(nbClusters, null);
params = new ParametersAHC(nbClusters, model, distanceParameters);
System.out.println(Messages.getString("ClassifierPanel.106")); //$NON-NLS-1$
break;
}
......@@ -1245,7 +1263,7 @@ public class ClassifierPanel extends JPanel {
file += "\t<showTime>" + this.timeCheckBox.isSelected() //$NON-NLS-1$
+ "</showTime>\n"; //$NON-NLS-1$
if (dataSession.getData() != null) {
ClassificationWeights weights = new GlobalWeights(dataSession.getData());
ClassificationWeights weights = new GlobalWeights(dataSession.getData().getOneDataObject());
if (this.attributeSelectionPanel != null) {
weights = this.attributeSelectionPanel.getWeights();
file += "\t<weight>"; //$NON-NLS-1$
......@@ -1269,7 +1287,7 @@ public class ClassifierPanel extends JPanel {
file += "\t<showTime>" + this.timeCheckBox.isSelected() //$NON-NLS-1$
+ "</showTime>\n"; //$NON-NLS-1$
if (dataSession.getData() != null) {
ClassificationWeights weights = new GlobalWeights(dataSession.getData());
ClassificationWeights weights = new GlobalWeights(dataSession.getData().getOneDataObject());
if (this.attributeSelectionPanel != null) {
weights = this.attributeSelectionPanel.getWeights();
file += "\t<weight>"; //$NON-NLS-1$
......@@ -1295,7 +1313,7 @@ public class ClassifierPanel extends JPanel {
file += this.maclawParametersPanel.getParamsXML();
if (dataSession.getData() != null) {
ClassificationWeights weights = new GlobalWeights(dataSession.getData());
ClassificationWeights weights = new GlobalWeights(dataSession.getData().getOneDataObject());
if (this.attributeSelectionPanel != null) {
weights = this.attributeSelectionPanel.getWeights();
file += "\t<weight>"; //$NON-NLS-1$
......@@ -1351,7 +1369,7 @@ public class ClassifierPanel extends JPanel {
file += "\t<showTime>" + this.timeCheckBox.isSelected() //$NON-NLS-1$
+ "</showTime>\n"; //$NON-NLS-1$
ClassificationWeights weights = new GlobalWeights(dataSession.getData());
ClassificationWeights weights = new GlobalWeights(dataSession.getData().getOneDataObject());
if (this.attributeSelectionPanel != null) {
weights = this.attributeSelectionPanel.getWeights();
file += "\t<weight>"; //$NON-NLS-1$
......
......@@ -10,6 +10,7 @@ import javax.swing.*;
import javax.swing.border.TitledBorder;
import jcl.data.Data;
import jcl.data.DistanceModel;
import jcl.data.attribute.Attribute;
import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.data.distance.Distance;
......@@ -17,6 +18,7 @@ import jcl.data.distance.DistanceParameter;
import jcl.data.distance.sequential.DistanceEuclidean;
import jcl.learning.LearningParameters;
import jcl.learning.methods.multistrategy.samarah.*;
import jcl.weights.GlobalWeights;
import mustic.gui.MainFrame;
import mustic.gui.dialog.classifier.AgentDialog;
import mustic.gui.panels.classifier.*;
......@@ -78,7 +80,7 @@ public class HybridClassificationPanel extends JPanel implements AgentListManage
this.title = this.title + "." + HybridClassificationPanel.nbSamarah;
HybridClassificationPanel.nbSamarah++;
// this.samarah = new HybridClassification("TEST", data, null);
this.samarah = new HybridClassification();
this.samarah = new HybridClassification(null, null);
if (MainFrame.DEBUG_MODE)
System.out.println(" in HybridClassificationParametersPanel() ");
this.samarah.config.printInfo();
......@@ -102,7 +104,11 @@ public class HybridClassificationPanel extends JPanel implements AgentListManage
jbInit();
HybridClassificationPanel.nbSamarah++;
// this.samarah = new HybridClassification("TEST", data, null);
this.samarah = new HybridClassification();
DistanceModel model = DistanceModel.generateDefaultModel(data.getOneDataObject(),
new GlobalWeights(data.getOneDataObject()));
DistanceParameter[][] parameters = DistanceModel.generateDefaultDistanceParameters(1,model, data);
this.samarah = new HybridClassification(model, parameters);
}
@Override
......@@ -155,16 +161,17 @@ public class HybridClassificationPanel extends JPanel implements AgentListManage
else {
file += "\t\t<isSimplifySequence>true</isSimplifySequence>\n";
}
for (Distance<Attribute, DistanceParameter> d : agent.getParams().getModel().getDistances()) {
if(!(d instanceof DistanceEuclidean))
}
if (AttributeMultiDimSequence.getMode() == AttributeMultiDimSequence.EUCLIDIEN && agent.getParams().getModel()) {
file += "\t\t<isUseNaiveDist>true</isUseNaiveDist>\n";
}
else {
file += "\t\t<isUseNaiveDist>false</isUseNaiveDist>\n";
}
//TODO try to match with the new distanceModel
// for (Distance<Attribute, DistanceParameter> d : agent.getParams().getModel().getDistances()) {
// if(!(d instanceof DistanceEuclidean))
//
// }
// if (AttributeMultiDimSequence.getMode() == AttributeMultiDimSequence.EUCLIDIEN && agent.getParams().getModel()) {
// file += "\t\t<isUseNaiveDist>true</isUseNaiveDist>\n";
// }
// else {
// file += "\t\t<isUseNaiveDist>false</isUseNaiveDist>\n";
// }
if (agent.getParams().weights != null) {
file += "\t\t<weight>";
double weights[] = agent.getParams().weights.getGlobalWeights().getWeights();
......
......@@ -16,8 +16,10 @@ import com.l2fprod.common.swing.JTaskPane;
import com.l2fprod.common.swing.JTaskPaneGroup;
import jcl.data.DistanceModel;
import jcl.data.distance.DistanceParameter;
import jcl.data.mask.Mask;
import jcl.data.sampling.Sampler;
import jcl.weights.GlobalWeights;
import mustic.gui.ImageDesktopFrame;
import mustic.gui.ImageSession;
import mustic.gui.MainFrame;
......@@ -147,12 +149,16 @@ public class DataConstructPanel extends JPanel implements ToUpdateObject {
}
if (filesPaths.size() > 1) {
data = new ImageData(sample, filesPaths, null);
// data.setModel(Model.generateDefaultModel(data.getOneDataObject()));
data = new ImageData(sample, filesPaths, null, null, null);
} else {
data = new ImageData(sample, filesPaths.get(0), null);
// data.setModel(Model.generateDefaultModel(data.getOneDataObject()));
data = new ImageData(sample, filesPaths.get(0), null, null);
}
DistanceModel distModel = DistanceModel.generateDefaultModel(data.getOneDataObject(),
new GlobalWeights(data.getOneDataObject()));
DistanceParameter[][] distParameters = DistanceModel
.generateDefaultDistanceParameters(1, distModel, data);
data.setDistanceModel(distModel, distParameters);
MainFrame.getInstance().createDataSession(data);
DataConstructFrame.getInstance().updateDataConstructPanel();
......
......@@ -7,8 +7,8 @@ import java.util.Vector;
import jcl.data.DataObject;
import jcl.data.DistanceModel;
import jcl.data.SimpleData;
import jcl.data.attribute.AttributeMultiDimSequence;
import jcl.data.attribute.AttributeNumerical;
import jcl.data.distance.DistanceParameter;
import jcl.data.mask.Mask;
import jcl.data.sampling.Sampler;
import jcl.utils.exceptions.MethodNotImplementedException;
......@@ -59,7 +59,8 @@ public class ImageData extends SimpleData implements Serializable {
* @param image the image to convert
*/
@Deprecated
public ImageData(RawImage image) {
public ImageData(RawImage image, DistanceModel model, DistanceParameter[][] parameters) {
super(model, parameters);
if (MainFrame.DEBUG_MODE) {
System.out.println(">> ImageData(RawImage) <<");
}
......@@ -168,7 +169,8 @@ public class ImageData extends SimpleData implements Serializable {
* @param percent le pourcentage de pixels a choisir parmi l'image
*/
@Deprecated
public ImageData(RawImage image, double percent) {
public ImageData(RawImage image, double percent, DistanceModel model, DistanceParameter[][] parameters) {
super(model, parameters);
if (MainFrame.DEBUG_MODE)
System.out.println(">> ImageData(RawImage, double) <<");
......@@ -240,7 +242,9 @@ public class ImageData extends SimpleData implements Serializable {
* @param model
* the model to use with the data
*/
public ImageData(Sampler sampler, RawImage path, Mask mask, DistanceModel model) {
public ImageData(Sampler sampler, RawImage path, Mask mask,
DistanceModel model, DistanceParameter[][] parameters) {
super(model, parameters);
if (MainFrame.DEBUG_MODE) {
System.out.println(">> ImageData(Sampler,String) <<");
}
......@@ -292,9 +296,6 @@ public class ImageData extends SimpleData implements Serializable {
long endTime = System.currentTimeMillis();
System.out.println("___________________Total elapsed time in execution of loading image is :" + ((endTime - startTime)));
}
setModel(model);
}
/**
......@@ -310,8 +311,8 @@ public class ImageData extends SimpleData implements Serializable {
* @param model
* the model to use with the data
*/
public ImageData(Sampler sampler, RawImage path, DistanceModel model) {
this(sampler, path, null,model);
public ImageData(Sampler sampler, RawImage path, DistanceModel model, DistanceParameter[][] parameters) {
this(sampler, path, null, model, parameters);
}
/**
......@@ -329,8 +330,9 @@ public class ImageData extends SimpleData implements Serializable {
* @param model
* the model to use with the data
*/
public ImageData(Sampler sampler, Vector<RawImage> images, Mask mask, DistanceModel model) {
public ImageData(Sampler sampler, Vector<RawImage> images, Mask mask,
DistanceModel model, DistanceParameter[][] parameters) {
super(model, parameters);
for(RawImage s : images) {
this.rawImages.add(s);
}
......@@ -389,9 +391,6 @@ public class ImageData extends SimpleData implements Serializable {
System.out.println("___________________Total elapsed time in execution of loading image is :"
+ ((endTime - startTime)));
}
setModel(model);
}
/**
......@@ -407,8 +406,9 @@ public class ImageData extends SimpleData implements Serializable {
* @param model
* the model to use with the data
*/
public ImageData(Sampler sampler, Vector<RawImage> images, DistanceModel model) {
this(sampler, images, null, model);
public ImageData(Sampler sampler, Vector<RawImage> images,
DistanceModel model, DistanceParameter[][] parameters) {
this(sampler, images, null, model, parameters);
}
......
......@@ -146,7 +146,8 @@ public class FilterDataDialog extends JDialog {
private void jButtonOK_actionPerformed() {