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

Redo lost changes

parent 8d4ead19
Documents/ Documents/
AngularApp/prototype/node_modules AngularApp/prototype/node_modules
Flaskserver/venv/*
\ No newline at end of file
...@@ -16420,6 +16420,25 @@ ...@@ -16420,6 +16420,25 @@
"cwise-compiler": "^1.0.0" "cwise-compiler": "^1.0.0"
} }
}, },
"zingchart": {
"version": "2.9.1",
"resolved": "https://registry.npmjs.org/zingchart/-/zingchart-2.9.1.tgz",
"integrity": "sha512-LYCiqkzdDn5OxPqShfvUNcTtXxVgZDVqEztGINBb0EA9a1b1TOrLbW/BdJPpeobBahXSxvHYLO6NV/Dbw309Vw=="
},
"zingchart-angular": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/zingchart-angular/-/zingchart-angular-1.0.0.tgz",
"integrity": "sha512-T55KMk/1k5pcQ5sxTx0RTzIElbkJKWbvfgLTLiqaLz7kobrGLHxuNNS9Oya36p2Oaq/CxtoYFnCpM2V+zFd9Wg==",
"requires": {
"tslib": "^1.9.0",
"zingchart": "^2.9.1",
"zingchart-constants": "github:zingchart/zingchart-constants#master"
}
},
"zingchart-constants": {
"version": "github:zingchart/zingchart-constants#2cb0b3a55bbae8ee6fb943161fdd5b71618bc95f",
"from": "github:zingchart/zingchart-constants#master"
},
"zone.js": { "zone.js": {
"version": "0.10.3", "version": "0.10.3",
"resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.10.3.tgz", "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.10.3.tgz",
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
"plotly.js": "^1.54.6", "plotly.js": "^1.54.6",
"rxjs": "~6.5.4", "rxjs": "~6.5.4",
"tslib": "^1.10.0", "tslib": "^1.10.0",
"zingchart-angular": "^1.0.0",
"zone.js": "~0.10.2" "zone.js": "~0.10.2"
}, },
"devDependencies": { "devDependencies": {
......
...@@ -32,19 +32,21 @@ export class ApiService { ...@@ -32,19 +32,21 @@ export class ApiService {
}, },
body: JSON.stringify(postData) body: JSON.stringify(postData)
}); });
return (await response.json()).data; return await response.json();
} }
// Generate LSH-tables by hashing each window // Generate LSH-tables by hashing each window
async createTables(windows, parameters): Promise<any> { async createTables(windows, parameters): Promise<any> {
console.log("creating tables");
const postData = {windows, parameters}; const postData = {windows, parameters};
console.log("ahh");
const response = await fetch('http://127.0.0.1:5000/create-tables', { const response = await fetch('http://127.0.0.1:5000/create-tables', {
method: 'POST', method: 'POST',
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(postData) body: new Blob( [ JSON.stringify(postData) ], { type: 'text/plain' } )
}); });
return await response.json(); return await response.json();
} }
...@@ -70,7 +72,7 @@ export class ApiService { ...@@ -70,7 +72,7 @@ export class ApiService {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify(postData) body: new Blob( [ JSON.stringify(postData) ], { type: 'text/plain' } )
}); });
return await response.json(); return await response.json();
} }
......
...@@ -14,6 +14,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; ...@@ -14,6 +14,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import {MatTabsModule} from '@angular/material/tabs'; import {MatTabsModule} from '@angular/material/tabs';
import { LabelsComponent } from './labels/labels.component'; import { LabelsComponent } from './labels/labels.component';
import { QueryWindowComponent } from './query-window/query-window.component'; import { QueryWindowComponent } from './query-window/query-window.component';
import {ZingchartAngularModule} from 'zingchart-angular';
PlotlyModule.plotlyjs = PlotlyJS; PlotlyModule.plotlyjs = PlotlyJS;
...@@ -32,7 +33,8 @@ PlotlyModule.plotlyjs = PlotlyJS; ...@@ -32,7 +33,8 @@ PlotlyModule.plotlyjs = PlotlyJS;
FormsModule, FormsModule,
PlotlyModule, PlotlyModule,
BrowserAnimationsModule, BrowserAnimationsModule,
MatTabsModule MatTabsModule,
ZingchartAngularModule
], ],
providers: [], providers: [],
bootstrap: [AppComponent] bootstrap: [AppComponent]
......
...@@ -15,9 +15,10 @@ export class CacheService { ...@@ -15,9 +15,10 @@ export class CacheService {
private _tables; private _tables;
private _windowSimilarity; private _windowSimilarity;
public windowSize = 60; public windowSize = 200;
public nrOfTables = 10; public nrOfTables = 10;
public hashSize = 10; public hashSize = 5;
public stepSize = 1;
public onNewSimilarity: EventEmitter<void> = new EventEmitter<void>(); public onNewSimilarity: EventEmitter<void> = new EventEmitter<void>();
public onNewLabels: EventEmitter<void> = new EventEmitter<void>(); public onNewLabels: EventEmitter<void> = new EventEmitter<void>();
...@@ -130,7 +131,8 @@ export class CacheService { ...@@ -130,7 +131,8 @@ export class CacheService {
return { return {
windowsize: this.windowSize, windowsize: this.windowSize,
hashsize: this.hashSize, hashsize: this.hashSize,
tablesize: this.nrOfTables tablesize: this.nrOfTables,
stepsize: this.stepSize
}; };
} }
} }
...@@ -94,6 +94,9 @@ export class LabelingWindowComponent implements OnInit { ...@@ -94,6 +94,9 @@ export class LabelingWindowComponent implements OnInit {
titlefont: { titlefont: {
size: 9 size: 9
}, },
xaxis: {
showticklabels: false,
}
} }
} }
); );
......
<div style="overflow: auto"> <div style="overflow: auto">
<plotly-plot *ngIf="showPlot" [data]="data" [layout]="layout" (plotly_click)="clicked($event)"></plotly-plot> <!-- <plotly-plot *ngIf="showPlot" [data]="data" [layout]="layout" (plotly_click)="clicked($event)"></plotly-plot>-->
</div> </div>
<zingchart-angular [config]="config" [height]="500" [series]="series" (node_click)="clicked($event)"></zingchart-angular>
import {ChangeDetectorRef, Component, OnInit} from '@angular/core'; import { Component} from '@angular/core';
import { CacheService } from '../cache.service'; import { CacheService } from '../cache.service';
import {throwError} from 'rxjs';
@Component({ @Component({
selector: 'app-overview-window', selector: 'app-overview-window',
templateUrl: './overview-window.component.html', templateUrl: './overview-window.component.html',
styleUrls: ['./overview-window.component.css'] styleUrls: ['./overview-window.component.css']
}) })
export class OverviewWindowComponent implements OnInit { export class OverviewWindowComponent {
public defaultColors: string[]; public config;
public defaultSizes: number[]; public series;
public defaultOpacity: number[];
public showPlot = false; public showPlot = false;
public data; public data;
public layout; public layout;
constructor(private service: CacheService) { } constructor(private service: CacheService) {
}
async ngOnInit(): Promise<void> { async ngOnInit(): Promise<void> {
this.service.onNewWindows.subscribe(() => { this.initializePlot(); }); this.service.onNewWindows.subscribe(() => { this.initializePlot(); });
...@@ -29,46 +28,73 @@ export class OverviewWindowComponent implements OnInit { ...@@ -29,46 +28,73 @@ export class OverviewWindowComponent implements OnInit {
async initializePlot() { async initializePlot() {
this.service.query = undefined; this.service.query = undefined;
const size = this.service.rawValues.length; // this.data = this.service.rawIndices.map((e, i) => {
this.defaultColors = Array(size).fill('#a3a7e4'); // return [e, values[i]];
this.defaultSizes = Array(size).fill(5); // });
this.defaultOpacity = Array(size).fill(1); this.data = [];
this.data = [{ for (let i = 0; i < this.service.rawValues.length; i++) {
x: this.service.rawIndices, this.data.push([i, this.service.rawValues[i]]);
y: this.service.rawValues, }
type: 'scattergl', this.config = {
// mode: 'markers', type: "mixed",
// marker: { preview: {
// size: this.defaultSizes.slice(), 'auto-fit': true,
// color: this.defaultColors.slice()} handleTop: {
}]; alpha : 0.0
this.layout = { },
hovermode: 'closest', handleBottom: {
autosize: true, alpha : 0.0
margin: { }
l: 40, },
r: 0, 'scale-x': {
b: 40, zooming: true,
t: 0, zoomTo: [0, this.service.windowSize],
pad: 4 'auto-fit': true
},
'scale-y': {
zooming: true,
'auto-fit': true
},
series: [
{
type: 'line',
values: this.data,
text: 'Raw Values',
zIndex: 5,
marker: {
alpha: 0.0,
zIndex: 10
}
},
{
type: 'scatter',
values: [],
text: 'Good labels',
marker: {
backgroundColor: '#4caf50'
},
zIndex: 20,
}, },
height: 200, {
xaxis: { type: 'scatter',
showticklabels: false, values: [],
// rangeslider: {} text: 'Bad labels',
marker: {
backgroundColor: '#f44336'
}, },
zIndex: 20,
}]
}; };
this.showPlot = true;
console.log("showing plot"); console.log("showing plot");
} }
async clicked(clickData) { async clicked(clickData) {
for (const point of clickData.points) { console.log('clicked node');
this.service.query = point.pointNumber; const index = Math.floor(clickData.nodeindex / this.service.stepSize);
this.service.query = index;
const temp = {}; const temp = {};
temp[point.pointNumber] = true; temp[index] = true;
this.service.labels = temp; this.service.labels = temp;
}
await this.updatePlot(); await this.updatePlot();
} }
...@@ -79,29 +105,71 @@ export class OverviewWindowComponent implements OnInit { ...@@ -79,29 +105,71 @@ export class OverviewWindowComponent implements OnInit {
// Similarity // Similarity
const windowSimilarity = await this.service.getSimilarWindows(this.service.windows[this.service.query]); const windowSimilarity = await this.service.getSimilarWindows(this.service.windows[this.service.query]);
for (const frequency in windowSimilarity){ console.log(windowSimilarity);
for (const index of windowSimilarity[frequency]) { // for (const frequency in windowSimilarity){
colors[index] = this.getColor(Number(frequency) / this.service.nrOfTables); // for (const index of windowSimilarity[frequency]) {
sizes[index] = 5; // colors[index] = this.getColor(Number(frequency) / this.service.nrOfTables);
opacity[index] = Math.max(Number(frequency) / this.service.nrOfTables, 0.5); // sizes[index] = 5;
// opacity[index] = Math.max(Number(frequency) / this.service.nrOfTables, 0.5);
// }
// }
let goodLabels = [];
let badLabels = [];
for (const index in this.service.labels) {
console.log(index);
if (this.service.labels[index]) {
goodLabels.push(this.data[index]);
} else {
badLabels.push(this.data[index]);
} }
} }
console.log(goodLabels);
// Labeled console.log(badLabels);
for (const index in this.service.labels) { this.series = [
colors[Number(index)] = this.service.labels[index] ? '#4caf50' : '#f44336'; {
sizes[Number(index)] = 10; type: 'line',
opacity[Number(index)] = 1; values: this.data,
text: 'Raw Values',
zIndex: 5,
marker: {
alpha: 0.0,
zIndex: 10
} }
},
{
type: 'scatter',
values: goodLabels,
text: 'Good labels',
marker: {
backgroundColor: '#4caf50'
},
zIndex: 20,
},
{
type: 'scatter',
values: badLabels,
text: 'Bad labels',
marker: {
backgroundColor: '#f44336'
},
zIndex: 20,
}
];
// // Labeled
// for (const index in this.service.labels) {
// colors[Number(index)] = this.service.labels[index] ? '#4caf50' : '#f44336';
// sizes[Number(index)] = 10;
// opacity[Number(index)] = 1;
// }
//
// // Query
// colors[this.service.query] = '#cf00ff';
// sizes[this.service.query] = 10;
// opacity[this.service.query] = 1;
// Query // this.data[0].marker.color = colors;
colors[this.service.query] = '#cf00ff'; // this.data[0].marker.size = sizes;
sizes[this.service.query] = 10; // this.data[0].marker.opacity = opacity;
opacity[this.service.query] = 1;
this.data[0].marker.color = colors;
this.data[0].marker.size = sizes;
this.data[0].marker.opacity = opacity;
} }
public getColor(value: number) { public getColor(value: number) {
......
...@@ -44,6 +44,9 @@ export class QueryWindowComponent implements OnInit { ...@@ -44,6 +44,9 @@ export class QueryWindowComponent implements OnInit {
titlefont: { titlefont: {
size: 9 size: 9
}, },
xaxis: {
showticklabels: false,
}
} }
}; };
} }
......
This diff is collapsed.
...@@ -4,7 +4,6 @@ import numpy as np ...@@ -4,7 +4,6 @@ import numpy as np
from flask_cors import CORS from flask_cors import CORS
from collections import defaultdict, Counter from collections import defaultdict, Counter
from time import time from time import time
import dask.dataframe as dd
import os.path import os.path
import json import json
from sklearn import preprocessing from sklearn import preprocessing
...@@ -20,15 +19,15 @@ def index(): ...@@ -20,15 +19,15 @@ def index():
@app.route('/read-data', methods=['GET']) @app.route('/read-data', methods=['GET'])
def read_data(): def read_data():
filename = 'processed-data.pkl' filename = 'processed-data.pkl'
if (not os.path.isfile(filename)): # if (not os.path.isfile(filename)):
print("start") # print("start")
df = dd.read_csv("NW_Ground_Stations_2016.csv", usecols=['number_sta', 'date', 't']) # df = dd.read_csv("NW_Ground_Stations_2016.csv", usecols=['number_sta', 'date', 't'])
print("read file") # print("read file")
df = df.loc[df['number_sta'] == 14066001] # df = df.loc[df['number_sta'] == 14066001]
print("split rows") # print("split rows")
df = df.compute() # df = df.compute()
df.to_pickle(filename) # df.to_pickle(filename)
print("to_pandas") # print("to_pandas")
df = pd.read_pickle(filename) df = pd.read_pickle(filename)
df.dropna(subset=['t'], inplace=True) df.dropna(subset=['t'], inplace=True)
response = { response = {
...@@ -113,15 +112,13 @@ def query(): ...@@ -113,15 +112,13 @@ def query():
tables = raw_data["tables"] tables = raw_data["tables"]
neighbours = [] neighbours = []
output = {} output = defaultdict(list)
for t in tables.values(): for t in tables.values():
signature = ''.join((np.dot(window, t["hash"]) > 0).astype('int').astype('str')) signature = ''.join((np.dot(window, t["hash"]) > 0).astype('int').astype('str'))
neighbours.extend(t["entries"][signature]) neighbours.extend(t["entries"][signature])
neighbours_with_frequency = dict(Counter(neighbours)) neighbours_with_frequency = dict(Counter(neighbours))
for index, frequency in neighbours_with_frequency.items(): for index, frequency in neighbours_with_frequency.items():
if not frequency in output:
output[str(frequency)] = []
output[str(frequency)].append(index) output[str(frequency)].append(index)
response = orjson.dumps(output) response = orjson.dumps(output)
return response return response
......
Copyright (c) 2014-2018, Anaconda, Inc. and contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
Neither the name of Anaconda nor the names of any contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
Metadata-Version: 2.1
Name: dask
Version: 2.21.0
Summary: Parallel PyData with Task Scheduling
Home-page: https://github.com/dask/dask/
Maintainer: Matthew Rocklin
Maintainer-email: mrocklin@gmail.com
License: BSD
Keywords: task-scheduling parallel numpy pandas pydata
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Requires-Python: >=3.6
Requires-Dist: pyyaml
Provides-Extra: array
Requires-Dist: numpy (>=1.13.0) ; extra == 'array'
Requires-Dist: toolz (>=0.8.2) ; extra == 'array'
Provides-Extra: bag
Requires-Dist: cloudpickle (>=0.2.2) ; extra == 'bag'
Requires-Dist: fsspec (>=0.6.0) ; extra == 'bag'
Requires-Dist: toolz (>=0.8.2) ; extra == 'bag'
Requires-Dist: partd (>=0.3.10) ; extra == 'bag'
Provides-Extra: complete
Requires-Dist: bokeh (>=1.0.0) ; extra == 'complete'
Requires-Dist: cloudpickle (>=0.2.2) ; extra == 'complete'
Requires-Dist: distributed (>=2.0) ; extra == 'complete'
Requires-Dist: fsspec (>=0.6.0) ; extra == 'complete'