Skip to content

Commit 18a1c0f

Browse files
committed
Update clustercal.js
1 parent cac1afa commit 18a1c0f

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

BioRadar/src/script/worker/clustercal.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,28 @@ addEventListener('message',function ({data}) {
3838

3939
// remove outlying
4040
dataSpider3 = dataSpider3.filter(d => !d.outlier);
41-
console.log(dataSpider3.length)
41+
4242
postMessage({
4343
action: 'returnData',
4444
result: {message: `Binning process`, process: 40}
45-
})
46-
if (binopt.clusterMethod === 'leaderbin') {
47-
let estimateSize = Math.max(2, Math.pow(binopt.bin.range[1], 1 / dataSpider3[0].length));
48-
console.log('estimateSize: ' + estimateSize);
49-
bin = binnerN().startBinGridSize(estimateSize).isNormalized(true).minNumOfBins(binopt.bin.range[0]).maxNumOfBins(binopt.bin.range[1]).distanceMethod(binopt.normMethod).coefficient({
50-
reduce_coefficient: 0.3,
51-
reduce_offset: 0,
52-
increase_coefficient: 2,
53-
increase_offset: 0
54-
}).data([]);
55-
} else {
56-
bin = kmeanCluster;
57-
bin.k(binopt.bin.k);
58-
bin.distanceMethod(binopt.normMethod);
59-
bin.iterations(binopt.bin.iterations);
45+
});
46+
switch (binopt.clusterMethod) {
47+
case 'leaderbin':
48+
let estimateSize = Math.max(2, Math.pow(binopt.bin.range[1], 1 / dataSpider3[0].length));
49+
console.log('estimateSize: ' + estimateSize);
50+
bin = binnerN().startBinGridSize(estimateSize).isNormalized(true).minNumOfBins(binopt.bin.range[0]).maxNumOfBins(binopt.bin.range[1]).distanceMethod(binopt.normMethod).coefficient({
51+
reduce_coefficient: 0.3,
52+
reduce_offset: 0,
53+
increase_coefficient: 2,
54+
increase_offset: 0
55+
}).data([]);
56+
break;
57+
default:
58+
bin = kmeanCluster;
59+
bin.k(binopt.bin.k);
60+
bin.distanceMethod(binopt.normMethod);
61+
bin.iterations(binopt.bin.iterations);
62+
break;
6063
}
6164
let process = 50;
6265
let w = 25;

0 commit comments

Comments
 (0)