Commit c3272e93 authored by Gaetano Raffaele's avatar Gaetano Raffaele
Browse files

ENH: option to save training base in pkl file.

parent e56fd9f3
No related merge requests found
Showing with 12 additions and 0 deletions
+12 -0
import glob import glob
import pickle
import numpy as np import numpy as np
import pandas as pd import pandas as pd
...@@ -119,6 +120,11 @@ class ObjectBasedClassifier: ...@@ -119,6 +120,11 @@ class ObjectBasedClassifier:
self.obia_base.populate_map(t, L, c, output_file, compress) self.obia_base.populate_map(t, L, c, output_file, compress)
prg.update(1) prg.update(1)
return return
def save_training_base(self, fn):
with open(fn, 'wb') as f:
pickle.dump(self.training_base, f)
return
#TEST CODE #TEST CODE
def run_test(sample_folder): def run_test(sample_folder):
......
...@@ -85,6 +85,11 @@ def train_valid_workflow(seg, ts_lst_pkl, d, m_file): ...@@ -85,6 +85,11 @@ def train_valid_workflow(seg, ts_lst_pkl, d, m_file):
ref_class_field=d['ref_db']['fields']) ref_class_field=d['ref_db']['fields'])
obc.gen_k_folds(5, class_field=d['ref_db']['fields'][-1]) obc.gen_k_folds(5, class_field=d['ref_db']['fields'][-1])
if 'export_training_base' in d['training'].keys() and d['training']['export_training_base'] is True:
obc.save_training_base('{}/_side/training_base.pkl'.format(os.path.join(d['output_path'], d['chain_name'])))
print('[MORINGA-INFO] : Training base export completed.')
ok = True ok = True
for i,cf in enumerate(d['ref_db']['fields']): for i,cf in enumerate(d['ref_db']['fields']):
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
], ],
"training": { "training": {
"export_training_base": false,
"classifier": "rf", "classifier": "rf",
"parameters": { "parameters": {
"n_trees": 400 "n_trees": 400
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment