Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ECCCo-jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Patrick Altmeyer
ECCCo-jl
Commits
b674b4a1
Commit
b674b4a1
authored
1 year ago
by
pat-alt
Browse files
Options
Downloads
Patches
Plain Diff
rejigged grid search a little
parent
d478bcca
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!89
85 overshooting
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
experiments/grid_search.jl
+19
-8
19 additions, 8 deletions
experiments/grid_search.jl
with
19 additions
and
8 deletions
experiments/grid_search.jl
+
19
−
8
View file @
b674b4a1
using
DataFrames
"""
grid_search(
couterfactual_data::CounterfactualData,
...
...
@@ -24,7 +26,8 @@ function grid_search(
# Grid setup:
tuning_params
=
[
Pair
.
(
k
,
vals
)
for
(
k
,
vals
)
in
pairs
(
tuning_params
)]
grid
=
Iterators
.
product
(
tuning_params
...
)
outcomes
=
Dict
{
Any
,
Any
}()
df_params
=
[]
df_outcomes
=
[]
# Search:
counter
=
1
...
...
@@ -40,10 +43,18 @@ function grid_search(
tuning_params
...
,
kwargs
...
,
)
outcomes
[
tuning_params
]
=
outcome
_df_params
=
DataFrame
(
Dict
(
:
id
=>
counter
,
pairs
(
tuning_params
)))
_df_outcomes
=
DataFrame
(
Dict
(
:
id
=>
counter
,
:
params
=>
tuning_params
,
:
outcome
=>
outcome
))
push!
(
df_params
,
_df_params
)
push!
(
df_outcomes
,
_df_outcomes
)
counter
+=
1
end
outcomes
=
Dict
(
:
df_params
=>
vcat
(
df_params
...
),
:
df_outcomes
=>
vcat
(
df_outcomes
...
),
)
# Save:
if
!
(
is_multi_processed
(
PLZ
)
&&
MPI
.
Comm_rank
(
PLZ
.
comm
)
!=
0
)
Serialization
.
serialize
(
...
...
@@ -104,7 +115,7 @@ function best_rank_outcome(
df_weights
=
DataFrame
(
variable
=
measure
,
weight
=
weights
)
ranks
=
[]
for
(
params
,
outcome
)
in
outcomes
for
outcome
in
outcomes
.
df_outcomes
.
outcome
_ranks
=
generator_rank
(
outcome
;
...
...
@@ -119,8 +130,8 @@ function best_rank_outcome(
end
best_index
=
argmin
(
ranks
)
best_outcome
=
(
params
=
collect
(
keys
(
outcomes
))
[
best_index
],
outcome
=
collect
(
valu
es
(
outcomes
))
[
best_index
],
params
=
outcomes
.
df_
outcomes
.
params
[
best_index
],
outcome
=
outcomes
.
df_outcom
es
.
outcomes
[
best_index
],
)
return
best_outcome
end
...
...
@@ -148,7 +159,7 @@ function best_absolute_outcome(
df_weights
=
DataFrame
(
variable
=
measure
,
weight
=
weights
)
avg_values
=
[]
for
(
params
,
outcome
)
in
outcomes
for
(
params
,
outcome
)
in
(
outcomes
.
df_outcomes
.
params
,
outcomes
.
df_outcomes
.
outcome
)
# Setup
evaluation
=
deepcopy
(
outcome
.
bmk
.
evaluation
)
...
...
@@ -191,8 +202,8 @@ function best_absolute_outcome(
end
best_index
=
argmin
(
avg_values
)
best_outcome
=
(
params
=
collect
(
keys
(
outcomes
))
[
best_index
],
outcome
=
collect
(
valu
es
(
outcomes
))
[
best_index
],
params
=
outcomes
.
df_
outcomes
.
params
[
best_index
],
outcome
=
outcomes
.
df_outcom
es
.
outcomes
[
best_index
],
)
end
...
...
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