|
1 | 1 | /* eslint-disable no-console */
|
2 | 2 | /* global Plotly */
|
3 |
| -import {loadData, orderEntriesByValues, perc, chunk} from './utils.js' |
| 3 | +import {loadData, orderEntriesByValues, perc, chunk, groupBy} from './utils.js' |
4 | 4 |
|
5 | 5 | const labelDistributionPlot = data => {
|
6 |
| - const orderedData = orderEntriesByValues(data, [ |
7 |
| - 'overall', |
8 |
| - 'train', |
9 |
| - 'test', |
10 |
| - 'validation', |
| 6 | + const groups = groupBy(data, 'category') |
| 7 | + const orderedData = Object.entries(groups).map(entry => [ |
| 8 | + entry[0], |
| 9 | + entry[1].length, |
11 | 10 | ])
|
12 |
| - const xVals = orderedData.map(entry => entry[1].overall) |
| 11 | + orderedData.sort((a, b) => a[1] - b[1]) |
| 12 | + const xVals = orderedData.map(entry => entry[1]) |
13 | 13 | const categoryDistPlot = {
|
14 | 14 | y: orderedData.map(entry => entry[0]),
|
15 | 15 | x: xVals,
|
@@ -37,7 +37,7 @@ const labelDistributionPlot = data => {
|
37 | 37 | type: 'log',
|
38 | 38 | automargin: true,
|
39 | 39 | tick0: 0,
|
40 |
| - dtick: Math.log10(1), //log10(e**1), 0.30102999566 |
| 40 | + dtick: Math.log10(1), //log10(2) |
41 | 41 | },
|
42 | 42 | }
|
43 | 43 |
|
@@ -104,7 +104,6 @@ const facettedPartitionPlot = data => {
|
104 | 104 | ['overall', 'train', 'test', 'validation'],
|
105 | 105 | ['desc', 'desc', 'desc', 'desc'],
|
106 | 106 | )
|
107 |
| - console.log('orderd', orderedData) |
108 | 107 | const chunks = chunk(orderedData, 9)
|
109 | 108 | const parentPlot = document.getElementById('plot2')
|
110 | 109 |
|
@@ -261,10 +260,10 @@ const testedCategories = data => {
|
261 | 260 | }
|
262 | 261 |
|
263 | 262 | const build = async () => {
|
264 |
| - const [data] = await loadData() |
| 263 | + const [data, categoryPartitions] = await loadData() |
265 | 264 | console.log(data)
|
266 |
| - const entries = Object.entries(data) |
267 |
| - labelDistributionPlot(entries) |
| 265 | + const entries = Object.entries(categoryPartitions) |
| 266 | + labelDistributionPlot(data) |
268 | 267 | tvtPartitionsPlot(entries)
|
269 | 268 | facettedPartitionPlot(entries)
|
270 | 269 | trainedCategories(entries)
|
|
0 commit comments