Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.pad.base
Commits
b312e6b9
Commit
b312e6b9
authored
Aug 26, 2019
by
Anjith GEORGE
Browse files
Added tests for ScikitClassifier
parent
f01d2bda
Changes
2
Hide whitespace changes
Inline
Side-by-side
bob/pad/base/algorithm/__init__.py
View file @
b312e6b9
...
...
@@ -37,6 +37,7 @@ __appropriate__(
SVMCascadePCA
,
Predictions
,
VideoPredictions
,
ScikitClassifier
,
MLP
,
PadLDA
)
...
...
bob/pad/base/test/test_algorithms.py
View file @
b312e6b9
...
...
@@ -14,6 +14,7 @@ from bob.pad.base.algorithm import SVM
from
bob.pad.base.algorithm
import
OneClassGMM
from
bob.pad.base.algorithm
import
MLP
from
bob.pad.base.algorithm
import
PadLDA
from
bob.pad.base.algorithm
import
ScikitClassifier
import
random
...
...
@@ -219,3 +220,40 @@ def test_LDA():
lda
=
PadLDA
()
lda
.
train_projector
(
training_features
,
'/tmp/lda.hdf5'
)
assert
lda
.
machine
.
shape
==
(
2
,
1
)
def
test_ScikitClassifier
():
random
.
seed
(
7
)
N
=
20000
mu
=
1
sigma
=
1
real_array
=
np
.
transpose
(
np
.
vstack
([[
random
.
gauss
(
mu
,
sigma
)
for
_
in
range
(
N
)],
[
random
.
gauss
(
mu
,
sigma
)
for
_
in
range
(
N
)]]))
mu
=
5
sigma
=
1
attack_array
=
np
.
transpose
(
np
.
vstack
([[
random
.
gauss
(
mu
,
sigma
)
for
_
in
range
(
N
)],
[
random
.
gauss
(
mu
,
sigma
)
for
_
in
range
(
N
)]]))
training_features
=
[
real_array
,
attack_array
]
from
sklearn.preprocessing
import
StandardScaler
from
sklearn.mixture
import
GaussianMixture
_scaler
=
StandardScaler
()
_clf
=
GaussianMixture
(
n_components
=
10
,
covariance_type
=
'full'
)
sk
=
ScikitClassifier
(
clf
=
_clf
,
scaler
=
_scaler
,
frame_level_scores_flag
=
False
,
one_class
=
True
)
sk
.
train_projector
(
training_features
,
'/tmp/sk.hdf5'
)
# Model path `/tmp/sk_skmodel.obj`
# Scaler path `/tmp/sk_scaler.obj`
assert
sk
.
clf
.
n_components
==
10
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment