Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
theodolite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sören Henning
theodolite
Commits
3ed70c99
Commit
3ed70c99
authored
3 years ago
by
Sören Henning
Browse files
Options
Downloads
Patches
Plain Diff
Minor code cleanup
parent
20d0ba05
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!190
Update demant-metric notebooks in order to run with the new implementation
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
analysis/src/demand.py
+3
-8
3 additions, 8 deletions
analysis/src/demand.py
with
3 additions
and
8 deletions
analysis/src/demand.py
+
3
−
8
View file @
3ed70c99
...
...
@@ -7,10 +7,9 @@ from sklearn.linear_model import LinearRegression
def
demand
(
exp_id
,
directory
,
threshold
,
warmup_sec
):
raw_runs
=
[]
# Compute SL, i.e., lag trend, for each tested configuration
# Compute SL
I
, i.e., lag trend, for each tested configuration
filenames
=
[
filename
for
filename
in
os
.
listdir
(
directory
)
if
filename
.
startswith
(
f
"
exp
{
exp_id
}
"
)
and
"
lag-trend
"
in
filename
and
filename
.
endswith
(
"
.csv
"
)]
for
filename
in
filenames
:
#print(filename)
run_params
=
filename
[:
-
4
].
split
(
"
_
"
)
dim_value
=
run_params
[
1
]
instances
=
run_params
[
2
]
...
...
@@ -30,24 +29,20 @@ def demand(exp_id, directory, threshold, warmup_sec):
Y_pred
=
linear_regressor
.
predict
(
X
)
# make predictions
trend_slope
=
linear_regressor
.
coef_
[
0
][
0
]
#print(linear_regressor.coef_)
row
=
{
'
load
'
:
int
(
dim_value
),
'
resources
'
:
int
(
instances
),
'
trend_slope
'
:
trend_slope
}
#print(row)
raw_runs
.
append
(
row
)
runs
=
pd
.
DataFrame
(
raw_runs
)
# Group by the load and resources to handle repetitions, and take from the reptitions the median
# for even reptitions
the
the
average
of the two middle values is used
# for even reptitions
,
the
mean
of the two middle values is used
medians
=
runs
.
groupby
(
by
=
[
'
load
'
,
'
resources
'
],
as_index
=
False
).
median
()
# Set suitable = True if SLOs are met, i.e., lag trend is below threshold_ratio
# Calculate the absolute threshold for each row based on threshold_ratio and check if lag is below this threshold
# Set suitable = True if SLOs are met, i.e., lag trend slope is below threshold
medians
[
"
suitable
"
]
=
medians
.
apply
(
lambda
row
:
row
[
'
trend_slope
'
]
<
threshold
,
axis
=
1
)
suitable
=
medians
[
medians
.
apply
(
lambda
x
:
x
[
'
suitable
'
],
axis
=
1
)]
#print(suitable)
# Compute minimal demand per load intensity
demand_per_load
=
suitable
.
groupby
(
by
=
[
'
load
'
],
as_index
=
False
)[
'
resources
'
].
min
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment