You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// KMeans hiearchical clustering. Every Observation is to be clustered with "similar" observations. River cards are the base case, where similarity metric is defined by equity. For each higher layer, we compare distributions of next-layer outcomes. Distances are measured by EMD and unsupervised kmeans clustering is used to cluster similar distributions. Potential-aware imperfect recall!
20
71
pubstructLayer{
21
72
street:Street,
@@ -25,6 +76,18 @@ pub struct Layer {
25
76
}
26
77
27
78
implLayer{
79
+
pubasyncfnhierarchical() -> Self{
80
+
Self::outer()
81
+
.inner()
82
+
.await
83
+
.upload()
84
+
.inner()
85
+
.await
86
+
.upload()
87
+
.inner()
88
+
.await
89
+
.upload()
90
+
}
28
91
/// async equity calculations to create initial River layer.
29
92
pubfnouter() -> Self{
30
93
Self{
@@ -86,8 +149,8 @@ impl Layer {
86
149
for(j,(y, _))inself.kmeans.iter().enumerate(){
87
150
if i > j {
88
151
let index = Pair::from((x, y));
89
-
letref x = self.kmeans.get(x).expect("in centroids").0;
90
-
letref y = self.kmeans.get(y).expect("in centroids").0;
152
+
letref x = self.kmeans.get(x).expect("in centroids").0;// Centroid::prev()
153
+
letref y = self.kmeans.get(y).expect("in centroids").0;// Centroid::prev()
91
154
let distance = self.metric.emd(x, y) + self.metric.emd(y, x);
92
155
let distance = distance / 2.0;
93
156
metric.insert(index, distance);
@@ -145,7 +208,7 @@ impl Layer {
145
208
.get(choice)
146
209
.cloned()
147
210
.cloned()
148
-
.expect("shared index with lowers");
211
+
.expect("shared index with outer layer");
149
212
kmeans.push(sample);
150
213
progress.tick();
151
214
}
@@ -230,6 +293,7 @@ impl Layer {
230
293
.expect("kabstractions was initialized with neighbor")
231
294
.1
232
295
.absorb(children);
296
+
// Centroid::absorb
233
297
}
234
298
235
299
/// forget the old centroids and clear the new ones
0 commit comments