Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BayesianOptimization
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
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
shamith2
BayesianOptimization
Commits
c054494e
Unverified
Commit
c054494e
authored
5 years ago
by
Shamith Achanta
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Update plotter.py
parent
f8d2665c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fmfnBO/bayes_opt/plotter.py
+19
-15
19 additions, 15 deletions
fmfnBO/bayes_opt/plotter.py
with
19 additions
and
15 deletions
fmfnBO/bayes_opt/plotter.py
+
19
−
15
View file @
c054494e
import
os
import
sys
import
json
from
matplotlib
import
pyplot
as
my_plt
from
matplotlib
import
patches
as
my_patch
...
...
@@ -7,32 +6,32 @@ import pandas as pd
import
numpy
as
np
class
JSONPlotter
():
def
__init__
(
self
,
file
name
,
re
name
,
f
):
def
__init__
(
self
,
log_
name
,
plot_
name
,
f
unc
,
x_eval
=
True
):
try
:
os
.
remove
(
re
name
)
os
.
remove
(
plot_
name
)
except
OSError
:
pass
self
.
change
(
file
name
,
re
name
)
self
.
plot
(
re
name
,
f
)
self
.
change
(
log_
name
,
plot_
name
)
self
.
plot
(
plot_
name
,
f
unc
,
x_eval
)
self
.
lines
=
[]
def
change
(
self
,
file
name
,
re
name
):
with
open
(
file
name
,
"
r
"
)
as
f
:
def
change
(
self
,
log_
name
,
plot_
name
):
with
open
(
log_
name
,
"
r
"
)
as
f
:
file_data
=
f
.
read
()
with
open
(
file
name
,
"
r
"
)
as
f
:
with
open
(
log_
name
,
"
r
"
)
as
f
:
self
.
lines
=
f
.
readlines
()
first_line
=
self
.
lines
[
0
]
file_lines
=
[
''
.
join
([
'
,
'
,
line
.
strip
(),
'
\n
'
])
for
line
in
self
.
lines
[
1
:]]
with
open
(
re
name
,
"
w+
"
)
as
f
:
with
open
(
plot_
name
,
"
w+
"
)
as
f
:
f
.
write
(
'
{
'
+
'
\n
'
+
'
'
+
'"
logs
"'
+
'
:
'
+
'
'
+
'
[
'
+
'
\n
'
)
f
.
writelines
(
first_line
)
f
.
writelines
(
file_lines
)
f
.
write
(
"
"
+
"
]
"
+
"
\n
"
+
"
}
"
)
def
plot
(
self
,
re
name
,
f
):
with
open
(
re
name
)
as
json_file
:
def
plot
(
self
,
plot_
name
,
f
unc
,
x_eval
=
True
):
with
open
(
plot_
name
)
as
json_file
:
data
=
pd
.
DataFrame
(
json
.
load
(
json_file
)[
'
logs
'
])
_x
=
data
[
'
params
'
].
to_list
()
...
...
@@ -42,14 +41,19 @@ class JSONPlotter():
for
i
in
range
(
dim
):
x_list
[
i
].
append
(
tuple
(
x_
.
values
())[
i
])
x
_eval
=
np
.
arange
(
1
,
len
(
self
.
lines
)
+
1
,
1
)
n
_eval
=
np
.
arange
(
1
,
len
(
self
.
lines
)
+
1
,
1
)
y
=
data
[
'
target
'
].
to_numpy
()
if
x_eval
:
x
=
n_eval
else
:
x
=
x_list
[
0
]
my_plt
.
figure
(
'
FmFnBO
'
)
my_plt
.
title
(
"
function = {} :: evaluations = {}
"
.
format
(
f
,
len
(
self
.
lines
)))
my_plt
.
title
(
"
function = {} :: evaluations = {}
"
.
format
(
f
unc
,
len
(
self
.
lines
)))
blue
=
my_patch
.
Patch
(
color
=
'
blue
'
,
label
=
'
fmfn
'
)
my_plt
.
legend
(
handles
=
[
blue
])
my_plt
.
plot
(
x
_list
[
0
]
,
y
,
'
b
'
)
my_plt
.
plot
(
x
,
y
,
'
b
'
)
my_plt
.
show
()
\ No newline at end of file
my_plt
.
show
()
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