Skip to content
Snippets Groups Projects
Commit 59d73e17 authored by Kruyff,D.L.W. (Dylan)'s avatar Kruyff,D.L.W. (Dylan)
Browse files

Add documentation

Former-commit-id: 203becf4
parent d0d79ba2
No related branches found
No related tags found
No related merge requests found
...@@ -61,14 +61,14 @@ export class ApiService { ...@@ -61,14 +61,14 @@ export class ApiService {
} }
// Find candidates using LSH with weights // Find candidates using LSH with weights
async lshUpdate(query, hashFunctions, parameters): Promise<LshData> { async lshUpdate(query, weights, parameters): Promise<LshData> {
const response = await fetch('http://127.0.0.1:5000/update', { const response = await fetch('http://127.0.0.1:5000/update', {
method: 'POST', method: 'POST',
headers: { headers: {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: new Blob( [ JSON.stringify({query, hash_functions: hashFunctions, parameters}) ], { type: 'text/plain' } ) body: new Blob( [ JSON.stringify({query, weights, parameters}) ], { type: 'text/plain' } )
}); });
return await response.json(); return await response.json();
} }
......
...@@ -67,7 +67,7 @@ export class StateService { ...@@ -67,7 +67,7 @@ export class StateService {
} }
async update(): Promise<void> { async update(): Promise<void> {
this.lshData = await this.api.lshUpdate(this._queryWindow, [], this._parameters); this.lshData = await this.api.lshUpdate(this._queryWindow, [], this.lshData.parameters);
this.createTable(); this.createTable();
} }
...@@ -109,6 +109,7 @@ export class StateService { ...@@ -109,6 +109,7 @@ export class StateService {
} }
public set lshData(v: LshData) { public set lshData(v: LshData) {
console.log(v);
this._lshData = v; this._lshData = v;
} }
...@@ -126,6 +127,7 @@ export class StateService { ...@@ -126,6 +127,7 @@ export class StateService {
} }
public set table(v: {[bucket: string]: number[]}) { public set table(v: {[bucket: string]: number[]}) {
console.log(v);
this._table = v; this._table = v;
this.onNewTable.emit(); this.onNewTable.emit();
} }
......
...@@ -20,20 +20,13 @@ ...@@ -20,20 +20,13 @@
</component> </component>
<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 afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/state.service.ts" afterDir="false" />
<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/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" /> <change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/state.service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/state.service.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/labeling-window/labeling-window.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/labeling-window/labeling-window.component.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/labeling-window/labeling-window.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/labeling-window/labeling-window.component.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/labels/labels.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/labels/labels.component.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/main/main.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/main/main.component.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.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/settings/settings.component.ts" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/settings/settings.component.ts" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../AngularApp/prototype/src/app/table-overview/table-overview.component.html" beforeDir="false" afterPath="$PROJECT_DIR$/../AngularApp/prototype/src/app/table-overview/table-overview.component.html" 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$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/_lsh.cpython-38-x86_64-linux-gnu.so" beforeDir="false" afterPath="$PROJECT_DIR$/_lsh.cpython-38-x86_64-linux-gnu.so" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build/lib.linux-x86_64-3.8/_lsh.cpython-38-x86_64-linux-gnu.so" beforeDir="false" afterPath="$PROJECT_DIR$/build/lib.linux-x86_64-3.8/_lsh.cpython-38-x86_64-linux-gnu.so" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build/temp.linux-x86_64-3.8/Dylan/lsh-fast/_lsh.o" beforeDir="false" afterPath="$PROJECT_DIR$/build/temp.linux-x86_64-3.8/Dylan/lsh-fast/_lsh.o" afterDir="false" />
<change beforePath="$PROJECT_DIR$/build/temp.linux-x86_64-3.8/Dylan/lsh-fast/lsh.o" beforeDir="false" afterPath="$PROJECT_DIR$/build/temp.linux-x86_64-3.8/Dylan/lsh-fast/lsh.o" 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="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
...@@ -101,16 +101,13 @@ def update(): ...@@ -101,16 +101,13 @@ def update():
data = np.load('processed-data.npy') data = np.load('processed-data.npy')
data = np.reshape(data, (len(data), len(data[0]), 1)) data = np.reshape(data, (len(data), len(data[0]), 1))
# data = np.repeat(data, repeats=1, axis=2) # data = np.repeat(data, repeats=1, axis=2)
hash_functions = raw_data["hash_functions"] weights = raw_data["weights"]
hash_functions = np.array(hash_functions, dtype='double')
hash_functions = (hash_functions - np.min(hash_functions)) / np.ptp(hash_functions)
hash_functions = np.reshape(hash_functions, (len(data[0]), 1))
query = raw_data["query"] query = raw_data["query"]
query = np.reshape(query, (len(query), 1)) query = np.reshape(query, (len(query), 1))
# query = np.repeat(query, repeats=1, axis=1) # query = np.repeat(query, repeats=1, axis=1)
parameters = raw_data["parameters"] parameters = raw_data["parameters"]
candidates, distances, hf = _lsh.lsh(data, query, parameters[0], parameters[1], parameters[2], hash_functions) candidates, distances, hf = _lsh.lsh(data, query, parameters[0], parameters[1], parameters[2])
response = { response = {
"hash_functions": hf.tolist(), "hash_functions": hf.tolist(),
"distances": distances.tolist(), "distances": distances.tolist(),
...@@ -231,83 +228,32 @@ def debug_test_lsh(): ...@@ -231,83 +228,32 @@ def debug_test_lsh():
create_windows() create_windows()
query_n = 80503 query_n = 80503
data = np.load('processed-data.npy') data = np.load('processed-data.npy')
query = performDBA(data[[80503, 11514]]) query = data[query_n] # performDBA(data[[80503, 11514]])
query = np.reshape(query, (len(data[0]), 1)) query = np.reshape(query, (len(data[0]), 1))
data= np.array(data, dtype='double') data= np.array(data, dtype='double')
data = np.reshape(data, (len(data), len(data[0]), 1)) data = np.reshape(data, (len(data), len(data[0]), 1))
data = np.repeat(data, repeats=1, axis=2) data = np.repeat(data, repeats=1, axis=2)
# query = data[query_n]
candidates, distances, hf = _lsh.lsh(data, query, r, a, sd) candidates, distances, hf = _lsh.lsh(data, query, r, a, sd)
print(repr(candidates[0:20])) print(repr(candidates[0:20]))
print(distances[0:10]) print(distances[0:10])
print(np.where(candidates == 80503))
print(np.where(candidates == 11514))
data = np.load('processed-data.npy') data = np.load('processed-data.npy')
query = data[query_n] query = data[query_n]
distances = [_ucrdtw.ucrdtw(window, query, 0.05 * 120, False)[1] for window in data] print(data[0])
distances = [_ucrdtw.ucrdtw(window, query, 0.05, False)[1] for window in data]
sorted_distances = sorted(distances)
print(sorted_distances[0:10])
topk_dtw = sorted(range(len(distances)), key=lambda k: distances[k]) topk_dtw = sorted(range(len(distances)), key=lambda k: distances[k])
print(topk_dtw[0:10]) print(topk_dtw[0:10])
#
# for candidate in candidates[0:20]:
# print(_ucrdtw.ucrdtw(data[candidate], query, 0.05, False)[1])
#
# # distances_ed = [distance.euclidean(query, window) for window in data] # # distances_ed = [distance.euclidean(query, window) for window in data]
# # topk_ed = sorted(range(len(distances_ed)), key=lambda k: distances_ed[k]) # # topk_ed = sorted(range(len(distances_ed)), key=lambda k: distances_ed[k])
# #
# accuracy = 0 accuracy = 0
# for index in topk_dtw[0:20]: for index in topk_dtw[0:20]:
# if index in candidates[0:20]: if index in candidates[0:20]:
# accuracy += 1 accuracy += 1
# print(accuracy) print(accuracy)
#
# accuracy = 0
# for index in topk_dtw[0:20]:
# if index in candidates[0:50]:
# accuracy += 1
# print(accuracy)
#
# # accuracy = 0
# # for index in topk_ed[0:20]:
# # if index in candidates[0:20]:
# # accuracy += 1
# # print(accuracy)
# #
# # accuracy = 0
# # for index in topk_ed[0:50]:
# # if index in candidates[0:50]:
# # accuracy += 1
# # print(accuracy)
#
# accuracy = 0
# for index in topk_dtw[0:50]:
# if index in candidates[0:1000]:
# accuracy += 1
# print(accuracy)
#
# accuracy = 0
# for index in topk_dtw[0:50]:
# if index in candidates[0:5000]:
# accuracy += 1
# print(accuracy)
#
# accuracy = 0
# for index in topk_dtw[0:50]:
# if index in candidates[0:10000]:
# accuracy += 1
# print(accuracy)
#
# accuracy = 0
# for index in topk_dtw[0:50]:
# if index in candidates[0:50000]:
# accuracy += 1
# print(accuracy)
#
# accuracy = 0
# for index in topk_dtw[0:50]:
# if index in candidates:
# accuracy += 1
# print(accuracy)
# debug_test_lsh(r, a, sd) debug_test_lsh()
\ No newline at end of file \ No newline at end of file
...@@ -17,3 +17,35 @@ Once these are installed on your computer, simply run *run-angular.bat* to set u ...@@ -17,3 +17,35 @@ Once these are installed on your computer, simply run *run-angular.bat* to set u
and *run-flask.bat* to set up the server side API and *run-flask.bat* to set up the server side API
The client-side bat-file should automatically open your browser and connect to http://localhost:4200/ The client-side bat-file should automatically open your browser and connect to http://localhost:4200/
# Documentation
## GUI
The GUI is an Angular framework. It consists of views (components) and a state (service). Every time an API call is done, the state will alter. Using hooks (EventEmitters), views can subscribe state variable changes and alter their view using the new value(s). The types of views is listed below.
### Overview
This view shows the entire dataset. When windows are labeled and candidates are generated, it should show the locations in this overview.
### Query
This view shows the current query.
### Training
This view shows the sampled candidates. In this view the user can label the samples as correct or incorrect. When the user is satisfied the labels will be updated and new samples will be generated.
### Progress
This view will show the progress of the learned classifier. It should show whether the classifier is getting better at understanding the desired pattern
### Labels
This view shows the currently labeled windows. The user should be able to change and delete labels in this view.
### Settings
This view shows the current parameters (e.g. window size)
## API
### /read-data
This API call reads time series data from a file and returns the values and indices.
### /create-windows
This API call reads time series data and chunks it into windows. For now the windows are saved to a file locally.
### /initialize
This API call starts the first iteration of the LSH algorithm. First some essential parameters are calculated. Then the LSH algorithm is called. The API returns the candidates, distances and hash functions.
### /update
This API call runs the LSH algorithm with weights that will manipulate the hashing functions. The API returns the candidates, distances and hash functions.
### /query
This API will return the query data based on the provided window indices. If only one index is given, the API call will return the window values according to the index. If multiple indices are given, the DTW-based average of the window values according to the indices is returned.
### /window
This API simply returns the window values according to the index.
### /table-info
This API call will return extra info needed for the progression view. The input will be a subdivision of windows into buckets, and for each bucket the prototype (average) will be calculated + the distances between each prototype.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment