From 09ef9ca3823277ab2a1800c3da0e669c85bc4684 Mon Sep 17 00:00:00 2001 From: Mikko Kotila Date: Mon, 4 Mar 2019 12:39:57 +0200 Subject: [PATCH] clean up / pepify --- .gitignore | 1 + talos/commands/deploy.py | 9 ++++----- talos/commands/kerasmodel.py | 3 ++- talos/commands/predict.py | 5 ----- talos/commands/reporting.py | 3 +-- talos/commands/restore.py | 12 ++++++++++-- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 0aedd6eb..a15bf913 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ talos.egg-info *.h5 *.json *.npy +test.sh diff --git a/talos/commands/deploy.py b/talos/commands/deploy.py index 9e151acd..1e515070 100644 --- a/talos/commands/deploy.py +++ b/talos/commands/deploy.py @@ -12,11 +12,10 @@ class Deploy: def __init__(self, scan_object, model_name, metric='val_acc', asc=False): - '''Deploy a model to be used later or in a different system. NOTE: for a metric that is to be minimized, set asc=True or otherwise - you will end up with the model that has the highest loss. + you will end up with the model that has the highest loss. Deploy() takes in the object from Scan() and creates a package locally that can be later activated with Restore(). @@ -26,10 +25,10 @@ def __init__(self, scan_object, model_name, metric='val_acc', asc=False): model_name : str Name for the .zip file to be created. metric : str - The metric to be used for picking the best model. + The metric to be used for picking the best model. asc: bool - Make this True for metrics that are to be minimized (e.g. loss) , and - False when the metric is to be maximized (e.g. acc) + Make this True for metrics that are to be minimized (e.g. loss) , + and False when the metric is to be maximized (e.g. acc) ''' diff --git a/talos/commands/kerasmodel.py b/talos/commands/kerasmodel.py index 43c452f6..fb48764a 100644 --- a/talos/commands/kerasmodel.py +++ b/talos/commands/kerasmodel.py @@ -73,7 +73,8 @@ def _create_input_model(self, x_train, y_train, x_val, y_val, params): activation=params['last_activation'])) # bundle the optimizer with learning rate changes - optimizer = params['optimizer'](lr=lr_normalizer(params['lr'], params['optimizer'])) + optimizer = params['optimizer'](lr=lr_normalizer(params['lr'], + params['optimizer'])) # compile the model model.compile(optimizer=optimizer, diff --git a/talos/commands/predict.py b/talos/commands/predict.py index 725e062f..e46926e2 100644 --- a/talos/commands/predict.py +++ b/talos/commands/predict.py @@ -1,8 +1,3 @@ -from numpy import mean, std - -from sklearn.metrics import f1_score - -from ..utils.validation_split import kfold from ..utils.best_model import best_model, activate_model diff --git a/talos/commands/reporting.py b/talos/commands/reporting.py index 5832497b..e7d1485e 100644 --- a/talos/commands/reporting.py +++ b/talos/commands/reporting.py @@ -1,11 +1,10 @@ from pandas import read_csv from ..utils.connection_check import is_connected +from ..metrics.names import metric_names if is_connected() is True: from astetik import line, hist, corr, regs, bargrid, kde, box -from ..metrics.names import metric_names - class Reporting: diff --git a/talos/commands/restore.py b/talos/commands/restore.py index ca262fc8..1b185791 100644 --- a/talos/commands/restore.py +++ b/talos/commands/restore.py @@ -8,8 +8,16 @@ class Restore: - '''Utility class for restoring the assets from Deploy() - package.''' + '''Restores the scan_object that had been stored locally as a result + of talos.Deploy(scan_object, 'example') + + USE: + + diabetes = ta.Scan(x, y, p, input_model) + ta.Deploy(diabetes, 'diabetes') + ta.Restore('diabetes.zip') + + ''' def __init__(self, path_to_zip):