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
f7d0a4a0
Commit
f7d0a4a0
authored
7 years ago
by
bbauvin
Browse files
Options
Downloads
Patches
Plain Diff
Updated Decision trees agruments and modified gridsearch name
parent
ce891071
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/MonoMutliViewClassifiers/ExecClassif.py
+5
-0
5 additions, 0 deletions
Code/MonoMutliViewClassifiers/ExecClassif.py
Code/MonoMutliViewClassifiers/MonoviewClassifiers/DecisionTree.py
+16
-6
16 additions, 6 deletions
...oMutliViewClassifiers/MonoviewClassifiers/DecisionTree.py
with
21 additions
and
6 deletions
Code/MonoMutliViewClassifiers/ExecClassif.py
+
5
−
0
View file @
f7d0a4a0
...
@@ -471,6 +471,11 @@ groupAdaboost.add_argument('--CL_Adaboost_b_est', metavar='STRING', action='stor
...
@@ -471,6 +471,11 @@ groupAdaboost.add_argument('--CL_Adaboost_b_est', metavar='STRING', action='stor
groupDT
=
parser
.
add_argument_group
(
'
Decision Trees arguments
'
)
groupDT
=
parser
.
add_argument_group
(
'
Decision Trees arguments
'
)
groupDT
.
add_argument
(
'
--CL_DecisionTree_depth
'
,
metavar
=
'
INT
'
,
type
=
int
,
action
=
'
store
'
,
groupDT
.
add_argument
(
'
--CL_DecisionTree_depth
'
,
metavar
=
'
INT
'
,
type
=
int
,
action
=
'
store
'
,
help
=
'
Determine max depth for Decision Trees
'
,
default
=
3
)
help
=
'
Determine max depth for Decision Trees
'
,
default
=
3
)
groupDT
.
add_argument
(
'
--CL_DecisionTree_criterion
'
,
metavar
=
'
STRING
'
,
action
=
'
store
'
,
help
=
'
Determine max depth for Decision Trees
'
,
default
=
"
entropy
"
)
groupDT
.
add_argument
(
'
--CL_DecisionTree_splitter
'
,
metavar
=
'
STRING
'
,
action
=
'
store
'
,
help
=
'
Determine max depth for Decision Trees
'
,
default
=
"
random
"
)
groupSGD
=
parser
.
add_argument_group
(
'
SGD arguments
'
)
groupSGD
=
parser
.
add_argument_group
(
'
SGD arguments
'
)
groupSGD
.
add_argument
(
'
--CL_SGD_alpha
'
,
metavar
=
'
FLOAT
'
,
type
=
float
,
action
=
'
store
'
,
groupSGD
.
add_argument
(
'
--CL_SGD_alpha
'
,
metavar
=
'
FLOAT
'
,
type
=
float
,
action
=
'
store
'
,
...
...
This diff is collapsed.
Click to expand it.
Code/MonoMutliViewClassifiers/MonoviewClassifiers/DecisionTree.py
+
16
−
6
View file @
f7d0a4a0
...
@@ -13,9 +13,12 @@ __status__ = "Prototype" # Production, Development, P
...
@@ -13,9 +13,12 @@ __status__ = "Prototype" # Production, Development, P
def
canProbas
():
def
canProbas
():
return
True
return
True
def
fit
(
DATASET
,
CLASS_LABELS
,
NB_CORES
=
1
,
**
kwargs
):
def
fit
(
DATASET
,
CLASS_LABELS
,
NB_CORES
=
1
,
**
kwargs
):
maxDepth
=
int
(
kwargs
[
'
0
'
])
maxDepth
=
int
(
kwargs
[
'
0
'
])
classifier
=
DecisionTreeClassifier
(
max_depth
=
maxDepth
)
criterion
=
kwargs
[
'
1
'
]
splitter
=
kwargs
[
'
2
'
]
classifier
=
DecisionTreeClassifier
(
max_depth
=
maxDepth
,
criterion
=
criterion
,
splitter
=
splitter
)
classifier
.
fit
(
DATASET
,
CLASS_LABELS
)
classifier
.
fit
(
DATASET
,
CLASS_LABELS
)
return
classifier
return
classifier
...
@@ -25,12 +28,18 @@ def getKWARGS(kwargsList):
...
@@ -25,12 +28,18 @@ def getKWARGS(kwargsList):
for
(
kwargName
,
kwargValue
)
in
kwargsList
:
for
(
kwargName
,
kwargValue
)
in
kwargsList
:
if
kwargName
==
"
CL_DecisionTree_depth
"
:
if
kwargName
==
"
CL_DecisionTree_depth
"
:
kwargsDict
[
'
0
'
]
=
int
(
kwargValue
)
kwargsDict
[
'
0
'
]
=
int
(
kwargValue
)
if
kwargName
==
"
CL_DecisionTree_criterion
"
:
kwargsDict
[
'
1
'
]
=
kwargValue
if
kwargName
==
"
CL_DecisionTree_splitter
"
:
kwargsDict
[
'
2
'
]
=
kwargValue
return
kwargsDict
return
kwargsDict
def
gri
dSearch
(
X_train
,
y_train
,
nbFolds
=
4
,
nbCores
=
1
,
metric
=
[
"
accuracy_score
"
,
None
],
nIter
=
30
):
def
randomize
dSearch
(
X_train
,
y_train
,
nbFolds
=
4
,
nbCores
=
1
,
metric
=
[
"
accuracy_score
"
,
None
],
nIter
=
30
):
pipeline_DT
=
Pipeline
([(
'
classifier
'
,
DecisionTreeClassifier
())])
pipeline_DT
=
Pipeline
([(
'
classifier
'
,
DecisionTreeClassifier
())])
param_DT
=
{
"
classifier__max_depth
"
:
randint
(
1
,
30
)}
param_DT
=
{
"
classifier__max_depth
"
:
randint
(
1
,
30
),
"
classifier__criterion
"
:
[
"
gini
"
,
"
entropy
"
],
"
classifier__splitter
"
:
[
"
best
"
,
"
random
"
]}
metricModule
=
getattr
(
Metrics
,
metric
[
0
])
metricModule
=
getattr
(
Metrics
,
metric
[
0
])
if
metric
[
1
]
!=
None
:
if
metric
[
1
]
!=
None
:
metricKWARGS
=
dict
((
index
,
metricConfig
)
for
index
,
metricConfig
in
enumerate
(
metric
[
1
]))
metricKWARGS
=
dict
((
index
,
metricConfig
)
for
index
,
metricConfig
in
enumerate
(
metric
[
1
]))
...
@@ -40,12 +49,13 @@ def gridSearch(X_train, y_train, nbFolds=4, nbCores=1, metric=["accuracy_score",
...
@@ -40,12 +49,13 @@ def gridSearch(X_train, y_train, nbFolds=4, nbCores=1, metric=["accuracy_score",
grid_DT
=
RandomizedSearchCV
(
pipeline_DT
,
n_iter
=
nIter
,
param_distributions
=
param_DT
,
refit
=
True
,
n_jobs
=
nbCores
,
scoring
=
scorer
,
grid_DT
=
RandomizedSearchCV
(
pipeline_DT
,
n_iter
=
nIter
,
param_distributions
=
param_DT
,
refit
=
True
,
n_jobs
=
nbCores
,
scoring
=
scorer
,
cv
=
nbFolds
)
cv
=
nbFolds
)
DT_detector
=
grid_DT
.
fit
(
X_train
,
y_train
)
DT_detector
=
grid_DT
.
fit
(
X_train
,
y_train
)
desc_params
=
[
DT_detector
.
best_params_
[
"
classifier__max_depth
"
]]
desc_params
=
[
DT_detector
.
best_params_
[
"
classifier__max_depth
"
],
DT_detector
.
best_params_
[
"
classifier__criterion
"
],
DT_detector
.
best_params_
[
"
classifier__splitter
"
]]
return
desc_params
return
desc_params
def
getConfig
(
config
):
def
getConfig
(
config
):
try
:
try
:
return
"
\n\t\t
- Decision Tree with max_depth :
"
+
str
(
config
[
0
])
return
"
\n\t\t
- Decision Tree with max_depth :
"
+
str
(
config
[
0
])
+
"
, criterion :
"
+
config
[
1
]
+
"
, splitter :
"
+
config
[
2
]
except
:
except
:
return
"
\n\t\t
- Decision Tree with max_depth :
"
+
str
(
config
[
"
0
"
])
return
"
\n\t\t
- Decision Tree with max_depth :
"
+
str
(
config
[
"
0
"
])
+
"
, criterion :
"
+
config
[
"
1
"
]
+
"
, splitter :
"
+
config
[
"
2
"
]
\ No newline at end of file
\ No newline at end of file
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