ping98k commited on
Commit
aa85324
·
1 Parent(s): c305ab2

Refactor K-Means input handling to exclude cluster header lines and adjust heatmap margin settings for improved layout

Browse files
Files changed (1) hide show
  1. main.js +6 -3
main.js CHANGED
@@ -25,7 +25,10 @@ document.getElementById("run").onclick = async () => {
25
 
26
  const groupEmbeddings = [];
27
  for (const g of groups) {
28
- const lines = g.split(/\n/).filter(x => x.trim() != "");
 
 
 
29
  const prompts = lines.map(s => `Instruct: ${task}\nQuery:${s}`);
30
  const out = await embed(prompts, { pooling: "mean", normalize: true });
31
  const embeddings = typeof out.tolist === 'function' ? out.tolist() : out.data;
@@ -52,13 +55,13 @@ document.getElementById("run").onclick = async () => {
52
  }
53
  // If clusterNames exist and match group count, use as axis labels
54
  let xLabels = clusterNames && clusterNames.length === n ? clusterNames : Array.from({length: n}, (_, i) => `Group ${i+1}`);
55
- const data = [{ z: sim, type: "heatmap", colorscale: "Viridis", zmin: 0, zmax: 1, x: xLabels, y: xLabels }];
56
  Plotly.newPlot("plot-heatmap", data, {
57
  xaxis: { title: "Group", scaleanchor: "y", scaleratio: 1 },
58
  yaxis: { title: "Group", scaleanchor: "x", scaleratio: 1 },
59
  width: 500,
60
  height: 500,
61
- margin: { t: 40, l: 40, r: 10, b: 40 },
62
  title: "Group Similarity Heatmap"
63
  });
64
  };
 
25
 
26
  const groupEmbeddings = [];
27
  for (const g of groups) {
28
+ // Remove lines starting with ##
29
+ const lines = g.split(/\n/)
30
+ .map(x => x.trim())
31
+ .filter(x => x && !x.startsWith('##'));
32
  const prompts = lines.map(s => `Instruct: ${task}\nQuery:${s}`);
33
  const out = await embed(prompts, { pooling: "mean", normalize: true });
34
  const embeddings = typeof out.tolist === 'function' ? out.tolist() : out.data;
 
55
  }
56
  // If clusterNames exist and match group count, use as axis labels
57
  let xLabels = clusterNames && clusterNames.length === n ? clusterNames : Array.from({length: n}, (_, i) => `Group ${i+1}`);
58
+ const data = [{ z: sim, type: "heatmap", colorscale: "Viridis", zmin: 0.7, zmax: 1, x: xLabels, y: xLabels }];
59
  Plotly.newPlot("plot-heatmap", data, {
60
  xaxis: { title: "Group", scaleanchor: "y", scaleratio: 1 },
61
  yaxis: { title: "Group", scaleanchor: "x", scaleratio: 1 },
62
  width: 500,
63
  height: 500,
64
+ margin: { t: 40, l: 200, r: 10, b: 200 },
65
  title: "Group Similarity Heatmap"
66
  });
67
  };