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
bob
bob.learn.boosting
Commits
9558aba2
Commit
9558aba2
authored
Sep 18, 2013
by
Manuel Günther
Browse files
Tried to speed-up the scoring process; fixed small bug
parent
7e011d68
Changes
2
Hide whitespace changes
Inline
Side-by-side
xbob/boosting/core/boosting.py
View file @
9558aba2
...
...
@@ -27,6 +27,7 @@ import numpy
import
trainers
import
losses
import
scipy.optimize
import
itertools
...
...
@@ -261,6 +262,7 @@ class BoostMachine():
"""Returns the indices of the features that are selected by the weak classifiers."""
return
sorted
(
list
(
self
.
selected_indices
))
def
__call__
(
self
,
feature
):
"""Returns the predicted score for the given single feature, assuming only single output.
...
...
@@ -268,7 +270,7 @@ class BoostMachine():
Output: A single floating point number
"""
return
sum
([
a
*
weak
.
get_weak_score
(
feature
)
for
(
a
,
weak
)
in
zip
(
self
.
alpha
,
self
.
weak_trainer
)])
return
sum
([
a
*
weak
.
get_weak_score
(
feature
)
for
(
a
,
weak
)
in
itertools
.
i
zip
(
self
.
alpha
,
self
.
weak_trainer
)])
def
classify
(
self
,
test_features
):
...
...
xbob/boosting/core/trainers.py
View file @
9558aba2
...
...
@@ -23,6 +23,8 @@ class StumpMachine():
self
.
threshold
=
threshold
self
.
polarity
=
polarity
self
.
selected_indices
=
selected_indices
if
isinstance
(
self
.
selected_indices
,
int
):
self
.
selected_indices
=
numpy
.
array
([
self
.
selected_indices
],
dtype
=
numpy
.
int
)
def
get_weak_scores
(
self
,
test_features
):
...
...
Write
Preview
Supports
Markdown
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