summaryrefslogtreecommitdiff
path: root/ml_model_trainer.py
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2021-07-08 22:25:12 -0700
committerScott Gasch <[email protected]>2021-07-08 22:25:12 -0700
commit11eeb8574b7b4620ac6fd440cb251f8aa2458f5b (patch)
tree97f8e64eddd4528b01af58df269427814b889929 /ml_model_trainer.py
parente516059c716537259c601c022cc3bad44025385e (diff)
Reduce import scopes, remove cycles.
Diffstat (limited to 'ml_model_trainer.py')
-rw-r--r--ml_model_trainer.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/ml_model_trainer.py b/ml_model_trainer.py
index b0a9a1b..ab3059f 100644
--- a/ml_model_trainer.py
+++ b/ml_model_trainer.py
@@ -20,14 +20,8 @@ from sklearn.preprocessing import MinMaxScaler # type: ignore
from ansi import bold, reset
import argparse_utils
import config
-import datetime_utils
-import decorator_utils
-import input_utils
-import list_utils
+from decorator_utils import timed
import parallelize as par
-import smart_future
-import string_utils
-import text_utils
logger = logging.getLogger(__file__)
@@ -101,6 +95,8 @@ class TrainingBlueprint(ABC):
self.spec = None
def train(self, spec: InputSpec) -> OutputSpec:
+ import smart_future
+
random.seed()
self.spec = spec
@@ -262,11 +258,17 @@ class TrainingBlueprint(ABC):
def make_progress_graph(self) -> None:
if not self.spec.quiet:
- text_utils.progress_graph(self.file_done_count,
- self.total_file_count)
+ from text_utils import progress_graph
+ progress_graph(
+ self.file_done_count,
+ self.total_file_count
+ )
- @decorator_utils.timed
+ @timed
def read_input_files(self):
+ import list_utils
+ import smart_future
+
# All features
X = []
@@ -350,6 +352,10 @@ class TrainingBlueprint(ABC):
scaler: Any,
model: Any) -> Tuple[Optional[str], Optional[str], Optional[str]]:
if not self.spec.dry_run:
+ import datetime_utils
+ import input_utils
+ import string_utils
+
if (
(self.spec.persist_percentage_threshold is not None and
test_score > self.spec.persist_percentage_threshold)