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.bio.base
Commits
440483c0
Commit
440483c0
authored
Apr 26, 2016
by
Tiago de Freitas Pereira
Browse files
Fixed issue
#16
parent
96cfce3d
Changes
2
Hide whitespace changes
Inline
Side-by-side
bob/bio/base/algorithm/Distance.py
View file @
440483c0
...
...
@@ -89,7 +89,7 @@ class Distance (Algorithm):
probe : object
The probe.
"""
return
utils
.
load
(
featur
e_file
)
return
utils
.
load
(
prob
e_file
)
def
score
(
self
,
model
,
probe
):
...
...
bob/bio/base/test/test_algorithms.py
View file @
440483c0
...
...
@@ -216,6 +216,37 @@ def test_lda():
def
test_distance
():
import
scipy.spatial
# assure that the configurations are loadable
distance
=
bob
.
bio
.
base
.
load_resource
(
"distance-cosine"
,
"algorithm"
,
preferred_package
=
'bob.bio.base'
)
assert
isinstance
(
distance
,
bob
.
bio
.
base
.
algorithm
.
Distance
)
assert
isinstance
(
distance
,
bob
.
bio
.
base
.
algorithm
.
Algorithm
)
assert
distance
.
performs_projection
==
False
assert
distance
.
requires_projector_training
==
False
assert
distance
.
use_projected_features_for_enrollment
==
False
assert
distance
.
split_training_features_by_client
==
False
assert
distance
.
requires_enroller_training
==
False
distance
=
bob
.
bio
.
base
.
algorithm
.
Distance
(
distance_function
=
scipy
.
spatial
.
distance
.
cosine
,
is_distance_function
=
True
)
# compare model with probe
enroll
=
utils
.
random_training_set
(
5
,
5
,
0.
,
255.
,
seed
=
21
);
model
=
numpy
.
mean
(
distance
.
enroll
(
enroll
),
axis
=
0
)
probe
=
distance
.
read_probe
(
pkg_resources
.
resource_filename
(
'bob.bio.base.test'
,
'data/lda_projected.hdf5'
))
reference_score
=
-
0.1873371
assert
abs
(
distance
.
score
(
model
,
probe
)
-
reference_score
)
<
1e-5
,
"The scores differ: %3.8f, %3.8f"
%
(
distance
.
score
(
model
,
probe
),
reference_score
)
def
test_bic
():
temp_file
=
bob
.
io
.
base
.
test_utils
.
temporary_filename
()
# assure that the configurations are loadable
...
...
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