-
Notifications
You must be signed in to change notification settings - Fork 0
/
NeighborhoodHitComp.java
241 lines (202 loc) · 7.75 KB
/
NeighborhoodHitComp.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package dataanalysis;
import distance.DetailedDistanceMatrix;
import distance.DistanceMatrix;
import distance.dissimilarity.AbstractDissimilarity;
import distance.dissimilarity.DissimilarityFactory;
import distance.dissimilarity.DissimilarityFactory.DissimilarityType;
import java.io.IOException;
import java.util.ArrayList;
import java.util.TreeMap;
import javax.swing.JOptionPane;
import labeledprojection.model.LabeledProjectionModel;
import matrix.AbstractMatrix;
import projection.model.ProjectionModel;
import simpletree.model.SimpleTreeModel;
import topics.model.TopicProjectionModel;
import topics.model.TopicTreeModel;
import tree.model.TreeModel;
import vispipelinebasics.annotations.Param;
import vispipelinebasics.annotations.VisComponent;
import vispipelinebasics.interfaces.AbstractComponent;
import vispipelinebasics.interfaces.AbstractParametersView;
/**
*
* @author Fernando V. Paulovic
*/
@VisComponent(hierarchy = "Data Analysis",
name = "Neighborhood Hit",
description = "calculate the neighboorhod hit measure.")
public class NeighborhoodHitComp implements AbstractComponent {
@Override
public void execute() throws IOException {
//NeighborhoodHitView.getInstance(null).display();
ArrayList<Serie> series = new ArrayList<Serie>();
AbstractDissimilarity diss = null;
if (this.disstype != null)
diss = DissimilarityFactory.getInstance(this.disstype);
if ((models == null || models.isEmpty()) && (matrices == null || matrices.isEmpty()) && (dmats == null || dmats.isEmpty())) {
System.out.println("No input informed.");
return;
}
if (models != null && !models.isEmpty()) {
for (int i=0;i<models.size();i++) {
if (models.get(i) instanceof SimpleTreeModel) {
if (originalPoints == null) {
JOptionPane.showMessageDialog(paramview,
"The original points matrix should be informed!",
"Error",JOptionPane.ERROR_MESSAGE);
return;
}
}
}
for (int i=0;i<models.size();i++) {
Serie serie = new Serie(models.get(i));
series.add(serie);
}
}
//Creating dmats with the matrix informed...
if (matrices != null && !matrices.isEmpty()) {
for (int i=0;i<matrices.size();i++) {
DistanceMatrix dm = new DetailedDistanceMatrix(matrices.get(i),diss);
if (dm != null) {
if (dmats == null)
dmats = new ArrayList<DistanceMatrix>();
dmats.add(dm);
}
}
}
//NeighborhoodHit.Serie serie = new NeighborhoodHit.Serie(model);
//series.add(serie);
// for (int i = 0; i < this.projTable.getRowCount(); i++) {
// String filename = (String) this.projTable.getValueAt(i, 1);
//
// if (filename.trim().length() > 0) {
// String description = (String) this.projTable.getValueAt(i, 0);
//
// NeighborhoodHit.Serie serie = new NeighborhoodHit.Serie(description, filename);
// try {
// serie.readModel();
// series.add(serie);
// } catch (IOException ex) {
// Logger.getLogger(NeighborhoodHitView.class.getName()).log(Level.SEVERE, null, ex);
// }
//
// }
// }
resultValues = NeighborhoodHit.getInstance(null).display(series,this.dmats,this.nrNeighbors,this.useVisEuclideanDistance,this.useWeight,this.useEuclideanAsWeights,this.originalPoints);
}
public void attach(@Param(name = "simple tree model") SimpleTreeModel model) {
if (models == null)
models = new ArrayList<ProjectionModel>();
if (model != null)
models.add((ProjectionModel) model);
}
public void input(@Param(name = "original points matrix") AbstractMatrix matrix) {
originalPoints = matrix;
}
public void attach(@Param(name = "topic projection model") TopicProjectionModel model) {
if (models == null)
models = new ArrayList<ProjectionModel>();
if (model != null)
models.add(model);
}
public void attach(@Param(name = "projection model") LabeledProjectionModel model) {
if (models == null)
models = new ArrayList<ProjectionModel>();
if (model != null)
models.add(model);
}
public void attach(@Param(name = "tree model") TreeModel model) {
if (models == null)
models = new ArrayList<ProjectionModel>();
if (model != null)
models.add((ProjectionModel) model);
}
public void attach(@Param(name = "topic tree model") TopicTreeModel model) {
if (models == null)
models = new ArrayList<ProjectionModel>();
if (model != null)
models.add(model);
}
public void attach(@Param(name = "points matrix") AbstractMatrix matrix) {
if (matrices == null)
matrices = new ArrayList<AbstractMatrix>();
if (matrices != null)
matrices.add(matrix);
}
public void attach(@Param(name = "distance matrix") DistanceMatrix dmat) {
if (dmats == null)
dmats = new ArrayList<DistanceMatrix>();
if (dmats != null)
dmats.add(dmat);
}
// public AbstractMatrix output() {
// return input;
// }
@Override
public AbstractParametersView getParametersEditor() {
if (paramview == null) {
paramview = new NeighborhoodHitParamView(this);
}
return paramview;
}
@Override
public void reset() {
models = null;
matrices = null;
dmats = null;
originalPoints = null;
}
public boolean isUseWeight() {
return useWeight;
}
public void setUseWeight(boolean useWeight) {
this.useWeight = useWeight;
}
public int getNrNeighbors() {
return nrNeighbors;
}
public void setNrNeighbors(int nrNeighbors) {
this.nrNeighbors = nrNeighbors;
}
public boolean getUseVisEuclidianDistance() {
return useVisEuclideanDistance;
}
public void setUseVisEuclidianDistance(boolean selected) {
this.useVisEuclideanDistance = selected;
}
public boolean getUseEuclideanAsWeights() {
return useEuclideanAsWeights;
}
public void setUseEuclideanAsWeights(boolean selected) {
this.useEuclideanAsWeights = selected;
}
public DissimilarityType getDissimilarityType() {
return disstype;
}
public void setDissimilarityType(DissimilarityType diss) {
this.disstype = diss;
}
public static final long serialVersionUID = 1L;
private transient ArrayList<ProjectionModel> models;
private transient ArrayList<AbstractMatrix> matrices;
private transient ArrayList<DistanceMatrix> dmats;
private DissimilarityType disstype = DissimilarityType.EUCLIDEAN;
private transient AbstractMatrix originalPoints;
private boolean useWeight = false;
private int nrNeighbors = 30;
private transient NeighborhoodHitParamView paramview;
private boolean useVisEuclideanDistance = false;
private boolean useEuclideanAsWeights = false;
TreeMap<String,double[]> resultValues;
public TreeMap<String,double[]> getResultValues() {
return resultValues;
}
public void setResultValues(TreeMap<String,double[]> resultValues) {
this.resultValues = resultValues;
}
}