Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
0839a52c
Commit
0839a52c
authored
Jan 21, 2020
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clustering with agi dataset
parent
f11c4d13
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27060 additions
and
3 deletions
+27060
-3
swagger.yml
.../community-detection-microservice/app/configs/swagger.yml
+28
-2
agi_repository.py
...unity-detection-microservice/app/db/agi/agi_repository.py
+49
-0
travels.json
.../community-detection-microservice/app/db/agi/travels.json
+26958
-0
main.py
src/data-hub/community-detection-microservice/app/main.py
+1
-1
agi_cluster.py
.../community-detection-microservice/app/rest/agi_cluster.py
+24
-0
No files found.
src/data-hub/community-detection-microservice/app/configs/swagger.yml
View file @
0839a52c
...
...
@@ -72,7 +72,7 @@ paths:
schema
:
$ref
:
"
#/definitions/Cluster"
/cluster.png
:
/cluster
/cluster
.png
:
get
:
operationId
:
"
rest.cluster.get_image"
tags
:
...
...
@@ -86,6 +86,32 @@ paths:
description
:
"
Successful
operation"
/agi/cluster
:
get
:
operationId
:
"
rest.agi_cluster.get"
tags
:
-
"
Clusters"
summary
:
"
Get
clustered
data"
parameters
:
[]
responses
:
200
:
description
:
"
Successful
operation"
schema
:
$ref
:
"
#/definitions/Cluster"
/agi/cluster/cluster.png
:
get
:
operationId
:
"
rest.agi_cluster.get_image"
tags
:
-
"
Clusters"
summary
:
"
Get
clustered
data
as
image"
parameters
:
[]
produces
:
-
"
image/png"
responses
:
200
:
description
:
"
Successful
operation"
definitions
:
Location
:
type
:
"
object"
...
...
src/data-hub/community-detection-microservice/app/db/agi/agi_repository.py
0 → 100644
View file @
0839a52c
import
json
from
typing
import
List
,
Dict
class
AgiRepository
:
def
getLocations
(
self
)
->
List
:
locations
=
[]
travels
=
self
.
readDataFromFile
()
# only take started travels
travels
=
[
t
for
t
in
travels
if
t
[
'status'
]
>=
2
]
for
travel
in
travels
:
locations
.
append
(
self
.
location
(
travel
[
"id"
],
travel
[
'startPlace.latitude'
],
travel
[
'startPlace.longitude'
],
0
,
''
))
continue
# todo work on locations
# todo number of complete travels with startlocation and user data
num_complete_travels
=
min
(
len
(
travel
[
'startedBy'
]),
len
(
travel
[
'users'
]))
for
i
in
range
(
num_complete_travels
):
cur_location
=
travel
[
'startedBy'
][
i
]
cur_user
=
travel
[
'users'
][
i
]
locations
.
append
(
self
.
location
(
f
'{travel["id"]}-{cur_location["moment"]}'
,
cur_location
[
'coordinate'
][
'latitude'
],
cur_location
[
'coordinate'
][
'longitude'
],
cur_location
[
'moment'
],
# todo user in travel startedBy not available from dataset - currently using user list
cur_user
[
'userId'
]
))
return
locations
def
readDataFromFile
(
self
)
->
List
[
Dict
]:
with
open
(
'./db/agi/travels.json'
,
'r'
)
as
f_travels
:
travels
=
json
.
loads
(
f_travels
.
read
())
return
travels
def
location
(
self
,
id_
,
lat
,
long_
,
timestamp
,
username
)
->
dict
:
return
{
"id"
:
id_
,
'latitude'
:
lat
,
'longitude'
:
long_
,
"timestamp"
:
timestamp
,
"username"
:
username
}
src/data-hub/community-detection-microservice/app/db/agi/travels.json
0 → 100644
View file @
0839a52c
This diff is collapsed.
Click to expand it.
src/data-hub/community-detection-microservice/app/main.py
View file @
0839a52c
...
...
@@ -17,4 +17,4 @@ def api_root():
# start app
if
__name__
==
'__main__'
:
app
.
run
(
host
=
'0.0.0.0'
,
port
=
5000
,
debug
=
True
,
use_reloader
=
True
)
app
.
run
(
host
=
'0.0.0.0'
,
port
=
5000
,
debug
=
True
)
src/data-hub/community-detection-microservice/app/rest/agi_cluster.py
0 → 100644
View file @
0839a52c
import
io
from
flask
import
request
,
Response
from
db.agi.agi_repository
import
AgiRepository
from
processing.clusterer
import
Clusterer
from
matplotlib.backends.backend_agg
import
FigureCanvasAgg
as
FigureCanvas
repo
=
AgiRepository
()
clusterer
=
Clusterer
()
def
get
():
locations
=
repo
.
getLocations
()
clusters
=
clusterer
.
run
(
locations
)
return
clusters
def
get_image
():
locations
=
repo
.
getLocations
()
fig
=
clusterer
.
draw_locations
(
locations
)
output
=
io
.
BytesIO
()
FigureCanvas
(
fig
)
.
print_png
(
output
)
return
Response
(
output
.
getvalue
(),
mimetype
=
"image/png"
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment