diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 88d97d3..68449c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: strategy: max-parallel: 9 matrix: - python-version: [3.7, 3.8] + python-version: [3.9, 3.10, 3.11] os: [ubuntu-latest, macos-latest] steps: diff --git a/talos/autom8/autoparams.py b/talos/autom8/autoparams.py index d8a9b8c..3f18cee 100644 --- a/talos/autom8/autoparams.py +++ b/talos/autom8/autoparams.py @@ -168,7 +168,7 @@ def batch_size(self, min_size=8, max_size=None, steps=None): integer value at the same time.''' if max_size is None and steps is None: - values = [int(np.exp2(i/2)) for i in range(3, 15)] + values = [int(np.exp2(i / 2)) for i in range(3, 15)] else: values = list(range(min_size, max_size, steps)) @@ -180,7 +180,7 @@ def epochs(self, min_epochs=50, max_epochs=None, steps=None): integer value at the same time.''' if max_epochs is None and steps is None: - values = [int(np.exp2(i/2))+50 for i in range(3, 15)] + values = [int(np.exp2(i / 2)) + 50 for i in range(3, 15)] else: values = list(range(min_epochs, max_epochs, steps)) diff --git a/talos/callbacks/experiment_log.py b/talos/callbacks/experiment_log.py index dbfba0a..f0cd0f2 100644 --- a/talos/callbacks/experiment_log.py +++ b/talos/callbacks/experiment_log.py @@ -27,7 +27,7 @@ def __init__(self, try: latest_file = max(list_of_files, key=os.path.getmtime) except ValueError: - print("\n TALOS ERROR: `experiment_name` has to match `Scan(experiment_name)`\n") + print("\nERROR: `experiment_name` has to match `Scan(experiment_name)`\n") self.name = latest_file.replace('.csv', '') + '.log' diff --git a/talos/templates/datasets.py b/talos/templates/datasets.py index 53ed6ff..62ced39 100755 --- a/talos/templates/datasets.py +++ b/talos/templates/datasets.py @@ -18,7 +18,9 @@ def telco_churn(quantile=.5): import wrangle import pandas as pd - df = pd.read_csv('https://raw.githubusercontent.com/autonomio/examples/master/telco_churn/telco_churn_for_sensitivity.csv') + base_url = 'https://raw.githubusercontent.com/autonomio/' + url = 'examples/master/telco_churn/telco_churn_for_sensitivity.csv' + df = pd.read_csv(base_url + url) df = df.drop(['val_acc', 'loss', 'f1score', 'acc', 'round_epochs'], axis=1) @@ -42,8 +44,10 @@ def telco_churn(quantile=.5): def icu_mortality(samples=None): import pandas as pd - base = 'https://raw.githubusercontent.com/autonomio/datasets/master/autonomio-datasets/' - df = pd.read_csv(base + 'icu_mortality.csv') + + base_url = 'https://raw.githubusercontent.com/autonomio/' + url = 'datasets/master/autonomio-datasets/' + df = pd.read_csv(base_url + url + 'icu_mortality.csv') df = df.dropna(thresh=3580, axis=1) df = df.dropna() df = df.sample(frac=1).head(samples) @@ -56,8 +60,10 @@ def icu_mortality(samples=None): def titanic(): import pandas as pd - base = 'https://raw.githubusercontent.com/autonomio/datasets/master/autonomio-datasets/' - df = pd.read_csv(base + 'titanic.csv') + + base_url = 'https://raw.githubusercontent.com/autonomio/' + url = 'datasets/master/autonomio-datasets/' + df = pd.read_csv(base_url + url + 'titanic.csv') y = df.survived.values @@ -81,8 +87,10 @@ def iris(): import pandas as pd from tensorflow.keras.utils import to_categorical - base = 'https://raw.githubusercontent.com/autonomio/datasets/master/autonomio-datasets/' - df = pd.read_csv(base + 'iris.csv') + + base_url = 'https://raw.githubusercontent.com/autonomio/' + url = 'datasets/master/autonomio-datasets/' + df = pd.read_csv(base_url + url + 'iris.csv') df['species'] = df['species'].factorize()[0] df = df.sample(len(df)) y = to_categorical(df['species']) @@ -98,8 +106,10 @@ def cervical_cancer(): import pandas as pd from numpy import nan - base = 'https://raw.githubusercontent.com/autonomio/datasets/master/autonomio-datasets/' - df = pd.read_csv(base + 'cervical_cancer.csv') + + base_url = 'https://raw.githubusercontent.com/autonomio/' + url = 'datasets/master/autonomio-datasets/' + df = pd.read_csv(base_url + url + 'cervical_cancer.csv') df = df.replace('?', nan) df = df.drop(['citology', 'hinselmann', 'biopsy'], axis=1) df = df.drop(['since_first_diagnosis', @@ -116,8 +126,10 @@ def cervical_cancer(): def breast_cancer(): import pandas as pd - base = 'https://raw.githubusercontent.com/autonomio/datasets/master/autonomio-datasets/' - df = pd.read_csv(base + 'breast_cancer.csv') + + base_url = 'https://raw.githubusercontent.com/autonomio/' + url = 'datasets/master/autonomio-datasets/' + df = pd.read_csv(base_url + url + 'breast_cancer.csv') # then some minimal data cleanup df.drop("Unnamed: 32", axis=1, inplace=True) diff --git a/talos/templates/params.py b/talos/templates/params.py index b627baf..2d6826a 100644 --- a/talos/templates/params.py +++ b/talos/templates/params.py @@ -18,16 +18,16 @@ def titanic(debug=False): if debug: p = {'lr': [0.1, 0.2], - 'first_neuron': [4, 8], - 'batch_size': [20, 30], - 'dropout': [0.2, 0.3], - 'optimizer': [Adam(), Nadam()], - 'epochs': [50, 100], - 'losses': ['logcosh', 'binary_crossentropy'], - 'shapes': ['brick', 'triangle', 0.2], - 'hidden_layers': [0, 1], - 'activation': ['relu', 'elu'], - 'last_activation': ['sigmoid']} + 'first_neuron': [4, 8], + 'batch_size': [20, 30], + 'dropout': [0.2, 0.3], + 'optimizer': [Adam(), Nadam()], + 'epochs': [50, 100], + 'losses': ['logcosh', 'binary_crossentropy'], + 'shapes': ['brick', 'triangle', 0.2], + 'hidden_layers': [0, 1], + 'activation': ['relu', 'elu'], + 'last_activation': ['sigmoid']} return p diff --git a/talos/templates/pipelines.py b/talos/templates/pipelines.py index 5ccf735..3aa3605 100644 --- a/talos/templates/pipelines.py +++ b/talos/templates/pipelines.py @@ -44,7 +44,7 @@ def titanic(round_limit=2, random_method='uniform_mersenne', debug=False): '''Performs a Scan with Iris dataset and simple dense net''' import talos as ta - + scan_object = ta.Scan(ta.templates.datasets.titanic()[0].astype('float32'), ta.templates.datasets.titanic()[1].astype('float32'), ta.templates.params.titanic(debug), diff --git a/tests/commands/test_analyze.py b/tests/commands/test_analyze.py index 66a0b84..653a615 100644 --- a/tests/commands/test_analyze.py +++ b/tests/commands/test_analyze.py @@ -5,7 +5,6 @@ def test_analyze(scan_object): print('\n >>> Start Analyze()... \n') import talos - import glob # for now test with old name r = talos.Reporting(scan_object) @@ -31,10 +30,6 @@ def test_analyze(scan_object): r.high('val_acc') r.low('val_acc') - - - - # r.plot_bars('first_neuron', 'val_acc', 'dropout', 'hidden_layers') r.plot_box('first_neuron', 'val_acc') r.plot_corr('val_loss', ['val_acc', diff --git a/tests/commands/test_rest.py b/tests/commands/test_rest.py index a9d44b1..b6dfcd6 100644 --- a/tests/commands/test_rest.py +++ b/tests/commands/test_rest.py @@ -21,12 +21,7 @@ def test_rest(scan_object): x_train, y_train, x_val, y_val = talos.utils.val_split(x, y, .2) x = talos.utils.rescale_meanzero(x) - import os - os.getcwd() - os.listdir() - - callbacks = [ - talos.utils.early_stopper(10), + callbacks = [talos.utils.early_stopper(10), talos.callbacks.ExperimentLog('test', {})] metrics = [talos.utils.metrics.f1score, diff --git a/tests/commands/test_scan.py b/tests/commands/test_scan.py index b53e2c1..a6e5f62 100644 --- a/tests/commands/test_scan.py +++ b/tests/commands/test_scan.py @@ -5,7 +5,7 @@ def test_scan(): import talos from tensorflow.keras.losses import binary_crossentropy - from tensorflow.keras.optimizers.legacy import Adam, Nadam + from tensorflow.keras.optimizers.legacy import Adam from tensorflow.keras.activations import relu, elu from tensorflow.keras.layers import Dense from tensorflow.keras.models import Sequential @@ -49,12 +49,12 @@ def iris_model(x_train, y_train, x_val, y_val, params): x, y = talos.templates.datasets.iris() - p_for_q = {'activation':['relu', 'elu'], + p_for_q = {'activation': ['relu', 'elu'], 'optimizer': ['Nadam', 'Adam'], 'losses': ['logcosh'], 'shapes': ['brick'], 'first_neuron': [16, 32, 64, 128], - 'hidden_layers':[0, 1, 2, 3], + 'hidden_layers': [0, 1, 2, 3], 'dropout': [.2, .3, .4], 'batch_size': [20, 30, 40, 50], 'epochs': [10]} @@ -74,7 +74,6 @@ def iris_model(x_train, y_train, x_val, y_val, params): reduction_metric='val_acc', minimize_loss=False) - x = x[:50] y = y[:50] @@ -137,8 +136,8 @@ def iris_model(x_train, y_train, x_val, y_val, params): # the create the test based on it - _keras_model = scan_object.best_model() - _keras_model = scan_object.best_model('loss', True) + scan_object.best_model() + scan_object.best_model('loss', True) scan_object.evaluate_models(x_val=scan_object.x, y_val=scan_object.y, @@ -155,7 +154,4 @@ def iris_model(x_train, y_train, x_val, y_val, params): print('finised Scan() object \n') - # # # # # # # # # # # # # # # # # # - - return scan_object