Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.pad.base
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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Show more breadcrumbs
bob
bob.pad.base
Commits
b312e6b9
Commit
b312e6b9
authored
5 years ago
by
Anjith GEORGE
Browse files
Options
Downloads
Patches
Plain Diff
Added tests for ScikitClassifier
parent
f01d2bda
No related branches found
No related tags found
1 merge request
!64
Scikit wrapper
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/pad/base/algorithm/__init__.py
+1
-0
1 addition, 0 deletions
bob/pad/base/algorithm/__init__.py
bob/pad/base/test/test_algorithms.py
+38
-0
38 additions, 0 deletions
bob/pad/base/test/test_algorithms.py
with
39 additions
and
0 deletions
bob/pad/base/algorithm/__init__.py
+
1
−
0
View file @
b312e6b9
...
...
@@ -37,6 +37,7 @@ __appropriate__(
SVMCascadePCA
,
Predictions
,
VideoPredictions
,
ScikitClassifier
,
MLP
,
PadLDA
)
...
...
This diff is collapsed.
Click to expand it.
bob/pad/base/test/test_algorithms.py
+
38
−
0
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
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