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
1ba72d41
Commit
1ba72d41
authored
Aug 02, 2021
by
Alexander Lercher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Regression prediction
parent
b5ab2b36
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
3 deletions
+9
-3
repository.py
...ive-community-detection-microservice/app/db/repository.py
+4
-0
predict_cross_context.py
...n-microservice/app/processing/ml/predict_cross_context.py
+2
-1
predict_single_context.py
...-microservice/app/processing/ml/predict_single_context.py
+2
-1
predictions.py
...ommunity-detection-microservice/app/routes/predictions.py
+1
-1
No files found.
src/data-hub/proactive-community-detection-microservice/app/db/repository.py
View file @
1ba72d41
...
@@ -132,6 +132,10 @@ class Repository(MongoRepositoryBase):
...
@@ -132,6 +132,10 @@ class Repository(MongoRepositoryBase):
entries
=
super
()
.
get_entries
(
self
.
_prediction_result_collection
,
selection
=
{
'use_case'
:
use_case
},
projection
=
{
'_id'
:
0
})
entries
=
super
()
.
get_entries
(
self
.
_prediction_result_collection
,
selection
=
{
'use_case'
:
use_case
},
projection
=
{
'_id'
:
0
})
return
[
PredictionResult
.
create_from_dict
(
e
)
for
e
in
entries
]
return
[
PredictionResult
.
create_from_dict
(
e
)
for
e
in
entries
]
def
get_prediction_results_for_layer
(
self
,
use_case
:
str
,
use_case_table
:
str
,
layer_name
:
str
)
->
List
[
PredictionResult
]:
entries
=
super
()
.
get_entries
(
self
.
_prediction_result_collection
,
selection
=
{
'use_case'
:
use_case
,
'table'
:
use_case_table
,
'layer'
:
layer_name
},
projection
=
{
'_id'
:
0
})
return
[
PredictionResult
.
create_from_dict
(
e
)
for
e
in
entries
]
def
delete_all_prediction_results
(
self
):
def
delete_all_prediction_results
(
self
):
super
()
.
drop_collection
(
self
.
_prediction_result_collection
)
super
()
.
drop_collection
(
self
.
_prediction_result_collection
)
#endregion
#endregion
src/data-hub/proactive-community-detection-microservice/app/processing/ml/predict_cross_context.py
View file @
1ba72d41
...
@@ -91,7 +91,8 @@ def run_prediction(use_case: str):
...
@@ -91,7 +91,8 @@ def run_prediction(use_case: str):
prediction_metrics
.
append
(
flat_
)
prediction_metrics
.
append
(
flat_
)
prediction_results
=
svc
.
predict
(
scaler
.
transform
(
np
.
array
(
prediction_metrics
)))
prediction_results
=
svc
.
predict
(
scaler
.
transform
(
np
.
array
(
prediction_metrics
)))
print
(
np
.
unique
(
prediction_results
,
return_counts
=
True
))
# print(np.unique(prediction_results, return_counts=True))
prediction_results
=
np
.
rint
(
prediction_results
)
# round to full numbers
for
i
in
range
(
len
(
prediction_cluster_ids
)):
for
i
in
range
(
len
(
prediction_cluster_ids
)):
res
=
PredictionResult
(
use_case
,
use_case
,
method
,
layer_name
,
reference_layer_name
,
prediction_cluster_ids
[
i
],
prediction_time_window
,
prediction_results
[
i
])
res
=
PredictionResult
(
use_case
,
use_case
,
method
,
layer_name
,
reference_layer_name
,
prediction_cluster_ids
[
i
],
prediction_time_window
,
prediction_results
[
i
])
...
...
src/data-hub/proactive-community-detection-microservice/app/processing/ml/predict_single_context.py
View file @
1ba72d41
...
@@ -74,7 +74,8 @@ def run_prediction(use_case: str):
...
@@ -74,7 +74,8 @@ def run_prediction(use_case: str):
# predict all at once for speedup
# predict all at once for speedup
prediction_results
=
svc
.
predict
(
scaler
.
transform
(
np
.
array
(
prediction_metrics
)))
prediction_results
=
svc
.
predict
(
scaler
.
transform
(
np
.
array
(
prediction_metrics
)))
print
(
np
.
unique
(
prediction_results
,
return_counts
=
True
))
# print(np.unique(prediction_results, return_counts=True))
prediction_results
=
np
.
rint
(
prediction_results
)
# round to full numbers
for
i
in
range
(
len
(
prediction_cluster_ids
)):
for
i
in
range
(
len
(
prediction_cluster_ids
)):
res
=
PredictionResult
(
use_case
,
use_case
,
method
,
layer_name
,
None
,
prediction_cluster_ids
[
i
],
prediction_time_windows
[
i
],
prediction_results
[
i
])
res
=
PredictionResult
(
use_case
,
use_case
,
method
,
layer_name
,
None
,
prediction_cluster_ids
[
i
],
prediction_time_windows
[
i
],
prediction_results
[
i
])
...
...
src/data-hub/proactive-community-detection-microservice/app/routes/predictions.py
View file @
1ba72d41
...
@@ -5,7 +5,7 @@ from db.dao import PredictionResult
...
@@ -5,7 +5,7 @@ from db.dao import PredictionResult
repo
=
Repository
()
repo
=
Repository
()
def
get
(
use_case
,
table
,
layer_name
):
def
get
(
use_case
,
table
,
layer_name
):
res
=
repo
.
get_prediction_results
(
use_cas
e
)
res
=
repo
.
get_prediction_results
_for_layer
(
use_case
,
table
,
layer_nam
e
)
if
res
is
None
or
len
(
res
)
==
0
:
if
res
is
None
or
len
(
res
)
==
0
:
return
Response
(
status
=
404
)
return
Response
(
status
=
404
)
else
:
else
:
...
...
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