Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sebastian Heimann
grond
Commits
6c98a7ea
Commit
6c98a7ea
authored
Jun 09, 2017
by
Sebastian Heimann
Browse files
changed to bayesian bootstrap
parent
0f9e71fc
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/core.py
View file @
6c98a7ea
...
@@ -216,21 +216,31 @@ class Problem(Object):
...
@@ -216,21 +216,31 @@ class Problem(Object):
def
combined
(
self
):
def
combined
(
self
):
return
self
.
parameters
+
self
.
dependants
return
self
.
parameters
+
self
.
dependants
def
make_bootstrap_weights
(
self
,
nbootstrap
):
def
make_bootstrap_weights
(
self
,
nbootstrap
,
type
=
'classic'
):
ntargets
=
self
.
ntargets
ntargets
=
self
.
ntargets
ws
=
num
.
zeros
((
nbootstrap
,
ntargets
))
ws
=
num
.
zeros
((
nbootstrap
,
ntargets
))
rstate
=
num
.
random
.
RandomState
(
23
)
rstate
=
num
.
random
.
RandomState
(
23
)
for
ibootstrap
in
xrange
(
nbootstrap
):
for
ibootstrap
in
xrange
(
nbootstrap
):
ii
=
rstate
.
randint
(
0
,
ntargets
,
size
=
self
.
ntargets
)
if
type
==
'classic'
:
ws
[
ibootstrap
,
:]
=
num
.
histogram
(
ii
=
rstate
.
randint
(
0
,
ntargets
,
size
=
self
.
ntargets
)
ii
,
ntargets
,
(
-
0.5
,
ntargets
-
0.5
))[
0
]
ws
[
ibootstrap
,
:]
=
num
.
histogram
(
ii
,
ntargets
,
(
-
0.5
,
ntargets
-
0.5
))[
0
]
elif
type
==
'bayesian'
:
f
=
rstate
.
uniform
(
0.
,
1.
,
size
=
self
.
ntargets
+
1
)
f
[
0
]
=
0.
f
[
-
1
]
=
1.
f
=
num
.
sort
(
f
)
g
=
f
[
1
:]
-
f
[:
-
1
]
ws
[
ibootstrap
,
:]
=
g
*
ntargets
else
:
assert
False
return
ws
return
ws
def
get_bootstrap_weights
(
self
,
ibootstrap
=
None
):
def
get_bootstrap_weights
(
self
,
ibootstrap
=
None
):
if
self
.
_bootstrap_weights
is
None
:
if
self
.
_bootstrap_weights
is
None
:
self
.
_bootstrap_weights
=
self
.
make_bootstrap_weights
(
self
.
_bootstrap_weights
=
self
.
make_bootstrap_weights
(
self
.
nbootstrap
)
self
.
nbootstrap
,
type
=
'bayesian'
)
if
ibootstrap
is
None
:
if
ibootstrap
is
None
:
return
self
.
_bootstrap_weights
return
self
.
_bootstrap_weights
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment