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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Baptiste Bauvin
Supervised MultiModal Integration Tool
Commits
81ea004a
Commit
81ea004a
authored
5 years ago
by
Baptiste Bauvin
Browse files
Options
Downloads
Patches
Plain Diff
Mumbo dict base param
parent
b88f3845
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
multiview_platform/mono_multi_view_classifiers/multiview_classifiers/mumbo.py
+21
-6
21 additions, 6 deletions
...ono_multi_view_classifiers/multiview_classifiers/mumbo.py
with
21 additions
and
6 deletions
multiview_platform/mono_multi_view_classifiers/multiview_classifiers/mumbo.py
+
21
−
6
View file @
81ea004a
from
sklearn.tree
import
DecisionTreeClassifier
from
sklearn.base
import
BaseEstimator
import
numpy
as
np
from
multimodal.boosting.mumbo
import
MumboClassifier
...
...
@@ -17,6 +18,7 @@ class Mumbo(BaseMultiviewClassifier, MumboClassifier):
random_state
=
None
,
best_view_mode
=
"
edge
"
):
BaseMultiviewClassifier
.
__init__
(
self
,
random_state
)
base_estimator
=
self
.
set_base_estim_from_dict
(
base_estimator
)
MumboClassifier
.
__init__
(
self
,
base_estimator
=
base_estimator
,
n_estimators
=
n_estimators
,
random_state
=
random_state
,
...
...
@@ -25,6 +27,23 @@ class Mumbo(BaseMultiviewClassifier, MumboClassifier):
self
.
distribs
=
[
base_boosting_estimators
,
CustomRandint
(
5
,
200
),
[
random_state
],
[
"
edge
"
,
"
error
"
]]
def
set_base_estim_from_dict
(
self
,
base_estim_dict
):
if
base_estim_dict
is
None
:
base_estimator
=
DecisionTreeClassifier
()
elif
isinstance
(
base_estim_dict
,
dict
):
estim_name
=
next
(
iter
(
base_estim_dict
))
estim_module
=
getattr
(
monoview_classifiers
,
estim_name
)
estim_class
=
getattr
(
estim_module
,
estim_module
.
classifier_class_name
)
base_estimator
=
estim_class
(
**
base_estim_dict
[
estim_name
])
elif
isinstance
(
base_estim_dict
,
BaseEstimator
):
base_estimator
=
base_estim_dict
else
:
raise
ValueError
(
"
base_estimator should be either None, a dictionary
"
"
or a BaseEstimator child object,
"
"
here it is {}
"
.
format
(
type
(
base_estim_dict
)))
return
base_estimator
def
set_params
(
self
,
base_estimator
=
None
,
**
params
):
"""
Sets the base estimator from a dict.
...
...
@@ -35,11 +54,7 @@ class Mumbo(BaseMultiviewClassifier, MumboClassifier):
if
base_estimator
is
None
:
self
.
base_estimator
=
DecisionTreeClassifier
()
elif
isinstance
(
base_estimator
,
dict
):
estim_name
=
next
(
iter
(
base_estimator
))
estim_module
=
getattr
(
monoview_classifiers
,
estim_name
)
estim_class
=
getattr
(
estim_module
,
estim_module
.
classifier_class_name
)
self
.
base_estimator
=
estim_class
(
**
base_estimator
[
estim_name
])
self
.
base_estimator
=
self
.
set_base_estim_from_dict
(
base_estimator
)
MumboClassifier
.
set_params
(
self
,
**
params
)
else
:
MumboClassifier
.
set_params
(
self
,
base_estimator
=
base_estimator
,
**
params
)
...
...
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