Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wela
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Swain Lab
wela
Commits
0f680a6e
Commit
0f680a6e
authored
4 months ago
by
pswain
Browse files
Options
Downloads
Patches
Plain Diff
change(plot_binned): variables renamed for clarity
parent
b3ddc43d
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
src/wela/plotting.py
+10
-9
10 additions, 9 deletions
src/wela/plotting.py
with
10 additions
and
9 deletions
src/wela/plotting.py
+
10
−
9
View file @
0f680a6e
...
...
@@ -767,7 +767,7 @@ def plot_binned(
df
,
x_signal
,
y_signal
,
statistic
,
y_
statistic
,
bins
=
10
,
equal_bins
=
False
,
groups
=
None
,
...
...
@@ -798,7 +798,7 @@ def plot_binned(
Name of the signal to bin and plot on the x-axis.
y_signal: str
Name of the signal from which the statistic will be calculated.
statistic: function
y_
statistic: function
Statistic to calculate for y_signal for cells in bins of x_signal.
bins: int, List[float]
Number of bins.
...
...
@@ -841,11 +841,11 @@ def plot_binned(
if
x_signal
==
y_signal
:
sdf
=
df
[
df
.
group
==
group
][[
x_signal
]].
dropna
()
x
=
sdf
[
x_signal
].
values
values
=
x
y_
values
=
x
else
:
sdf
=
df
[
df
.
group
==
group
][[
x_signal
,
y_signal
]].
dropna
()
x
=
sdf
[
x_signal
].
values
values
=
sdf
[
y_signal
].
values
y_
values
=
sdf
[
y_signal
].
values
if
isinstance
(
bins
,
int
)
and
equal_bins
:
_
,
bin_edges
=
pd
.
qcut
(
x
,
bins
,
retbins
=
True
,
duplicates
=
"
drop
"
)
bs_bins
=
bin_edges
...
...
@@ -853,8 +853,8 @@ def plot_binned(
bs_bins
=
bins
res
[
f
"
stat_
{
group
}
"
],
bin_edges
,
bin_nos
=
binned_statistic
(
x
,
values
,
statistic
=
statistic
,
y_
values
,
statistic
=
y_
statistic
,
bins
=
bs_bins
,
)
res
[
f
"
bin_midpoints_
{
group
}
"
]
=
np
.
array
(
...
...
@@ -865,15 +865,16 @@ def plot_binned(
)
res
[
f
"
bin_size_
{
group
}
"
]
=
np
.
array
(
[
values
[
bin_nos
==
bin_no
].
size
y_
values
[
bin_nos
==
bin_no
].
size
for
bin_no
in
np
.
arange
(
1
,
bin_edges
.
size
)
]
)
res
[
f
"
bin_edges_
{
group
}
"
]
=
bin_edges
# estimate errors
print
(
group
)
err
=
[]
for
bin_no
in
np
.
arange
(
1
,
bin_edges
.
size
):
data
=
values
[
bin_nos
==
bin_no
]
data
=
y_
values
[
bin_nos
==
bin_no
]
if
data
.
size
>
1
:
print
(
f
"
Bin
{
bin_no
}
: bootstrapping with
{
data
.
size
}
data points.
"
...
...
@@ -881,7 +882,7 @@ def plot_binned(
data
=
(
data
,)
bootstrap_ci
=
bootstrap
(
data
,
statistic
,
y_
statistic
,
confidence_level
=
confidence_level
,
random_state
=
rng
,
n_resamples
=
no_bootstrap_samples
,
...
...
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