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
8287b767
Commit
8287b767
authored
Feb 07, 2020
by
Alexander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storing location and time clusters independently
parent
c94aba76
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
10 deletions
+19
-10
repository.py
...hub/community-detection-microservice/app/db/repository.py
+14
-6
agi_cluster.py
.../community-detection-microservice/app/rest/agi_cluster.py
+1
-1
cluster.py
...-hub/community-detection-microservice/app/rest/cluster.py
+1
-1
run_clustering.py
...ub/community-detection-microservice/app/run_clustering.py
+3
-2
No files found.
src/data-hub/community-detection-microservice/app/db/repository.py
View file @
8287b767
...
...
@@ -16,7 +16,8 @@ class Repository(MongoRepositoryBase):
netconst
.
COMMUNITY_DETECTION_DB_PORT
,
'communityDetectionDb'
)
self
.
_location_collection
=
'location_agi'
if
agi_data
else
'location'
self
.
_cluster_collection
=
'cluster_agi'
if
agi_data
else
'cluster'
self
.
_location_cluster_collection
=
'location_cluster_agi'
if
agi_data
else
'location_cluster'
self
.
_time_cluster_collection
=
'time_cluster_agi'
if
agi_data
else
'time_cluster'
self
.
agi_repo
=
AgiRepository
()
...
...
@@ -31,12 +32,19 @@ class Repository(MongoRepositoryBase):
agi_locations
=
self
.
agi_repo
.
getLocations
()
return
[
Location
(
agi_loc
)
for
agi_loc
in
agi_locations
]
def
add_
user
_cluster
(
self
,
cluster
:
UserCluster
):
super
()
.
insert_entry
(
self
.
_cluster_collection
,
cluster
.
to_serializable_dict
(
for_db
=
True
))
def
add_
location
_cluster
(
self
,
cluster
:
UserCluster
):
super
()
.
insert_entry
(
self
.
_
location_
cluster_collection
,
cluster
.
to_serializable_dict
(
for_db
=
True
))
def
get_user_clusters
(
self
)
->
List
[
UserCluster
]:
clusters
=
super
()
.
get_entries
(
self
.
_cluster_collection
)
return
[
UserCluster
(
c
[
'date'
],
int
(
c
[
'hour'
]),
json
.
loads
(
c
[
'clusters'
]))
for
c
in
clusters
]
def
get_location_clusters
(
self
)
->
List
[
UserCluster
]:
clusters
=
super
()
.
get_entries
(
self
.
_location_cluster_collection
)
return
[
UserCluster
(
c
[
'cluster_label'
],
json
.
loads
(
c
[
'clusters'
]))
for
c
in
clusters
]
def
add_time_cluster
(
self
,
cluster
:
UserCluster
):
super
()
.
insert_entry
(
self
.
_time_cluster_collection
,
cluster
.
to_serializable_dict
(
for_db
=
True
))
def
get_time_clusters
(
self
)
->
List
[
UserCluster
]:
clusters
=
super
()
.
get_entries
(
self
.
_time_cluster_collection
)
return
[
UserCluster
(
c
[
'cluster_label'
],
json
.
loads
(
c
[
'clusters'
]))
for
c
in
clusters
]
def
add_popular_location
(
self
,
popular_location
:
PopularLocation
):
pass
src/data-hub/community-detection-microservice/app/rest/agi_cluster.py
View file @
8287b767
...
...
@@ -8,7 +8,7 @@ repo = Repository(agi_data=True)
clusterer
=
Clusterer
()
def
get
():
clusters
=
repo
.
get_
user
_clusters
()
clusters
=
repo
.
get_
location
_clusters
()
return
[
c
.
to_serializable_dict
()
for
c
in
clusters
]
def
get_image
():
...
...
src/data-hub/community-detection-microservice/app/rest/cluster.py
View file @
8287b767
...
...
@@ -8,7 +8,7 @@ repo = Repository()
clusterer
=
Clusterer
()
def
get
():
clusters
=
repo
.
get_
user
_clusters
()
clusters
=
repo
.
get_
location
_clusters
()
return
[
c
.
to_serializable_dict
()
for
c
in
clusters
]
def
get_image
():
...
...
src/data-hub/community-detection-microservice/app/run_clustering.py
View file @
8287b767
...
...
@@ -39,7 +39,8 @@ def run_time_clustering():
clusters
=
[
UserCluster
(
key
,
value
)
for
key
,
value
in
cluster_result
.
items
()]
store_user_clusters
(
clusters
)
for
c
in
clusters
:
repo
.
add_time_cluster
(
c
)
def
store_user_clusters
(
user_clusters
:
List
[
UserCluster
]):
...
...
@@ -48,7 +49,7 @@ def store_user_clusters(user_clusters: List[UserCluster]):
return
for
c
in
user_clusters
:
repo
.
add_
user
_cluster
(
c
)
repo
.
add_
location
_cluster
(
c
)
if
__name__
==
"__main__"
:
...
...
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