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
fe2835b5
Commit
fe2835b5
authored
Jan 24, 2020
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/cluster-name-infos' into develop
parents
76a41124
a6213463
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
15 deletions
+25
-15
swagger.yml
.../community-detection-microservice/app/configs/swagger.yml
+15
-5
agi_repository.py
...unity-detection-microservice/app/db/agi/agi_repository.py
+4
-7
clusterer.py
...munity-detection-microservice/app/processing/clusterer.py
+6
-3
debug.py
...ta-hub/community-detection-microservice/app/rest/debug.py
+0
-0
No files found.
src/data-hub/community-detection-microservice/app/configs/swagger.yml
View file @
fe2835b5
...
@@ -14,7 +14,7 @@ basePath: "/api"
...
@@ -14,7 +14,7 @@ basePath: "/api"
paths
:
paths
:
/debug
:
/debug
:
post
:
post
:
operationId
:
"
debug.echo"
operationId
:
"
rest.
debug.echo"
tags
:
tags
:
-
"
Echo"
-
"
Echo"
summary
:
"
Echo
function
for
debugging
purposes"
summary
:
"
Echo
function
for
debugging
purposes"
...
@@ -70,7 +70,7 @@ paths:
...
@@ -70,7 +70,7 @@ paths:
200
:
200
:
description
:
"
Successful
operation"
description
:
"
Successful
operation"
schema
:
schema
:
$ref
:
"
#/definitions/Cluster"
$ref
:
"
#/definitions/Cluster
Value
"
/cluster/cluster.png
:
/cluster/cluster.png
:
get
:
get
:
...
@@ -97,7 +97,7 @@ paths:
...
@@ -97,7 +97,7 @@ paths:
200
:
200
:
description
:
"
Successful
operation"
description
:
"
Successful
operation"
schema
:
schema
:
$ref
:
"
#/definitions/Cluster"
$ref
:
"
#/definitions/Cluster
Value
"
/agi/cluster/cluster.png
:
/agi/cluster/cluster.png
:
get
:
get
:
...
@@ -119,7 +119,7 @@ definitions:
...
@@ -119,7 +119,7 @@ definitions:
id
:
id
:
type
:
string
type
:
string
format
:
uuid
format
:
uuid
user
name
:
user
:
type
:
"
string"
type
:
"
string"
latitude
:
latitude
:
type
:
"
number"
type
:
"
number"
...
@@ -127,10 +127,20 @@ definitions:
...
@@ -127,10 +127,20 @@ definitions:
type
:
"
number"
type
:
"
number"
timestamp
:
timestamp
:
type
:
"
number"
type
:
"
number"
Cluster
:
Cluster
Value
:
type
:
"
object"
type
:
"
object"
properties
:
properties
:
id
:
id
:
type
:
string
type
:
string
format
:
uuid
format
:
uuid
cluster_label
:
type
:
number
latitude
:
type
:
number
longitude
:
type
:
number
timestamp
:
type
:
number
user
:
type
:
string
\ No newline at end of file
src/data-hub/community-detection-microservice/app/db/agi/agi_repository.py
View file @
fe2835b5
import
json
import
json
from
typing
import
List
,
Dict
from
typing
import
List
,
Dict
import
hashlib
class
AgiRepository
:
class
AgiRepository
:
def
getLocations
(
self
)
->
List
:
def
getLocations
(
self
)
->
List
:
...
@@ -12,22 +12,19 @@ class AgiRepository:
...
@@ -12,22 +12,19 @@ class AgiRepository:
travels
=
[
t
for
t
in
travels
if
t
[
'status'
]
>=
2
]
travels
=
[
t
for
t
in
travels
if
t
[
'status'
]
>=
2
]
for
travel
in
travels
:
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'
]))
num_complete_travels
=
min
(
len
(
travel
[
'startedBy'
]),
len
(
travel
[
'users'
]))
for
i
in
range
(
num_complete_travels
):
for
i
in
range
(
num_complete_travels
):
cur_location
=
travel
[
'startedBy'
][
i
]
cur_location
=
travel
[
'startedBy'
][
i
]
cur_user
=
travel
[
'users'
][
i
]
cur_user
=
travel
[
'users'
][
i
]
locations
.
append
(
locations
.
append
(
self
.
location
(
f
'{travel["id"]}-{cur_location["moment"]}'
,
self
.
location
(
f
'{travel["id"]}-{cur_location["moment"]}'
,
cur_location
[
'coordinate'
][
'latitude'
],
cur_location
[
'coordinate'
][
'latitude'
],
cur_location
[
'coordinate'
][
'longitude'
],
cur_location
[
'coordinate'
][
'longitude'
],
cur_location
[
'moment'
],
cur_location
[
'moment'
],
# todo user in travel startedBy not available from dataset - currently using user list
# todo user in travel startedBy not available from dataset - currently using user list
cur_user
[
'userId'
]
hashlib
.
sha1
(
cur_user
[
'userId'
]
.
encode
())
.
hexdigest
()
# not showing generated username
))
))
return
locations
return
locations
...
@@ -44,6 +41,6 @@ class AgiRepository:
...
@@ -44,6 +41,6 @@ class AgiRepository:
'latitude'
:
lat
,
'latitude'
:
lat
,
'longitude'
:
long_
,
'longitude'
:
long_
,
"timestamp"
:
timestamp
,
"timestamp"
:
timestamp
,
"user
name
"
:
username
"user"
:
username
}
}
src/data-hub/community-detection-microservice/app/processing/clusterer.py
View file @
fe2835b5
...
@@ -17,7 +17,7 @@ class Clusterer:
...
@@ -17,7 +17,7 @@ class Clusterer:
labels
=
self
.
create_labels
(
locations
)
labels
=
self
.
create_labels
(
locations
)
return
self
.
_draw_locations
(
return
self
.
_draw_locations
(
locations
=
np
.
asarray
([(
l
[
'latitude'
],
l
[
'longitude'
])
for
l
in
locations
]
),
locations
=
self
.
extract_location_data
(
locations
),
partition_info
=
labels
partition_info
=
labels
)
)
...
@@ -47,7 +47,7 @@ class Clusterer:
...
@@ -47,7 +47,7 @@ class Clusterer:
if
locations
is
None
or
len
(
locations
)
==
0
:
if
locations
is
None
or
len
(
locations
)
==
0
:
return
locations
# trash in trash out
return
locations
# trash in trash out
locations
=
np
.
asarray
([(
l
[
'latitude'
],
l
[
'longitude'
])
for
l
in
locations
]
)
locations
=
self
.
extract_location_data
(
locations
)
dbsc
=
DBSCAN
(
eps
=
self
.
epsilon
,
min_samples
=
self
.
min_points
)
dbsc
=
DBSCAN
(
eps
=
self
.
epsilon
,
min_samples
=
self
.
min_points
)
dbsc
=
dbsc
.
fit
(
locations
)
dbsc
=
dbsc
.
fit
(
locations
)
...
@@ -78,3 +78,6 @@ class Clusterer:
...
@@ -78,3 +78,6 @@ class Clusterer:
clusters
[
label
]
=
[
l
for
l
in
locations
if
l
[
'cluster_label'
]
==
label
]
clusters
[
label
]
=
[
l
for
l
in
locations
if
l
[
'cluster_label'
]
==
label
]
return
clusters
return
clusters
def
extract_location_data
(
self
,
locations
:
List
[
dict
])
->
np
.
ndarray
:
return
np
.
asarray
([(
float
(
l
[
'latitude'
]),
float
(
l
[
'longitude'
]))
for
l
in
locations
])
\ No newline at end of file
src/data-hub/community-detection-microservice/app/debug.py
→
src/data-hub/community-detection-microservice/app/
rest/
debug.py
View file @
fe2835b5
File moved
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