We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d252f43 commit 227fd37Copy full SHA for 227fd37
tests/lib/model/split_merge.test.js
@@ -0,0 +1,25 @@
1
+import Matrix from '../../../lib/util/matrix.js'
2
+import SplitAndMerge from '../../../lib/model/split_merge.js'
3
+
4
+import { randIndex } from '../../../lib/evaluate/clustering.js'
5
6
+test.each(['variance', 'uniformity'])('predict %s', method => {
7
+ const model = new SplitAndMerge(method)
8
+ const n = 100
9
+ const x = Matrix.zeros(n, n).toArray()
10
+ const t = []
11
+ for (let i = 0, p = 0; i < n; i++) {
12
+ for (let j = 0; j < n; j++, p++) {
13
+ if ((i - n / 2) ** 2 + (j - n / 2) ** 2 < (n / 4) ** 2) {
14
+ x[i][j] = 255
15
+ t[p] = 1
16
+ } else {
17
+ t[p] = 0
18
+ }
19
20
21
22
+ const y = model.predict(x)
23
+ const ri = randIndex(y.flat(), t)
24
+ expect(ri).toBeGreaterThan(0.9)
25
+})
0 commit comments