Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bolsonaro
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
Container registry
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
Luc Giffon
bolsonaro
Merge requests
!5
Resolve "Add plots"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Add plots"
5-add-plots-2
into
wip_clean_scripts
Overview
0
Commits
3
Pipelines
0
Changes
5
Merged
Leo Bouscarrat
requested to merge
5-add-plots-2
into
wip_clean_scripts
5 years ago
Overview
0
Commits
3
Pipelines
0
Changes
5
Expand
Closes
#5 (closed)
Edited
5 years ago
by
Charly Lamothe
0
0
Merge request reports
Compare
wip_clean_scripts
version 1
553764d7
5 years ago
wip_clean_scripts (base)
and
latest version
latest version
eefd7b6b
3 commits,
5 years ago
version 1
553764d7
2 commits,
5 years ago
5 files
+
37
−
14
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
Search (e.g. *.vue) (Ctrl+P)
code/bolsonaro/visualization/plotter.py
+
16
−
13
Options
import
matplotlib.pyplot
as
plt
import
numpy
as
np
from
sklearn.neighbors.kde
import
KernelDensity
import
pandas
as
pd
class
Plotter
(
object
):
@staticmethod
def
weight_density
(
weights
,
X
,
file_path
):
X_plot
=
[
np
.
exp
(
elem
)
for
elem
in
weights
]
fig
,
ax
=
plt
.
subplots
()
def
weight_density
(
all_experiment_weights
,
file_path
):
'''
Function that creates the figure with the density of the weights
:param all_experiment_weights: The weights for the different experiments
:param file path: str, path where the figure will be saved
'''
for
kernel
in
[
'
gaussian
'
,
'
tophat
'
,
'
epanechnikov
'
]:
kde
=
KernelDensity
(
kernel
=
kernel
,
bandwidth
=
0.5
).
fit
(
X_plot
)
log_dens
=
kde
.
score_samples
(
X_plot
)
ax
.
plot
(
X_plot
,
np
.
exp
(
log_dens
),
'
-
'
,
label
=
"
kernel =
'
{0}
'"
.
format
(
kernel
))
all_experiment_weights
=
np
.
array
(
list
(
all_experiment_weights
.
values
()))
n
=
len
(
all_experiment_weights
)
colors
=
Plotter
.
get_colors_from_cmap
(
n
)
ax
.
legend
(
loc
=
'
upper left
'
)
ax
.
plot
(
X
[:,
0
],
-
0.005
-
0.01
*
np
.
random
.
random
(
X
.
shape
[
0
]),
'
+k
'
)
fig
,
ax
=
plt
.
subplots
()
for
i
in
range
(
n
):
for
weights
in
all_experiment_weights
[
i
]:
pd
.
Series
([
weight
for
weight
in
weights
if
weight
!=
0
]).
plot
.
kde
(
figsize
=
(
15
,
10
),
ax
=
ax
,
color
=
colors
[
i
])
ax
.
set_xlim
(
-
4
,
9
)
ax
.
set_ylim
(
-
0.02
,
0.4
)
ax
.
set_title
(
'
Density weights of the OMP
'
)
fig
.
savefig
(
file_path
,
dpi
=
fig
.
dpi
)
plt
.
close
(
fig
)
Loading