Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
deepdraw
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
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
medai
software
deepdraw
Commits
678e3a54
Commit
678e3a54
authored
4 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[utils.measure] Fix docstring of new code
parent
1fb0f4e4
No related branches found
No related tags found
1 merge request
!16
Use pytest instead of nose
Pipeline
#45863
passed
4 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/ip/binseg/utils/measure.py
+18
-18
18 additions, 18 deletions
bob/ip/binseg/utils/measure.py
with
18 additions
and
18 deletions
bob/ip/binseg/utils/measure.py
+
18
−
18
View file @
678e3a54
...
...
@@ -133,30 +133,30 @@ def beta_credible_region(k, l, lambda_, coverage):
from a series of Bernoulli trials (likelihood is binomial). The posterior
is derivated using the Bayes Theorem with a beta prior. As there is no
reason to favour high vs. low precision, we use a symmetric Beta prior
(:math:`
\a
lpha=
\b
eta`):
(:math:`
\
\
alpha=
\
\
beta`):
.. math::
P(p|k,n) &=
\f
rac{P(k,n|p)P(p)}{P(k,n)}
\\
P(p|k,n) &=
\f
rac{
\f
rac{n!}{k!(n-k)!}p^{k}(1-p)^{n-k}P(p)}{P(k)}
\\
P(p|k,n) &=
\f
rac{1}{B(k+
\a
lpha, n-k+
\b
eta)}p^{k+
\a
lpha-1}(1-p)^{n-k+
\b
eta-1}
P(p|k,n) &=
\f
rac{1}{B(k+
\a
lpha, n-k+
\a
lpha)}p^{k+
\a
lpha-1}(1-p)^{n-k+
\a
lpha-1}
P(p|k,n) &=
\
\
frac{P(k,n|p)P(p)}{P(k,n)}
\\
\\
P(p|k,n) &=
\
\
frac{
\
\
frac{n!}{k!(n-k)!}p^{k}(1-p)^{n-k}P(p)}{P(k)}
\\
\\
P(p|k,n) &=
\
\
frac{1}{B(k+
\
\
alpha, n-k+
\b
eta)}p^{k+
\
\
alpha-1}(1-p)^{n-k+
\
\
beta-1}
\\\\
P(p|k,n) &=
\
\
frac{1}{B(k+
\
\
alpha, n-k+
\
\
alpha)}p^{k+
\
\
alpha-1}(1-p)^{n-k+
\
\
alpha-1}
The mode for this posterior (also the maximum a posteriori) is:
.. math::
mode(p) =
\f
rac{k+\lambda-1}{n+2\lambda-2}
\\
text{
mode
}
(p) =
\
\
frac{k+
\
\
lambda-1}{n+2
\
\
lambda-2}
Concretely, the prior may be flat (all rates are equally likely,
:math:`\lambda=1`) or we may use Jeoffrey
'
s prior
(:math:`\lambda=0.5`),
that is invariant through re-parameterisation.
Jeffrey
'
s prior indicate
that rates close to zero or one are more likely.
:math:`
\
\
lambda=1`) or we may use Jeoffrey
'
s prior
(:math:`
\\
lambda=0.5`),
that is invariant through re-parameterisation.
Jeffrey
'
s prior indicate
that rates close to zero or one are more likely.
The mode above works if :math:`k+
\a
lpha,n-k+
\a
lpha > 1`, which is
usually
the case for a resonably well tunned system, with more than a few
samples
for analysis. In the limit of the system performance, :math:`k`
may be 0,
which will make the mode become zero.
The mode above works if :math:`k+
{
\
\
alpha
}
,n-k+
{
\
\
alpha
}
> 1`, which is
usually
the case for a resonably well tunned system, with more than a few
samples
for analysis. In the limit of the system performance, :math:`k`
may be 0,
which will make the mode become zero.
For our purposes, it may be more suitable to represent :math:`n = k + l`,
with :math:`k`, the number of successes and :math:`l`, the number of
...
...
@@ -165,8 +165,8 @@ def beta_credible_region(k, l, lambda_, coverage):
.. math::
P(p|k,l) &=
\f
rac{1}{B(k+
\a
lpha, l+
\a
lpha)}p^{k+
\a
lpha-1}(1-p)^{l+
\a
lpha-1}
\\
mode(p) &=
\f
rac{k+\lambda-1}{k+l+2\lambda-2}
P(p|k,l) &=
\
\
frac{1}{B(k+
\
\
alpha, l+
\
\
alpha)}p^{k+
\
\
alpha-1}(1-p)^{l+
\
\
alpha-1}
\\
\\
\\
text{
mode
}
(p) &=
\
\
frac{k+
\
\
lambda-1}{k+l+2
\
\
lambda-2}
This can be mapped to most rates calculated in the context of binary
classification this way:
...
...
@@ -189,7 +189,7 @@ def beta_credible_region(k, l, lambda_, coverage):
.. note::
For a disambiguation with Confidence Inter
f
val, read
For a disambiguation with Confidence Interval, read
https://en.wikipedia.org/wiki/Credible_interval.
...
...
@@ -202,9 +202,9 @@ def beta_credible_region(k, l, lambda_, coverage):
l : int
Number of failures observed on the experiment
lambda_ : :py:class:`float`, Optional
lambda_
_
: :py:class:`float`, Optional
The parameterisation of the Beta prior to consider. Use
:math:`\lambda=1` for a flat prior. Use :math:`\lambda=0.5` for
:math:`
\
\
lambda=1` for a flat prior. Use :math:`
\
\
lambda=0.5` for
Jeffrey
'
s prior (the default).
coverage : :py:class:`float`, Optional
...
...
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