Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bolsonaro
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
Operate
Environments
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
Luc Giffon
bolsonaro
Commits
a0f7c96f
Commit
a0f7c96f
authored
5 years ago
by
Charly Lamothe
Browse files
Options
Downloads
Patches
Plain Diff
- Split train function in three distinct functions;
- Update TODO list.
parent
f866e30d
No related branches found
No related tags found
1 merge request
!3
clean scripts
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
TODO.md
+7
-8
7 additions, 8 deletions
TODO.md
code/bolsonaro/trainer.py
+32
-29
32 additions, 29 deletions
code/bolsonaro/trainer.py
code/train.py
+3
-1
3 additions, 1 deletion
code/train.py
with
42 additions
and
38 deletions
TODO.md
+
7
−
8
View file @
a0f7c96f
*
Trouver des jeux de données pertinents
*
Entraîner et tester des forêts de différentes tailles
*
Entraîner et tester en regression et classification
*
Entraîner et tester sur différentes modalités (pas seulement des datasets d'images)
*
Entraîner avec différents hyperparamètres (d, profondeur, epsilon)
*
Appliquer OMP avec différentes valeurs de k (notamment un petit k)
*
Faire des figures
*
Implémenter et comparer les systèmes concurrents
\ No newline at end of file
*
Fix pickle loading of ModelRawResults, because saving the model_object leads import issues.
*
Fix ModelFactory.load function.
*
Fix model results loading in compute_results.py.
*
Check that omp multiclasses classifier is working as expected.
*
In the bayesian search computation, output a different file name depending on the task of the trained model.
*
Check the best params scores of the regressors (neg_mean_squared_error leads to huge negative values).
*
Prepare the json experiment files to run.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
code/bolsonaro/trainer.py
+
32
−
29
View file @
a0f7c96f
...
...
@@ -20,48 +20,51 @@ class Trainer(object):
self
.
_dataset
=
dataset
self
.
_logger
=
LoggerFactory
.
create
(
LOG_PATH
,
__name__
)
def
train
(
self
,
model
,
models_dir
):
"""
:param model: Object with
:param models_dir: Where the results will be saved
:return:
"""
# todo cette fonction ne fait pas que "train", elle choisit le jeu de données, train et evalue le modèle -> nom à changer
self
.
_logger
.
debug
(
'
Training model using train set...
'
)
begin_time
=
time
.
time
()
def
init
(
self
,
model
):
if
model
.
models_parameters
.
subsets_used
==
'
train,dev
'
:
X_forest
=
self
.
_dataset
.
X_train
y_forest
=
self
.
_dataset
.
y_train
X_omp
=
self
.
_dataset
.
X_dev
y_omp
=
self
.
_dataset
.
y_dev
self
.
_
X_forest
=
self
.
_dataset
.
X_train
self
.
_
y_forest
=
self
.
_dataset
.
y_train
self
.
_
X_omp
=
self
.
_dataset
.
X_dev
self
.
_
y_omp
=
self
.
_dataset
.
y_dev
self
.
_logger
.
debug
(
'
Fitting the forest on train subset and OMP on dev subset.
'
)
elif
model
.
models_parameters
.
subsets_used
==
'
train+dev,train+dev
'
:
X_forest
=
np
.
concatenate
([
self
.
_dataset
.
X_train
,
self
.
_dataset
.
X_dev
])
X_omp
=
X_forest
y_forest
=
np
.
concatenate
([
self
.
_dataset
.
y_train
,
self
.
_dataset
.
y_dev
])
y_omp
=
y_forest
self
.
_
X_forest
=
np
.
concatenate
([
self
.
_dataset
.
X_train
,
self
.
_dataset
.
X_dev
])
self
.
_
X_omp
=
self
.
_
X_forest
self
.
_
y_forest
=
np
.
concatenate
([
self
.
_dataset
.
y_train
,
self
.
_dataset
.
y_dev
])
self
.
_
y_omp
=
self
.
_
y_forest
self
.
_logger
.
debug
(
'
Fitting both the forest and OMP on train+dev subsets.
'
)
elif
model
.
models_parameters
.
subsets_used
==
'
train,train+dev
'
:
X_forest
=
self
.
_dataset
.
X_train
y_forest
=
self
.
_dataset
.
y_train
X_omp
=
np
.
concatenate
([
self
.
_dataset
.
X_train
,
self
.
_dataset
.
X_dev
])
y_omp
=
np
.
concatenate
([
self
.
_dataset
.
y_train
,
self
.
_dataset
.
y_dev
])
self
.
_
X_forest
=
self
.
_dataset
.
X_train
self
.
_
y_forest
=
self
.
_dataset
.
y_train
self
.
_
X_omp
=
np
.
concatenate
([
self
.
_dataset
.
X_train
,
self
.
_dataset
.
X_dev
])
self
.
_
y_omp
=
np
.
concatenate
([
self
.
_dataset
.
y_train
,
self
.
_dataset
.
y_dev
])
else
:
raise
ValueError
(
"
Unknown specified subsets_used parameter
'
{}
'"
.
format
(
model
.
models_parameters
.
subsets_used
))
def
train
(
self
,
model
):
"""
:param model: Object with
:return:
"""
self
.
_logger
.
debug
(
'
Training model using train set...
'
)
self
.
_begin_time
=
time
.
time
()
model
.
fit
(
X_forest
=
X_forest
,
y_forest
=
y_forest
,
X_omp
=
X_omp
,
y_omp
=
y_omp
X_forest
=
self
.
_
X_forest
,
y_forest
=
self
.
_
y_forest
,
X_omp
=
self
.
_
X_omp
,
y_omp
=
self
.
_
y_omp
)
end_time
=
time
.
time
()
self
.
_
end_time
=
time
.
time
()
def
compute_results
(
self
,
model
,
models_dir
):
"""
:param model: Object with
:param models_dir: Where the results will be saved
"""
results
=
ModelRawResults
(
model_object
=
model
,
training_time
=
end_time
-
begin_time
,
training_time
=
self
.
_
end_time
-
self
.
_
begin_time
,
datetime
=
datetime
.
datetime
.
now
(),
train_score
=
model
.
score
(
self
.
_dataset
.
X_train
,
self
.
_dataset
.
y_train
),
dev_score
=
model
.
score
(
self
.
_dataset
.
X_dev
,
self
.
_dataset
.
y_dev
),
...
...
This diff is collapsed.
Click to expand it.
code/train.py
+
3
−
1
View file @
a0f7c96f
...
...
@@ -69,7 +69,9 @@ def process_job(seed, parameters, experiment_id, hyperparameters):
model
=
ModelFactory
.
build
(
dataset
.
task
,
model_parameters
)
trainer
.
train
(
model
,
sub_models_dir
)
trainer
.
init
(
model
)
trainer
.
train
(
model
)
trainer
.
compute_results
(
model
,
sub_models_dir
)
logger
.
info
(
'
Training done
'
)
if
__name__
==
"
__main__
"
:
...
...
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