Commit f7d56127 authored by Kruyff,D.L.W. (Dylan)'s avatar Kruyff,D.L.W. (Dylan)
Browse files

Display aggregate min and max + ordering of buckets in hashtable

parent d9d06a3e
...@@ -85,8 +85,8 @@ export class CacheService { ...@@ -85,8 +85,8 @@ export class CacheService {
return await this.api.getAverageTableWindows(windows); return await this.api.getAverageTableWindows(windows);
} }
async getQueryWindow(queryIndex): Promise<number[]> { async getQueryWindow(window): Promise<number[]> {
this.queryWindow = await this.api.getQueryWindow(this.rawValues.slice(queryIndex, queryIndex + this.windowSize)); this.queryWindow = await this.api.getQueryWindow(window);
console.log(this._queryWindow); console.log(this._queryWindow);
return this._queryWindow; return this._queryWindow;
} }
......
...@@ -99,7 +99,7 @@ export class OverviewWindowComponent implements OnInit { ...@@ -99,7 +99,7 @@ export class OverviewWindowComponent implements OnInit {
y: clickData.y y: clickData.y
}); });
const index = Math.floor(xyInformation[2].nodeidx / this.service.stepSize); const index = Math.floor(xyInformation[2].nodeidx / this.service.stepSize);
await this.service.getQueryWindow(index); await this.service.getQueryWindow(this.service.rawValues.slice(index, index + this.service.windowSize));
const temp = {}; const temp = {};
temp[index] = true; temp[index] = true;
this.service.labels = temp; this.service.labels = temp;
......
...@@ -19,30 +19,59 @@ export class ProgressViewComponent implements OnInit { ...@@ -19,30 +19,59 @@ export class ProgressViewComponent implements OnInit {
averagePlot(averages) { averagePlot(averages) {
let highest = 100; let highest = 100;
const data = averages.map((average, i) => { let data = averages.map((average, i) => {
if (average.length !== 0 && i < highest) { if (average.average.length !== 0 && i < highest) {
highest = i; highest = i;
} }
return { return [
x: [...Array(average.length).keys()], {
y: average, x: [...Array(average.average.length).keys()],
type: 'line', y: average.average,
visible: i === highest type: 'line',
}; visible: i === highest,
},
{
x: [...Array(average.average.length).keys()],
y: average.max,
type: 'scatter',
visible: i === highest,
fill: null,
mode: 'lines',
line: {
color: 'rgb(55, 128, 191)',
width: 3
}
},
{
x: [...Array(average.average.length).keys()],
y: average.min,
type: 'scatter',
visible: i === highest,
fill: 'tonexty',
mode: 'lines',
line: {
color: 'rgb(55, 128, 191)',
width: 3
}
},
];
}); });
const visibility = Array(averages.length).fill(false); data = [].concat(...data);
const visibility = Array(averages.length * 3).fill(false);
const steps = []; const steps = [];
for (let i = averages.length - 1; i >= 0; i--) { for (let i = averages.length - 1; i >= 0; i--) {
const v = visibility.slice(); const v = visibility.slice();
v[i] = true; v[i * 3 + 2] = true;
v[i * 3 + 1] = true;
v[i * 3] = true;
steps.push({ steps.push({
label: (100 * (averages.length - i) / averages.length).toString() + '%', label: (100 * (averages.length - i) / averages.length).toString() + '%',
method: 'restyle', method: 'restyle',
args: ['visible', v] args: ['visible', v]
}); });
} }
console.log(averages.length - 1 - highest); // console.log(averages.length - 1 - highest);
visibility[averages.length - 1 - highest] = true; // visibility[averages.length - 1 - highest] = true;
this.data = data; this.data = data;
this.layout = { this.layout = {
showlegend: false, showlegend: false,
...@@ -89,9 +118,7 @@ export class ProgressViewComponent implements OnInit { ...@@ -89,9 +118,7 @@ export class ProgressViewComponent implements OnInit {
allWindows.push(this.similarity[i.toString()]); allWindows.push(this.similarity[i.toString()]);
} }
} }
console.log(allWindows);
const averages = await this.cache.getAverageProgressWindows(allWindows); const averages = await this.cache.getAverageProgressWindows(allWindows);
console.log(averages);
this.plot = this.averagePlot(averages); this.plot = this.averagePlot(averages);
} }
......
...@@ -22,13 +22,39 @@ export class TableOverviewComponent implements OnInit { ...@@ -22,13 +22,39 @@ export class TableOverviewComponent implements OnInit {
} }
averagePlot(average): object { averagePlot(average): object {
console.log(average);
return { return {
data: [{ data: [
x: [...Array(average.length).keys()], {
y: average, x: [...Array(average.average.length).keys()],
type: 'line', y: average.average,
}], type: 'line',
},
{
x: [...Array(average.average.length).keys()],
y: average.max,
type: 'scatter',
fill: null,
mode: 'lines',
line: {
color: 'rgb(55, 128, 191)',
width: 3
}
},
{
x: [...Array(average.average.length).keys()],
y: average.min,
type: 'scatter',
fill: 'tonexty',
mode: 'lines',
line: {
color: 'rgb(55, 128, 191)',
width: 3
}
}
],
layout: { layout: {
showlegend: false,
hovermode: 'closest', hovermode: 'closest',
autosize: true, autosize: true,
margin: { margin: {
...@@ -61,32 +87,47 @@ export class TableOverviewComponent implements OnInit { ...@@ -61,32 +87,47 @@ export class TableOverviewComponent implements OnInit {
return output.map((x) => x > 0 ? '1' : '0').join(''); return output.map((x) => x > 0 ? '1' : '0').join('');
} }
distanceMetric(hash) {
let sum = 0;
for (let i = 0; i < hash.length; i++) {
if (hash[i] === '1') {
sum++;
}
}
return sum;
}
async createPlots() { async createPlots() {
this.subplots = []; this.subplots = [];
this.averages = []; this.averages = [];
const listOfWindows = []; const listOfWindows = [];
for (const tableIndex in this.tables) { for (const tableIndex in this.tables) {
const table = this.tables[tableIndex]; const table = this.tables[tableIndex];
let opacity = new Array(Object.keys(table.entries).length);
opacity.fill(1);
if (this.service.queryWindow) { if (this.service.queryWindow) {
const queryEntry = this.calculateSignature(table.hash, this.service.queryWindow); const queryEntry = this.calculateSignature(table.hash, this.service.queryWindow);
listOfWindows.push(table.entries[queryEntry]); listOfWindows.push(table.entries[queryEntry]);
opacity = Object.keys(table.entries).map((hash: string) => {
return hash === queryEntry ? 1.0 : 0.5;
}
);
} }
const orderedHashes = Object.keys(table.entries).sort((hash1, hash2) => {
return this.distanceMetric(hash1) - this.distanceMetric(hash2);
});
console.log(orderedHashes);
this.subplots.push( this.subplots.push(
{ {
data: [{ data: [{
x: Object.keys(table.entries).map((hash: string) => { x: orderedHashes.map((hash: string) => {
return Number('0b' + hash); return Number('0b' + hash);
} }
), ),
y: Object.values(table.entries).map((values: number[]) => values.length / (this.service.rawValues.length - this.service.windowSize)), y: orderedHashes.map((hash: string) => table.entries[hash].length / (this.service.rawValues.length - this.service.windowSize)),
type: 'bar', type: 'bar',
marker: { marker: {
color: Object.values(table.entries).map((values: number[]) => { opacity
if (values.indexOf(this.service.query) > -1) {
return 'red';
}
return 'blue';
})
} }
}], }],
layout: { layout: {
...@@ -120,7 +161,7 @@ export class TableOverviewComponent implements OnInit { ...@@ -120,7 +161,7 @@ export class TableOverviewComponent implements OnInit {
async setQuery(data) { async setQuery(data) {
console.log('clicked for query'); console.log('clicked for query');
this.service.queryWindow = data[0].y; this.service.queryWindow = await this.service.getQueryWindow(data[0].y);
await this.service.getSimilarWindows(); await this.service.getSimilarWindows();
} }
} }
...@@ -2,14 +2,7 @@ ...@@ -2,14 +2,7 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="556080ba-825c-4b55-a92a-867a4df4fb32" name="Default Changelist" comment=""> <list default="true" id="556080ba-825c-4b55-a92a-867a4df4fb32" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/api.service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/api.service.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/cache.service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/cache.service.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/overview-window/overview-window.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/overview-window/overview-window.component.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/progress-view/progress-view.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/progress-view/progress-view.component.ts" afterDir="false" /> <change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/progress-view/progress-view.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/progress-view/progress-view.component.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/query-window/query-window.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/query-window/query-window.component.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/query-window/query-window.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/query-window/query-window.component.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/table-overview/table-overview.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/table-overview/table-overview.component.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
...@@ -23,8 +16,8 @@ ...@@ -23,8 +16,8 @@
<file pinned="false" current-in-tab="true"> <file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/main.py"> <entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="245"> <state relative-caret-position="330">
<caret line="141" column="20" lean-forward="true" selection-start-line="141" selection-start-column="20" selection-end-line="141" selection-end-column="20" /> <caret line="161" column="15" lean-forward="true" selection-start-line="161" selection-start-column="15" selection-end-line="161" selection-end-column="15" />
<folding> <folding>
<element signature="e#0#41#0" expanded="true" /> <element signature="e#0#41#0" expanded="true" />
</folding> </folding>
...@@ -64,9 +57,9 @@ ...@@ -64,9 +57,9 @@
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectFrameBounds" extendedState="7"> <component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="100" /> <option name="x" value="-11" />
<option name="y" value="-36" /> <option name="y" value="-11" />
<option name="width" value="1890" /> <option name="width" value="1890" />
<option name="height" value="960" /> <option name="height" value="960" />
</component> </component>
...@@ -149,17 +142,18 @@ ...@@ -149,17 +142,18 @@
<workItem from="1599487808817" duration="1192000" /> <workItem from="1599487808817" duration="1192000" />
<workItem from="1599578907139" duration="8436000" /> <workItem from="1599578907139" duration="8436000" />
<workItem from="1599661275060" duration="1249000" /> <workItem from="1599661275060" duration="1249000" />
<workItem from="1600001984238" duration="3064000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="94056000" /> <option name="totallyTimeSpent" value="97120000" />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="-7" y="-7" width="1295" height="695" extended-state="7" /> <frame x="-7" y="-7" width="1295" height="695" extended-state="7" />
<editor active="true" /> <editor active="true" />
<layout> <layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.29021826" /> <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.28698465" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" /> <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" /> <window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" /> <window_info anchor="bottom" id="Message" order="0" />
...@@ -215,8 +209,8 @@ ...@@ -215,8 +209,8 @@
</entry> </entry>
<entry file="file://$PROJECT_DIR$/main.py"> <entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="245"> <state relative-caret-position="330">
<caret line="141" column="20" lean-forward="true" selection-start-line="141" selection-start-column="20" selection-end-line="141" selection-end-column="20" /> <caret line="161" column="15" lean-forward="true" selection-start-line="161" selection-start-column="15" selection-end-line="161" selection-end-column="15" />
<folding> <folding>
<element signature="e#0#41#0" expanded="true" /> <element signature="e#0#41#0" expanded="true" />
</folding> </folding>
......
...@@ -140,8 +140,14 @@ def average_progress(): ...@@ -140,8 +140,14 @@ def average_progress():
if len(actual_windows) == 0: if len(actual_windows) == 0:
output.append([]) output.append([])
continue continue
print(len(actual_windows)) max_values = np.maximum.reduce(actual_windows).tolist()
output.append((np.sum(actual_windows, 0)/len(actual_windows)).tolist()) min_values = np.minimum.reduce(actual_windows).tolist()
average_values = (np.sum(actual_windows, 0)/len(actual_windows)).tolist()
output.append({
'average': average_values,
'max': max_values,
'min': min_values
})
print("Average calculated: " + str(time() - t1)) print("Average calculated: " + str(time() - t1))
response = orjson.dumps(output) response = orjson.dumps(output)
print("Averages calculated: " + str(time() - t0)) print("Averages calculated: " + str(time() - t0))
...@@ -159,7 +165,14 @@ def average_table(): ...@@ -159,7 +165,14 @@ def average_table():
t1 = time() t1 = time()
actual_windows = data[windows] actual_windows = data[windows]
print(len(actual_windows)) print(len(actual_windows))
output.append((np.sum(actual_windows, 0)/len(actual_windows)).tolist()) max_values = np.maximum.reduce(actual_windows).tolist()
min_values = np.minimum.reduce(actual_windows).tolist()
average_values = (np.sum(actual_windows, 0) / len(actual_windows)).tolist()
output.append({
'average': average_values,
'max': max_values,
'min': min_values
})
print("Average calculated: " + str(time() - t1)) print("Average calculated: " + str(time() - t1))
response = orjson.dumps(output) response = orjson.dumps(output)
print("Averages calculated: " + str(time() - t0)) print("Averages calculated: " + str(time() - t0))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment