StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics
https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
24 KiB
1 line
24 KiB
4 years ago
|
{"version":3,"file":"d3-loom.js","sources":["../src/compare-value.js","../src/constant.js","../src/loom.js","../src/string.js"],"sourcesContent":["export default function compareValue(compare) {\n return (a, b) => compare(a.outer.value, b.outer.value);\n}\n","export default function constant(x) {\n return () => x;\n}\n","/* Based on the d3v4 d3.chord() function by Mike Bostock\n** Adjusted by Nadieh Bremer - July 2016 */\n\n/* global d3 */\nimport compareValue from './compare-value';\nimport constant from './constant';\n\nexport default function loom() {\n const tau = Math.PI * 2;\n\n let padAngle = 0;\n let sortGroups = null;\n let sortSubgroups = null;\n let sortLooms = null;\n let emptyPerc = 0.2;\n let heightInner = 20;\n let widthInner = () => 30;\n let value = d => d.value;\n let inner = d => d.inner;\n let outer = d => d.outer;\n\n function loomLayout(layoutData) {\n // Nest the data on the outer variable\n const data = d3.nest().key(outer).entries(layoutData);\n\n const n = data.length;\n\n // Loop over the outer groups and sum the values\n\n const groupSums = [];\n const groupIndex = d3.range(n);\n const subgroupIndex = [];\n const looms = [];\n looms.groups = new Array(n);\n const groups = looms.groups;\n let numSubGroups;\n looms.innergroups = [];\n const uniqueInner = looms.innergroups;\n const uniqueCheck = [];\n let k;\n let x;\n let x0;\n let j;\n let l;\n let s;\n let v;\n let sum;\n let section;\n let remain;\n let counter;\n let reverseOrder = false;\n let approxCenter;\n k = 0;\n numSubGroups = 0;\n for (let i = 0; i < n; i += 1) {\n v = data[i].values.length;\n sum = 0;\n for (j = 0; j < v; j += 1) {\n sum += value(data[i].values[j]);\n } // for j\n groupSums.push(sum);\n subgroupIndex.push(d3.range(v));\n numSubGroups += v;\n k += sum;\n } // for i\n\n // Sort the groups…\n if (sortGroups) {\n groupIndex.sort((a, b) => sortGroups(groupSums[a], groupSums[b]));\n }\n\n // Sort subgroups…\n if (sortSubgroups) {\n subgroupIndex.forEach((d, i) => {\n d.sort((a, b) =>\n sortSubgroups(inner(data[i].values[a]), inner(data[i].values[b]))\n );\n });\n }\n\n // After which group are we past the center, taking into account the padding\n // TODO: make something for if there is no \"nice\" split in two...\n const padk = k * (padAngle / tau);\n l = 0;\n for (let i = 0; i < n; i += 1) {\n section = groupSums[groupIndex[i]] + padk;\n l += section;\n if (l > (k + n * padk) / 2) {\n // Check if the group should be added to left or right\n remain = k + n * padk - (l - section);\n approxCenter = remain / section < 0.5\n ? groupIndex[i]\n : groupIndex[i - 1];\n break;\n } // if\n } // for i\n\n // How much should be added to k to make the empty part emptyPerc big of the total\n const emptyk = k * emptyPerc / (1 - emptyPerc);\n k += emptyk;\n\n // Convert the sum to scaling factor for [0, 2pi].\n k = Math.max(0, tau - padAngle * n) / k;\n const dx = k ? padAngle : tau / n;\n\n // Compute the start and end angle for each group and subgroup.\n // Note: Opera has a bug reordering object literal properties!\n const subgroups = new Array(numSubGroups);\n x = emptyk * 0.25 * k; // starting with quarter of the empty part to the side;\n counter = 0;\n for (let i = 0; i < n; i += 1) {\n const di = groupIndex[i];\n const outername = data[di].key;\n\n x0 = x;\n s = subgroupIndex[di].length;\n for (j = 0; j < s; j += 1) {\n const dj = reverseOrder\n ? subgroupIndex[di][s - 1 - j]\n : subgroupIndex[di][j];\n\n v = value(data[di].values[dj]);\n const innername = inner(data[di].values[dj]);\n const a0 = x;\n x += v * k;\n const a1 = x;\n subgroups[counter] = {\n index: di,\n subindex: dj,\n s
|