Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Supervised MultiModal Integration Tool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Analyze
Contributor 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
Baptiste Bauvin
Supervised MultiModal Integration Tool
Commits
5cb78e92
Commit
5cb78e92
authored
5 years ago
by
Baptiste Bauvin
Browse files
Options
Downloads
Patches
Plain Diff
Removed easy_mkl
parent
ffb86575
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
multiview_platform/mono_multi_view_classifiers/multiview_classifiers/easy_mkl.py
+0
-70
0 additions, 70 deletions
..._multi_view_classifiers/multiview_classifiers/easy_mkl.py
with
0 additions
and
70 deletions
multiview_platform/mono_multi_view_classifiers/multiview_classifiers/easy_mkl.py
deleted
100644 → 0
+
0
−
70
View file @
ffb86575
from
MKLpy.algorithms
import
EasyMKL
from
MKLpy.metrics
import
pairwise
from
MKLpy.lists
import
HPK_generator
from
MKLpy.algorithms.komd
import
KOMD
import
numpy
as
np
from
..multiview.multiview_utils
import
BaseMultiviewClassifier
,
get_examples_views_indices
from
..utils.hyper_parameter_search
import
CustomUniform
classifier_class_name
=
"
EasyMKLClassifier
"
class
EasyMKLClassifier
(
BaseMultiviewClassifier
,
EasyMKL
):
def
__init__
(
self
,
random_state
=
None
,
degrees
=
1
,
lam
=
0.1
,
learner
=
KOMD
(
lam
=
0.1
),
generator
=
HPK_generator
(
n
=
10
),
multiclass_strategy
=
'
ova
'
,
verbose
=
False
):
super
().
__init__
(
random_state
)
super
(
BaseMultiviewClassifier
,
self
).
__init__
(
lam
=
lam
,
learner
=
learner
,
generator
=
generator
,
multiclass_strategy
=
multiclass_strategy
,
verbose
=
verbose
)
self
.
degrees
=
degrees
self
.
param_names
=
[
"
lam
"
,
"
degrees
"
]
self
.
distribs
=
[
CustomUniform
(),
DegreesGenerator
()]
def
fit
(
self
,
X
,
y
,
train_indices
=
None
,
view_indices
=
None
):
train_indices
,
view_indices
=
get_examples_views_indices
(
X
,
train_indices
,
view_indices
)
if
isinstance
(
self
.
degrees
,
DegreesDistribution
):
self
.
degrees
=
self
.
degrees
.
draw
(
len
(
view_indices
))
elif
isinstance
(
int
,
self
.
degrees
):
self
.
degrees
=
[
self
.
degrees
for
_
in
range
(
len
(
view_indices
))]
kernels
=
[
pairwise
.
homogeneous_polynomial_kernel
(
X
.
get_v
(
view_indices
[
index
],
train_indices
),
degree
=
degree
)
for
index
,
degree
in
enumerate
(
self
.
degrees
)]
return
super
(
EasyMKLClassifier
,
self
).
fit
(
kernels
,
y
[
train_indices
])
def
predict
(
self
,
X
,
example_indices
=
None
,
view_indices
=
None
):
example_indices
,
view_indices
=
get_examples_views_indices
(
X
,
example_indices
,
view_indices
)
kernels
=
[
pairwise
.
homogeneous_polynomial_kernel
(
X
.
get_v
(
view_indices
[
index
],
example_indices
),
degree
=
degree
)
for
index
,
degree
in
enumerate
(
self
.
degrees
)]
return
super
(
EasyMKLClassifier
,
self
).
predict
(
kernels
,)
class
DegreesGenerator
:
def
__init__
(
self
):
pass
def
rvs
(
self
,
random_state
=
None
):
return
DegreesDistribution
(
seed
=
random_state
.
randint
(
1
))
class
DegreesDistribution
:
def
__init__
(
self
,
seed
=
42
):
self
.
random_state
=
np
.
random
.
RandomState
(
seed
)
def
draw
(
self
,
nb_view
):
return
self
.
random_state
.
randint
(
low
=
5
,
high
=
10
,
size
=
nb_view
)
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