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 {
return await this.api.getAverageTableWindows(windows);
}
async getQueryWindow(queryIndex): Promise<number[]> {
this.queryWindow = await this.api.getQueryWindow(this.rawValues.slice(queryIndex, queryIndex + this.windowSize));
async getQueryWindow(window): Promise<number[]> {
this.queryWindow = await this.api.getQueryWindow(window);
console.log(this._queryWindow);
return this._queryWindow;
}
......
......@@ -99,7 +99,7 @@ export class OverviewWindowComponent implements OnInit {
y: clickData.y
});
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 = {};
temp[index] = true;
this.service.labels = temp;
......
......@@ -19,30 +19,59 @@ export class ProgressViewComponent implements OnInit {
averagePlot(averages) {
let highest = 100;
const data = averages.map((average, i) => {
if (average.length !== 0 && i < highest) {
let data = averages.map((average, i) => {
if (average.average.length !== 0 && i < highest) {
highest = i;
}
return {
x: [...Array(average.length).keys()],
y: average,
type: 'line',
visible: i === highest
};
return [
{
x: [...Array(average.average.length).keys()],
y: average.average,
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 = [];
for (let i = averages.length - 1; i >= 0; i--) {
const v = visibility.slice();
v[i] = true;
v[i * 3 + 2] = true;
v[i * 3 + 1] = true;
v[i * 3] = true;
steps.push({
label: (100 * (averages.length - i) / averages.length).toString() + '%',
method: 'restyle',
args: ['visible', v]
});
}
console.log(averages.length - 1 - highest);
visibility[averages.length - 1 - highest] = true;
// console.log(averages.length - 1 - highest);
// visibility[averages.length - 1 - highest] = true;
this.data = data;
this.layout = {
showlegend: false,
......@@ -89,9 +118,7 @@ export class ProgressViewComponent implements OnInit {
allWindows.push(this.similarity[i.toString()]);
}
}
console.log(allWindows);
const averages = await this.cache.getAverageProgressWindows(allWindows);
console.log(averages);
this.plot = this.averagePlot(averages);
}
......
......@@ -22,13 +22,39 @@ export class TableOverviewComponent implements OnInit {
}
averagePlot(average): object {
console.log(average);
return {
data: [{
x: [...Array(average.length).keys()],
y: average,
type: 'line',
}],
data: [
{
x: [...Array(average.average.length).keys()],
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: {
showlegend: false,
hovermode: 'closest',
autosize: true,
margin: {
......@@ -61,32 +87,47 @@ export class TableOverviewComponent implements OnInit {
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() {
this.subplots = [];
this.averages = [];
const listOfWindows = [];
for (const tableIndex in this.tables) {
const table = this.tables[tableIndex];
let opacity = new Array(Object.keys(table.entries).length);
opacity.fill(1);
if (this.service.queryWindow) {
const queryEntry = this.calculateSignature(table.hash, this.service.queryWindow);
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(
{
data: [{
x: Object.keys(table.entries).map((hash: string) => {
x: orderedHashes.map((hash: string) => {
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',
marker: {
color: Object.values(table.entries).map((values: number[]) => {
if (values.indexOf(this.service.query) > -1) {
return 'red';
}
return 'blue';
})
opacity
}
}],
layout: {
......@@ -120,7 +161,7 @@ export class TableOverviewComponent implements OnInit {
async setQuery(data) {
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();
}
}
......@@ -2,14 +2,7 @@
<project version="4">
<component name="ChangeListManager">
<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/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" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
......@@ -23,8 +16,8 @@
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="245">
<caret line="141" column="20" lean-forward="true" selection-start-line="141" selection-start-column="20" selection-end-line="141" selection-end-column="20" />
<state relative-caret-position="330">
<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>
<element signature="e#0#41#0" expanded="true" />
</folding>
......@@ -64,9 +57,9 @@
</list>
</option>
</component>
<component name="ProjectFrameBounds" extendedState="7">
<option name="x" value="100" />
<option name="y" value="-36" />
<component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="-11" />
<option name="y" value="-11" />
<option name="width" value="1890" />
<option name="height" value="960" />
</component>
......@@ -149,17 +142,18 @@
<workItem from="1599487808817" duration="1192000" />
<workItem from="1599578907139" duration="8436000" />
<workItem from="1599661275060" duration="1249000" />
<workItem from="1600001984238" duration="3064000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="94056000" />
<option name="totallyTimeSpent" value="97120000" />
</component>
<component name="ToolWindowManager">
<frame x="-7" y="-7" width="1295" height="695" extended-state="7" />
<editor active="true" />
<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="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
......@@ -215,8 +209,8 @@
</entry>
<entry file="file://$PROJECT_DIR$/main.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="245">
<caret line="141" column="20" lean-forward="true" selection-start-line="141" selection-start-column="20" selection-end-line="141" selection-end-column="20" />
<state relative-caret-position="330">
<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>
<element signature="e#0#41#0" expanded="true" />
</folding>
......
......@@ -140,8 +140,14 @@ def average_progress():
if len(actual_windows) == 0:
output.append([])
continue
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))
response = orjson.dumps(output)
print("Averages calculated: " + str(time() - t0))
......@@ -159,7 +165,14 @@ def average_table():
t1 = time()
actual_windows = data[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))
response = orjson.dumps(output)
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