markdown
stringlengths
0
1.02M
code
stringlengths
0
832k
output
stringlengths
0
1.02M
license
stringlengths
3
36
path
stringlengths
6
265
repo_name
stringlengths
6
127
Mangelfulle spørringer mot NVDB api V3? her sammenligner vi resultatet av spørringen `/vegobjekter/904?kommune=5001&veg(system)referanse=K` mot NVDB api V2 og V3.
import json import pandas as pd import os mappe = 'stavanger_904' filer = os.listdir(mappe) manglergeom = [] fasit = [] etterspurt_E = [] etterspurt_R = [] etterspurt_F = [] etterspurt_K = [] etterspurt_P = [] etterspurt_S = [] for eifil in filer: if 'json' in eifil: spurt_vegkat = eifil.split( '.')[0].split( '_')[-1] with open( os.path.join( mappe, eifil), encoding='utf-8') as f: data = json.load( f) for rad in data: rad['spurt_vegkat'] = spurt_vegkat if 'mengdeuttak_v2' in eifil: fasit.extend( data) elif 'mangler_geometriv3' in eifil: manglergeom.extend( data ) manglergeom = pd.DataFrame( manglergeom ) fasit = pd.DataFrame( fasit )
_____no_output_____
MIT
debug_nvdbapilesv3/vegobjekter/sjekkmangler.ipynb
LtGlahn/diskusjon_diverse
Har vi duplikater i de ugyldige V3-objektene?
duplikat = manglergeom[ manglergeom.duplicated(subset='id', keep=False) ] print( len( duplikat), 'duplikater av', len( manglergeom), 'ugyldige og', len(fasit), 'totalt')
4 duplikater av 155 ugyldige og 5648 totalt
MIT
debug_nvdbapilesv3/vegobjekter/sjekkmangler.ipynb
LtGlahn/diskusjon_diverse
Relativt uinteressant, iallfall inntil videre Lær mer om ugyldige data Stemmer ønsket vegkategori med det vi fant?
mangler = pd.merge( left=manglergeom, right=fasit, left_on='id', right_on='vegobjektid', how='inner') mangler.columns mangler[ mangler['spurt_vegkat_x'] == mangler['vegkat']]
_____no_output_____
MIT
debug_nvdbapilesv3/vegobjekter/sjekkmangler.ipynb
LtGlahn/diskusjon_diverse
Er det en vegkategori som peker seg ut?
mangler.vegkat.value_counts()
_____no_output_____
MIT
debug_nvdbapilesv3/vegobjekter/sjekkmangler.ipynb
LtGlahn/diskusjon_diverse
Estimate Paramters of system of ODEs for given time course data imports
import pandas as pd # convert excel to dataframe import numpy as np # convert dataframe to nparray for solver from scipy.integrate import odeint # solve ode from lmfit import minimize, Parameters, Parameter, report_fit # fitting import matplotlib.pyplot as plt # plot data and results
_____no_output_____
BSD-2-Clause
Model_Stephan_pH7.ipynb
HannahDi/EnzymeML_KineticModeling
Get data from excel
data = './datasets/Stephan_pH7.xlsx' df = pd.read_excel(data, sheet_name=1)
_____no_output_____
BSD-2-Clause
Model_Stephan_pH7.ipynb
HannahDi/EnzymeML_KineticModeling
Convert dataframe to np-array
# time: data_time = df[df.columns[0]].to_numpy(np.float64) #shape: (60,) # substrate data (absorption): data_s = np.transpose(df.iloc[:,1:].to_numpy(np.float64)) #shape: (3, 60)
_____no_output_____
BSD-2-Clause
Model_Stephan_pH7.ipynb
HannahDi/EnzymeML_KineticModeling
Fit data to system of odes define the ode functions
def f(w, t, paras): ''' System of differential equations Arguments: w: vector of state variables: w = [v,s] t: time params: parameters ''' v, s = w try: a = paras['a'].value vmax = paras['vmax'].value km = paras['km'].value except KeyError: a, vmax, km = paras # f(v',s'): f0 = a*(vmax-v) # v' f1 = -v*s/(km+s) # s' return [f0,f1]
_____no_output_____
BSD-2-Clause
Model_Stephan_pH7.ipynb
HannahDi/EnzymeML_KineticModeling
Solve ODE
def g(t, w0, paras): ''' Solution to the ODE w'(t)=f(t,w,p) with initial condition w(0)= w0 (= [v0, s0]) ''' w = odeint(f, w0, t, args=(paras,)) return w
_____no_output_____
BSD-2-Clause
Model_Stephan_pH7.ipynb
HannahDi/EnzymeML_KineticModeling
compute residual between actual data (s) and fitted data
def res_multi(params, t, data_s): ndata, nt = data_s.shape resid = 0.0*data_s[:] # residual per data set for i in range(ndata): w0 = params['v0'].value, params['s0'].value model = g(t, w0, params) # only have data for s not v s_model = model[:,1] s_model_b = s_model + params['b'].value resid[i,:]=data_s[i,:]-s_model_b return resid.flatten()
_____no_output_____
BSD-2-Clause
Model_Stephan_pH7.ipynb
HannahDi/EnzymeML_KineticModeling
Bringing everything togetherInitialize parameters
# initial conditions: v0 = 0 s0 = np.mean(data_s,axis=0)[0] # Set parameters including bounds bias = 0.1 params = Parameters() params.add('v0', value=v0, vary=False) params.add('s0', value=s0-bias, min=0.1, max=s0) params.add('a', value=1., min=0.0001, max=2.) params.add('vmax', value=0.2, min=0.0001, max=1.) params.add('km', value=0.05, min=0.0001, max=1.) params.add('b', value=bias, min=0.01, max=0.5) # time t_measured = data_time
_____no_output_____
BSD-2-Clause
Model_Stephan_pH7.ipynb
HannahDi/EnzymeML_KineticModeling
Fit model and visualize results
# fit model result = minimize(res_multi , params, args=(t_measured, data_s), method='leastsq') # leastsq nelder report_fit(result) # plot the data sets and fits w0 = params['v0'].value, params['s0'].value data_fitted = g(t_measured, w0, result.params) plt.figure() for i in range(data_s.shape[0]): plt.plot(t_measured, data_s[i, :], 'o') plt.plot(t_measured, data_fitted[:, 1]+params['b'].value, '-', linewidth=2, color='red', label='fitted data') plt.show()
[[Fit Statistics]] # fitting method = leastsq # function evals = 96 # data points = 180 # variables = 5 chi-square = 0.04123983 reduced chi-square = 2.3566e-04 Akaike info crit = -1498.63538 Bayesian info crit = -1482.67059 [[Variables]] v0: 0 (fixed) s0: 0.86085398 +/- 0.00534285 (0.62%) (init = 0.8780667) a: 1.69791467 +/- 0.15515893 (9.14%) (init = 1) vmax: 0.28159258 +/- 0.01082300 (3.84%) (init = 0.2) km: 0.04761797 +/- 0.01094650 (22.99%) (init = 0.05) b: 0.09725106 +/- 0.00436845 (4.49%) (init = 0.1) [[Correlations]] (unreported correlations are < 0.100) C(vmax, km) = 0.947 C(a, vmax) = -0.895 C(a, km) = -0.743 C(s0, b) = -0.736 C(km, b) = -0.638 C(vmax, b) = -0.504 C(a, b) = 0.333 C(s0, km) = 0.312 C(s0, a) = 0.211 C(s0, vmax) = 0.122
BSD-2-Clause
Model_Stephan_pH7.ipynb
HannahDi/EnzymeML_KineticModeling
Hyper-parameter tuning **Learning Objectives**1. Understand various approaches to hyperparameter tuning2. Automate hyperparameter tuning using AI Platform HyperTune IntroductionIn the previous notebook we achieved an RMSE of **4.13**. Let's see if we can improve upon that by tuning our hyperparameters.Hyperparameters are parameters that are set *prior* to training a model, as opposed to parameters which are learned *during* training. These include learning rate and batch size, but also model design parameters such as type of activation function and number of hidden units.Here are the four most common ways to finding the ideal hyperparameters:1. Manual2. Grid Search3. Random Search4. Bayesian Optimzation**1. Manual**Traditionally, hyperparameter tuning is a manual trial and error process. A data scientist has some intution about suitable hyperparameters which they use as a starting point, then they observe the result and use that information to try a new set of hyperparameters to try to beat the existing performance. Pros- Educational, builds up your intuition as a data scientist- Inexpensive because only one trial is conducted at a timeCons- Requires alot of time and patience**2. Grid Search**On the other extreme we can use grid search. Define a discrete set of values to try for each hyperparameter then try every possible combination. Pros- Can run hundreds of trials in parallel using the cloud- Gauranteed to find the best solution within the search spaceCons- Expensive**3. Random Search**Alternatively define a range for each hyperparamter (e.g. 0-256) and sample uniformly at random from that range. Pros- Can run hundreds of trials in parallel using the cloud- Requires less trials than Grid Search to find a good solutionCons- Expensive (but less so than Grid Search)**4. Bayesian Optimization**Unlike Grid Search and Random Search, Bayesian Optimization takes into account information from past trials to select parameters for future trials. The details of how this is done is beyond the scope of this notebook, but if you're interested you can read how it works here [here](https://cloud.google.com/blog/products/gcp/hyperparameter-tuning-cloud-machine-learning-engine-using-bayesian-optimization). Pros- Picks values intelligenty based on results from past trials- Less expensive because requires fewer trials to get a good resultCons- Requires sequential trials for best results, takes longer**AI Platform HyperTune**AI Platform HyperTune, powered by [Google Vizier](https://ai.google/research/pubs/pub46180), uses Bayesian Optimization by default, but [also supports](https://cloud.google.com/ml-engine/docs/tensorflow/hyperparameter-tuning-overviewsearch_algorithms) Grid Search and Random Search. When tuning just a few hyperparameters (say less than 4), Grid Search and Random Search work well, but when tunining several hyperparameters and the search space is large Bayesian Optimization is best.
# Ensure that we have Tensorflow 1.13 installed. !pip3 freeze | grep tensorflow==1.13.1 || pip3 install tensorflow==1.13.1 PROJECT = "qwiklabs-gcp-636667ae83e902b6" # Replace with your PROJECT BUCKET = "qwiklabs-gcp-636667ae83e902b6_al" # Replace with your BUCKET REGION = "us-east1" # Choose an available region for AI Platform TFVERSION = "1.13" # TF version for AI Platform import os os.environ["PROJECT"] = PROJECT os.environ["BUCKET"] = BUCKET os.environ["REGION"] = REGION os.environ["TFVERSION"] = TFVERSION
_____no_output_____
Apache-2.0
courses/machine_learning/deepdive/03_model_performance/labs/d_hyperparameter_tuning.ipynb
aleistra/training-data-analyst
Move code into python packageLet's package our updated code with feature engineering so it's AI Platform compatible.
%%bash mkdir taxifaremodel touch taxifaremodel/__init__.py
mkdir: cannot create directory ‘taxifaremodel’: File exists
Apache-2.0
courses/machine_learning/deepdive/03_model_performance/labs/d_hyperparameter_tuning.ipynb
aleistra/training-data-analyst
Create model.pyNote that any hyperparameters we want to tune need to be exposed as command line arguments. In particular note that the number of hidden units is now a parameter.
%%writefile taxifaremodel/model.py import tensorflow as tf import numpy as np import shutil print(tf.__version__) #1. Train and Evaluate Input Functions CSV_COLUMN_NAMES = ["fare_amount","dayofweek","hourofday","pickuplon","pickuplat","dropofflon","dropofflat"] CSV_DEFAULTS = [[0.0],[1],[0],[-74.0],[40.0],[-74.0],[40.7]] def read_dataset(csv_path): def _parse_row(row): # Decode the CSV row into list of TF tensors fields = tf.decode_csv(records = row, record_defaults = CSV_DEFAULTS) # Pack the result into a dictionary features = dict(zip(CSV_COLUMN_NAMES, fields)) # NEW: Add engineered features features = add_engineered_features(features) # Separate the label from the features label = features.pop("fare_amount") # remove label from features and store return features, label # Create a dataset containing the text lines. dataset = tf.data.Dataset.list_files(file_pattern = csv_path) # (i.e. data_file_*.csv) dataset = dataset.flat_map(map_func = lambda filename:tf.data.TextLineDataset(filenames = filename).skip(count = 1)) # Parse each CSV row into correct (features,label) format for Estimator API dataset = dataset.map(map_func = _parse_row) return dataset def train_input_fn(csv_path, batch_size = 128): #1. Convert CSV into tf.data.Dataset with (features,label) format dataset = read_dataset(csv_path) #2. Shuffle, repeat, and batch the examples. dataset = dataset.shuffle(buffer_size = 1000).repeat(count = None).batch(batch_size = batch_size) return dataset def eval_input_fn(csv_path, batch_size = 128): #1. Convert CSV into tf.data.Dataset with (features,label) format dataset = read_dataset(csv_path) #2.Batch the examples. dataset = dataset.batch(batch_size = batch_size) return dataset vocab = {} vocab['dayofweek'] = [i for i in range(7)] vocab['hourofday'] = [i for i in range(24)] # 1. One hot encode dayofweek and hourofday fc_dayofweek = tf.feature_column.indicator_column(tf.feature_column.categorical_column_with_vocabulary_list(key='dayofweek',vocabulary_list=vocab['dayofweek'])) fc_hourofday = tf.feature_column.indicator_column(tf.feature_column.categorical_column_with_vocabulary_list(key='hourofday', vocabulary_list=vocab['hourofday'])) # 2. Bucketize latitudes and longitude NBUCKETS = 16 latbuckets = np.linspace(start = 38.0, stop = 42.0, num = NBUCKETS).tolist() lonbuckets = np.linspace(start = -76.0, stop = -72.0, num = NBUCKETS).tolist() fc_bucketized_plat = tf.feature_column.bucketized_column(source_column = tf.feature_column.numeric_column('pickuplat'), boundaries = latbuckets) fc_bucketized_plon = tf.feature_column.bucketized_column(source_column = tf.feature_column.numeric_column('dropofflat'), boundaries = latbuckets) fc_bucketized_dlat = tf.feature_column.bucketized_column(source_column = tf.feature_column.numeric_column('pickuplon'), boundaries = lonbuckets) fc_bucketized_dlon = tf.feature_column.bucketized_column(source_column = tf.feature_column.numeric_column('dropofflon'), boundaries = lonbuckets) signedbuckets = [-5,0,5] fc_northsouth = tf.feature_column.bucketized_column(source_column = tf.feature_column.numeric_column(key='latdiff'), boundaries = signedbuckets) fc_eastwest = tf.feature_column.bucketized_column(source_column = tf.feature_column.numeric_column(key='londiff'), boundaries = signedbuckets) # 3. Cross features to get combination of day and hour fc_crossed_day_hr = tf.feature_column.indicator_column(tf.feature_column.crossed_column(keys=['dayofweek', 'hourofday'], hash_bucket_size=len(vocab['dayofweek'] * len(vocab['hourofday'])))) fc_crossed_ns_day_hr = tf.feature_column.indicator_column(tf.feature_column.crossed_column(keys=['fc_crossed_day_hr', 'fc_northsouth'], hash_bucket_size=len(vocab['dayofweek'] * len(vocab['hourofday']) * 2))) fc_crossed_ew_day_hr = tf.feature_column.indicator_column(tf.feature_column.crossed_column(keys=['fc_crossed_day_hr', 'fc_eastwest'], hash_bucket_size=len(vocab['dayofweek'] * len(vocab['hourofday']) * 2))) def add_engineered_features(features): features["dayofweek"] = features["dayofweek"] - 1 # subtract one since our days of week are 1-7 instead of 0-6 features["latdiff"] = features["pickuplat"] - features["dropofflat"] # East/West features["londiff"] = features["pickuplon"] - features["dropofflon"] # North/South features["euclidean_dist"] = tf.sqrt(features["latdiff"]**2 + features["londiff"]**2) return features feature_cols = [ fc_dayofweek, fc_hourofday, fc_bucketized_plat, fc_bucketized_plon, fc_bucketized_dlat, fc_bucketized_dlon, fc_crossed_day_hr, fc_northsouth, fc_eastwest, tf.feature_column.numeric_column(key='latdiff'), tf.feature_column.numeric_column(key='londiff'), tf.feature_column.numeric_column(key='euclidean_dist') ] #3. Serving Input Receiver Function def serving_input_receiver_fn(): receiver_tensors = { 'dayofweek' : tf.placeholder(dtype = tf.int32, shape = [None]), # shape is vector to allow batch of requests 'hourofday' : tf.placeholder(dtype = tf.int32, shape = [None]), 'pickuplon' : tf.placeholder(dtype = tf.float32, shape = [None]), 'pickuplat' : tf.placeholder(dtype = tf.float32, shape = [None]), 'dropofflat' : tf.placeholder(dtype = tf.float32, shape = [None]), 'dropofflon' : tf.placeholder(dtype = tf.float32, shape = [None]), } features = add_engineered_features(receiver_tensors) # 'features' is what is passed on to the model return tf.estimator.export.ServingInputReceiver(features = features, receiver_tensors = receiver_tensors) #4. Train and Evaluate def train_and_evaluate(params): OUTDIR = params["output_dir"] model = tf.estimator.DNNRegressor( hidden_units = params["hidden_units"].split(","), # NEW: paramaterize architecture feature_columns = feature_cols, model_dir = OUTDIR, config = tf.estimator.RunConfig( tf_random_seed = 1, # for reproducibility save_checkpoints_steps = max(100, params["train_steps"] // 10) # checkpoint every N steps ) ) # Add custom evaluation metric def my_rmse(labels, predictions): pred_values = tf.squeeze(input = predictions["predictions"], axis = -1) return {"rmse": tf.metrics.root_mean_squared_error(labels = labels, predictions = pred_values)} model = tf.contrib.estimator.add_metrics(model, my_rmse) train_spec = tf.estimator.TrainSpec( input_fn = lambda: train_input_fn(params["train_data_path"]), max_steps = params["train_steps"]) exporter = tf.estimator.BestExporter(name = "exporter", serving_input_receiver_fn = serving_input_receiver_fn) # export SavedModel once at the end of training # Note: alternatively use tf.estimator.BestExporter to export at every checkpoint that has lower loss than the previous checkpoint eval_spec = tf.estimator.EvalSpec( input_fn = lambda: eval_input_fn(params["eval_data_path"]), steps = None, start_delay_secs = 1, # wait at least N seconds before first evaluation (default 120) throttle_secs = 1, # wait at least N seconds before each subsequent evaluation (default 600) exporters = exporter) # export SavedModel once at the end of training tf.logging.set_verbosity(v = tf.logging.INFO) # so loss is printed during training shutil.rmtree(path = OUTDIR, ignore_errors = True) # start fresh each time tf.estimator.train_and_evaluate(model, train_spec, eval_spec)
Overwriting taxifaremodel/model.py
Apache-2.0
courses/machine_learning/deepdive/03_model_performance/labs/d_hyperparameter_tuning.ipynb
aleistra/training-data-analyst
Create task.py **Exercise 1**The code cell below has two TODOs for you to complete. Firstly, in model.py above we set the number of hidden units in our model to be a hyperparameter. This means `hidden_units` must be exposed as a command line argument when we submit our training job to Cloud ML Engine. Modify the code below to add an flag for `hidden_units`. Be sure to include a description for the `help` field and specify the data `type` that the model should expect to receive. You can also include a `default` value. Look to the other parser arguments to make sure you have the formatting corret. Second, when doing hyperparameter tuning we need to make sure the output directory is different for each run, otherwise successive runs will overwrite previous runs. In `task.py` below, add some code to append the trial_id to the output direcroty of the training job. **Hint**: You can use `json.loads(os.environ.get('TF_CONFIG', '{}')).get('task', {}).get('trial', '')` to extract the trial id of the training job. You will want to append this quanity to the output directory `args['output_dir']` to make sure the output directory is different for each run.
%%writefile taxifaremodel/task.py import argparse import json import os from . import model if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument( "--hidden_units", help = "Hidden layer sizes to use for DNN feature columns -- provide space-separated layers", type = str, default = "10,10" ) parser.add_argument( "--train_data_path", help = "GCS or local path to training data", required = True ) parser.add_argument( "--train_steps", help = "Steps to run the training job for (default: 1000)", type = int, default = 1000 ) parser.add_argument( "--eval_data_path", help = "GCS or local path to evaluation data", required = True ) parser.add_argument( "--output_dir", help = "GCS location to write checkpoints and export models", required = True ) parser.add_argument( "--job-dir", help="This is not used by our model, but it is required by gcloud", ) args = parser.parse_args().__dict__ # Append trial_id to path so trials don"t overwrite each other args["output_dir"] = os.path.join( args["output_dir"], json.loads( os.environ.get("TF_CONFIG", "{}") ).get("task", {}).get("trial", "") ) # Run the training job model.train_and_evaluate(args)
Overwriting taxifaremodel/task.py
Apache-2.0
courses/machine_learning/deepdive/03_model_performance/labs/d_hyperparameter_tuning.ipynb
aleistra/training-data-analyst
Create hypertuning configuration We specify:1. How many trials to run (`maxTrials`) and how many of those trials can be run in parrallel (`maxParallelTrials`) 2. Which algorithm to use (in this case `GRID_SEARCH`)3. Which metric to optimize (`hyperparameterMetricTag`)4. The search region in which to constrain the hyperparameter searchFull specification options [here](https://cloud.google.com/ml-engine/reference/rest/v1/projects.jobsHyperparameterSpec).Here we are just tuning one parameter, the number of hidden units, and we'll run all trials in parrallel. However more commonly you would tune multiple hyperparameters. **Exercise 2**Add some additional hidden units to the `hyperparam.yaml` file below to potetially explore during the hyperparameter job.
%%writefile hyperparam.yaml trainingInput: scaleTier: BASIC hyperparameters: goal: MINIMIZE maxTrials: 5 maxParallelTrials: 5 hyperparameterMetricTag: rmse enableTrialEarlyStopping: True algorithm: GRID_SEARCH params: - parameterName: hidden_units type: CATEGORICAL categoricalValues: - 10,10 - 64,32 - 128,64,32 - 32, 32 - 128, 64, 64
Overwriting hyperparam.yaml
Apache-2.0
courses/machine_learning/deepdive/03_model_performance/labs/d_hyperparameter_tuning.ipynb
aleistra/training-data-analyst
Run the training job|Same as before with the addition of `--config=hyperpam.yaml` to reference the file we just created.This will take about 20 minutes. Go to [cloud console](https://console.cloud.google.com/mlengine/jobs) and click on the job id. Once the job is completed, the choosen hyperparameters and resulting objective value (RMSE in this case) will be shown. Trials will sorted from best to worst. **Exercise 3**Submit a hyperparameter tuning job to the cloud. Fill in the missing arguments below. This is similar to the exercise you completed in the `02_tensorlfow/g_distributed` notebook. Note that one difference here is that we now specify a `config` parameter giving the location of our .yaml file.
OUTDIR="gs://{}/taxifare/trained_hp_tune".format(BUCKET) !gsutil -m rm -rf {OUTDIR} # start fresh each time !gcloud ai-platform jobs submit training taxifare_$(date -u +%y%m%d_%H%M%S) \ --package-path=taxifaremodel \ --module-name=taxifaremodel.task \ --config=hyperparam.yaml \ --job-dir=gs://{BUCKET}/taxifare \ --python-version=3.5 \ --runtime-version={TFVERSION} \ --region={REGION} \ -- \ --train_data_path=gs://{BUCKET}/taxifare/smallinput/taxi-train.csv \ --eval_data_path=gs://{BUCKET}/taxifare/smallinput/taxi-valid.csv \ --train_steps=5000 \ --output_dir={OUTDIR}
Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/#1563484245754874... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/events.out.tfevents.1563484194.cmle-training-731225091109210751#1563484432093881... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/#1563484245617656... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/#1563484179915317... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484290/saved_model.pb#1563484296416930... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/eval/#1563484221723731... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484244/variables/#1563484250562059... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484244/#1563484250271431... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/#1563484422198624... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/checkpoint#1563484424012789... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484244/variables/variables.data-00000-of-00002#1563484250704999... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484290/variables/variables.data-00001-of-00002#1563484296817040... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/eval/events.out.tfevents.1563484221.cmle-training-731225091109210751#1563484431813894... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484290/variables/#1563484296549505... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484244/variables/variables.data-00001-of-00002#1563484250850781... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484244/saved_model.pb#1563484250419358... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484290/variables/variables.data-00000-of-00002#1563484296673502... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484290/#1563484296264391... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484244/variables/variables.index#1563484250974705... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484290/variables/variables.index#1563484296948921... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484337/#1563484342693000... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484337/saved_model.pb#1563484342830504... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484337/variables/#1563484342983018... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484337/variables/variables.data-00000-of-00002#1563484343137269... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484337/variables/variables.data-00001-of-00002#1563484343290159... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484337/variables/variables.index#1563484343427043... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484383/#1563484388730588... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484383/saved_model.pb#1563484388882431... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484383/variables/#1563484389007300... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484383/variables/variables.data-00000-of-00002#1563484389169653... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484383/variables/variables.data-00001-of-00002#1563484389324151... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/export/exporter/1563484383/variables/variables.index#1563484389473891... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/graph.pbtxt#1563484196248726... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-3000.data-00000-of-00002#1563484328963452... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-3000.data-00001-of-00002#1563484328757555... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-3000.index#1563484329225429... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-3000.meta#1563484330801327... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-3500.data-00000-of-00002#1563484355145739... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-3500.data-00001-of-00002#1563484354914714... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-3500.index#1563484355346835... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-3500.meta#1563484356828161... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-4000.data-00000-of-00002#1563484374974893... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-4000.data-00001-of-00002#1563484374746083... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-4000.index#1563484375251856... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-4000.meta#1563484376821830... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-4500.data-00000-of-00002#1563484402466437... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-4500.data-00001-of-00002#1563484402221124... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-4500.index#1563484402697125... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-4500.meta#1563484404434046... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-5000.data-00000-of-00002#1563484423028688... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-5000.data-00001-of-00002#1563484422803063... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-5000.index#1563484423277025... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/1/model.ckpt-5000.meta#1563484425034903... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/checkpoint#1563484376190690... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/#1563484374709066... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/eval/events.out.tfevents.1563484205.cmle-training-12929692639216599982#1563484383348464... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/eval/#1563484205043343... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/#1563484244248422... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/events.out.tfevents.1563484180.cmle-training-12929692639216599982#1563484383566118... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/1563484243/#1563484248744457... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/#1563484244398170... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/1563484243/saved_model.pb#1563484248874194... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/1563484243/variables/#1563484249225632... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/1563484243/variables/variables.data-00000-of-00002#1563484249358059... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/1563484243/variables/variables.data-00001-of-00002#1563484249489227... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/1563484243/variables/variables.index#1563484249621916... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/1563484301/#1563484306419668... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/1563484301/saved_model.pb#1563484306552630... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/1563484301/variables/#1563484306733064... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/1563484301/variables/variables.data-00000-of-00002#1563484306867567... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/1563484301/variables/variables.data-00001-of-00002#1563484306999553... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/1563484343/saved_model.pb#1563484347695150... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/1563484301/variables/variables.index#1563484307113467... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/1563484343/variables/#1563484347801417... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/1563484343/#1563484347589201... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/1563484343/variables/variables.data-00000-of-00002#1563484347918820... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/graph.pbtxt#1563484181689138... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/1563484343/variables/variables.index#1563484348145772... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/export/exporter/1563484343/variables/variables.data-00001-of-00002#1563484348029085... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-3000.data-00000-of-00002#1563484293360998... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-3000.data-00001-of-00002#1563484292885587... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-3000.index#1563484293553194... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-3000.meta#1563484295070316... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-3500.data-00000-of-00002#1563484317673600... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-3500.data-00001-of-00002#1563484317473259... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-3500.index#1563484317872837... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-3500.meta#1563484319347611... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-4000.data-00000-of-00002#1563484335095991... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-4000.data-00001-of-00002#1563484334912284... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-4000.index#1563484335312197... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-4000.meta#1563484336753565... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-4500.data-00000-of-00002#1563484358453052... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-4500.data-00001-of-00002#1563484358268625... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-4500.meta#1563484359941574... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-4500.index#1563484358640561... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-5000.meta#1563484377023540... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-5000.index#1563484375638095... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-5000.data-00000-of-00002#1563484375432522... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/2/model.ckpt-5000.data-00001-of-00002#1563484375235121... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/#1563484375644467... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/checkpoint#1563484381097479... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/eval/#1563484206049622... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/eval/events.out.tfevents.1563484206.cmle-training-10262658521264896257#1563484388064133... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/events.out.tfevents.1563484180.cmle-training-10262658521264896257#1563484388315477... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/#1563484224902536... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/#1563484225061414... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484224/#1563484229273832... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484224/saved_model.pb#1563484229407734... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484224/variables/#1563484229550094... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484224/variables/variables.data-00000-of-00002#1563484229673343... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484224/variables/variables.data-00001-of-00002#1563484229817562... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484224/variables/variables.index#1563484229958661... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484247/#1563484251529202... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484247/saved_model.pb#1563484251657075... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484247/variables/#1563484251824353... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484247/variables/variables.data-00000-of-00002#1563484251973306... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484247/variables/variables.data-00001-of-00002#1563484252116431... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484247/variables/variables.index#1563484252242940... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484304/#1563484309303863... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484304/saved_model.pb#1563484309421396... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484304/variables/#1563484309548087... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484304/variables/variables.data-00000-of-00002#1563484309705354... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484304/variables/variables.data-00001-of-00002#1563484309827817... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484304/variables/variables.index#1563484309951448... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484344/#1563484349303991... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484344/saved_model.pb#1563484349414154... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484344/variables/#1563484349531037... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484344/variables/variables.data-00000-of-00002#1563484349645873... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484344/variables/variables.data-00001-of-00002#1563484349762609... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/export/exporter/1563484344/variables/variables.index#1563484349872497... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/graph.pbtxt#1563484183000844... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-3000.data-00000-of-00002#1563484296819223... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-3000.data-00001-of-00002#1563484296619230... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-3000.index#1563484297045905... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-3000.meta#1563484298443644... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-3500.data-00000-of-00002#1563484319923050... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-3500.data-00001-of-00002#1563484319724037... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-3500.meta#1563484321650722... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-3500.index#1563484320116550... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-4000.data-00000-of-00002#1563484337253547... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-4000.data-00001-of-00002#1563484337047406... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-4000.index#1563484337452247... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-4000.meta#1563484338850438... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-4500.data-00000-of-00002#1563484359302567... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-4500.data-00001-of-00002#1563484359132401... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-4500.index#1563484359484027... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-4500.meta#1563484360914944... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-5000.data-00000-of-00002#1563484380305813... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-5000.data-00001-of-00002#1563484376120536... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-5000.index#1563484380499366... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/3/model.ckpt-5000.meta#1563484382011616... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/#1563484416761122... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/checkpoint#1563484418329507... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/eval/#1563484241256373... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/eval/events.out.tfevents.1563484241.cmle-training-289151322071742182#1563484425230069... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/events.out.tfevents.1563484216.cmle-training-289151322071742182#1563484425447502... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/#1563484259707294... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/#1563484259837765... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484259/#1563484263893456... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484259/saved_model.pb#1563484264027996... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484259/variables/#1563484264142150... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484259/variables/variables.data-00000-of-00002#1563484264261719... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484259/variables/variables.index#1563484264497546... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484259/variables/variables.data-00001-of-00002#1563484264375700... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484281/#1563484286224229... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484281/saved_model.pb#1563484286340310... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484281/variables/#1563484286461425... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484281/variables/variables.data-00000-of-00002#1563484286580450... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484281/variables/variables.data-00001-of-00002#1563484286717986... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484281/variables/variables.index#1563484286845410... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484336/#1563484341015992... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484336/variables/#1563484341229010... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484336/variables/variables.data-00000-of-00002#1563484341339228... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484336/saved_model.pb#1563484341114302... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484336/variables/variables.data-00001-of-00002#1563484341462306... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484385/saved_model.pb#1563484390458842... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484336/variables/variables.index#1563484341574705... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484385/variables/#1563484390580196... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484385/#1563484390344098... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484385/variables/variables.data-00000-of-00002#1563484390708772... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484385/variables/variables.data-00001-of-00002#1563484390937401... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/export/exporter/1563484385/variables/variables.index#1563484391077987... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/graph.pbtxt#1563484218621545... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-3000.data-00000-of-00002#1563484329147911... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-3000.data-00001-of-00002#1563484328963816... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-3000.index#1563484329346558... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-3000.meta#1563484330624636... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-3500.data-00000-of-00002#1563484352714406... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-3500.data-00001-of-00002#1563484352540190... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-3500.index#1563484352917577... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-4000.data-00000-of-00002#1563484376649419... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-4000.data-00001-of-00002#1563484376451643... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-3500.meta#1563484354223608... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-4000.index#1563484376821363... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-4000.meta#1563484378128577... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-4500.data-00000-of-00002#1563484400152487... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-4500.data-00001-of-00002#1563484399861016... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-4500.index#1563484400336409... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-5000.data-00000-of-00002#1563484417563406... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-4500.meta#1563484401765724... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-5000.data-00001-of-00002#1563484417342324... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-5000.index#1563484417784237... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/4/model.ckpt-5000.meta#1563484419112226... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/#1563484409924817... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/checkpoint#1563484411449108... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/eval/#1563484227258939... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/eval/events.out.tfevents.1563484227.cmle-training-3856349254539048287#1563484424346296... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/events.out.tfevents.1563484201.cmle-training-3856349254539048287#1563484424551849... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/#1563484247171469... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/#1563484247287596... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484246/#1563484251346528... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484246/saved_model.pb#1563484251476014... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484246/variables/variables.data-00000-of-00002#1563484251712054... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484246/variables/variables.data-00001-of-00002#1563484251817583... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484246/variables/#1563484251600701... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484270/#1563484274603991... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484246/variables/variables.index#1563484251923209... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484270/saved_model.pb#1563484274717488... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484270/variables/#1563484274827785... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484270/variables/variables.data-00000-of-00002#1563484274950999... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484270/variables/variables.data-00001-of-00002#1563484275062028... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484270/variables/variables.index#1563484275176893... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484330/#1563484335772288... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484330/saved_model.pb#1563484335884018... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484330/variables/#1563484336013128... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484330/variables/variables.data-00000-of-00002#1563484336123803... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484330/variables/variables.data-00001-of-00002#1563484336255692... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484330/variables/variables.index#1563484336370990... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484376/#1563484381085274... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484376/saved_model.pb#1563484381214917... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484376/variables/variables.data-00001-of-00002#1563484381562765... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484376/variables/variables.data-00000-of-00002#1563484381443357... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/graph.pbtxt#1563484203137946... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484376/variables/#1563484381332974... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/export/exporter/1563484376/variables/variables.index#1563484381681337... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-3000.data-00000-of-00002#1563484322570048... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-3000.data-00001-of-00002#1563484322377733... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-3000.index#1563484322812373... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-3000.meta#1563484324176992... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-3500.data-00000-of-00002#1563484347151078... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-3500.data-00001-of-00002#1563484346965836... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-3500.index#1563484347363555... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-3500.meta#1563484348801156... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-4000.data-00000-of-00002#1563484368234852... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-4000.data-00001-of-00002#1563484368045553... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-4000.index#1563484368448018... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-4000.meta#1563484369920700... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-4500.data-00000-of-00002#1563484392172924... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-4500.data-00001-of-00002#1563484391925249... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-4500.meta#1563484393841966... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-4500.index#1563484392359867... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-5000.data-00000-of-00002#1563484410708980... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-5000.data-00001-of-00002#1563484410498595... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-5000.index#1563484410899374... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_hp_tune/5/model.ckpt-5000.meta#1563484412386035... / [255/255 objects] 100% Done Operation completed over 255 objects. Job [taxifare_190719_131105] submitted successfully. Your job is still active. You may view the status of your job with the command $ gcloud ai-platform jobs describe taxifare_190719_131105 or continue streaming the logs with the command $ gcloud ai-platform jobs stream-logs taxifare_190719_131105 jobId: taxifare_190719_131105 state: QUEUED
Apache-2.0
courses/machine_learning/deepdive/03_model_performance/labs/d_hyperparameter_tuning.ipynb
aleistra/training-data-analyst
ResultsThe best result is RMSE **4.02** with hidden units = 128,64,32. This improvement is modest, but now that we have our hidden units tuned let's run on our larger dataset to see if it helps. Note the passing of hyperparameter values via command line
OUTDIR="gs://{}/taxifare/trained_large_tuned".format(BUCKET) !gsutil -m rm -rf {OUTDIR} # start fresh each time !gcloud ai-platform jobs submit training taxifare_large_$(date -u +%y%m%d_%H%M%S) \ --package-path=taxifaremodel \ --module-name=taxifaremodel.task \ --job-dir=gs://{BUCKET}/taxifare \ --python-version=3.5 \ --runtime-version={TFVERSION} \ --region={REGION} \ --scale-tier=STANDARD_1 \ -- \ --train_data_path=gs://cloud-training-demos/taxifare/large/taxi-train*.csv \ --eval_data_path=gs://cloud-training-demos/taxifare/small/taxi-valid.csv \ --train_steps=200000 \ --output_dir={OUTDIR} \ --hidden_units="128,64,32"
Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/events.out.tfevents.1563484096.cmle-training-worker-285c128a20-0-kn9fp#1563485144189527... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/#1563485147333149... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/checkpoint#1563485150259049... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/#1563484319658283... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484528/variables/variables.data-00001-of-00002#1563484533435217... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/eval/events.out.tfevents.1563484217.cmle-training-master-285c128a20-0-2dgkd#1563485157570746... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484528/saved_model.pb#1563484532962349... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/eval/#1563484217291417... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/#1563484319800217... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484528/#1563484532833287... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484633/variables/#1563484638677121... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484528/variables/#1563484533113828... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/events.out.tfevents.1563484088.cmle-training-master-285c128a20-0-2dgkd#1563485044376692... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484633/saved_model.pb#1563484638544776... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484528/variables/variables.data-00000-of-00002#1563484533280453... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484528/variables/variables.index#1563484533564832... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484633/variables/variables.data-00000-of-00002#1563484638818566... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484633/variables/variables.data-00001-of-00002#1563484638949000... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484633/#1563484638417564... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484633/variables/variables.index#1563484639075867... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484736/#1563484741600907... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484736/saved_model.pb#1563484741745627... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484736/variables/#1563484741900597... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484736/variables/variables.data-00000-of-00002#1563484742036030... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484736/variables/variables.data-00001-of-00002#1563484742206744... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484736/variables/variables.index#1563484742343418... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484944/#1563484949505093... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484944/saved_model.pb#1563484949635794... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484944/variables/#1563484949772566... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484944/variables/variables.data-00000-of-00002#1563484949898220... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484944/variables/variables.data-00001-of-00002#1563484950094040... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563484944/variables/variables.index#1563484950271958... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563485051/#1563485056430632... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563485051/saved_model.pb#1563485056579291... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563485051/variables/#1563485056740246... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563485051/variables/variables.data-00000-of-00002#1563485056895302... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563485051/variables/variables.data-00001-of-00002#1563485057059242... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/export/exporter/1563485051/variables/variables.index#1563485057200913... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/graph.pbtxt#1563484090289612... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-120019.data-00000-of-00004#1563484728297956... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-120019.data-00001-of-00004#1563484728070330... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-120019.data-00002-of-00004#1563484727832446... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-120019.data-00003-of-00004#1563484727553393... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-120019.index#1563484728571392... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-120019.meta#1563484730474803... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-140022.data-00000-of-00004#1563484833349939... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-140022.data-00001-of-00004#1563484833133161... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-140022.data-00003-of-00004#1563484832548890... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-140022.data-00002-of-00004#1563484832896755... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-140022.index#1563484833598846... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-140022.meta#1563484835653301... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-160026.data-00000-of-00004#1563484936109525... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-160026.data-00001-of-00004#1563484935865504... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-160026.data-00002-of-00004#1563484935569969... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-160026.data-00003-of-00004#1563484935335460... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-160026.index#1563484936319481... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-160026.meta#1563484938500074... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-180032.data-00000-of-00004#1563485041773066... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-180032.data-00001-of-00004#1563485041524787... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-180032.data-00002-of-00004#1563485041274981... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-180032.data-00003-of-00004#1563485041035713... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-180032.index#1563485041983049... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-180032.meta#1563485044118660... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-200003.data-00000-of-00004#1563485149182394... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-200003.data-00001-of-00004#1563485148939219... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-200003.data-00002-of-00004#1563485148718153... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-200003.data-00003-of-00004#1563485148460511... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-200003.index#1563485149403992... Removing gs://qwiklabs-gcp-636667ae83e902b6_al/taxifare/trained_large_tuned/model.ckpt-200003.meta#1563485151296972... / [69/69 objects] 100% Done Operation completed over 69 objects. Job [taxifare_large_190719_132300] submitted successfully. Your job is still active. You may view the status of your job with the command $ gcloud ai-platform jobs describe taxifare_large_190719_132300 or continue streaming the logs with the command $ gcloud ai-platform jobs stream-logs taxifare_large_190719_132300 jobId: taxifare_large_190719_132300 state: QUEUED
Apache-2.0
courses/machine_learning/deepdive/03_model_performance/labs/d_hyperparameter_tuning.ipynb
aleistra/training-data-analyst
An Introduction to *Python*Let us begin by checking the version of our Python interpreter.
import sys sys.version
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
This notebook gives a short introduction to *Python*. We will start with the basics but as the **main goal** of this introduction is to show how *Python* supports *sets* we will quickly move to more advanced topics.In order to show off the features of *Python* we will give some examples that are not fully explained at the point where we introduce them. However, rest assured that these features will be explained eventually. Evaluating expressionsAs Python is an interactive language, expressions can be evaluated directly. In a *Jupyter* notebook we just have to type Ctrl-Enter in the cell containing the expression. Insteadof Ctrl-Enter we can also use Shift-Enter.
1 + 2
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
In *Python*, the precision of integers is not bounded. Hence, the following expression does **not** causean integer overflow.
1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10 * 11 * 12 * 13 * 14 * 15 * 16 * 17 * 18 * 19 * 20 * 21 * 22 * 23 * 24 * 25
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The next *cell* in this notebook shows how to compute the *factorial* of 1000, i.e. it shows how to compute the product$$ 1000! = 1 \cdot 2 \cdot 3 \cdot {\dots} \cdot 998 \cdot 999 \cdot 1000 $$It uses some advanced features from *functional programming* that will be discussed later.
import functools functools.reduce(lambda x, y: (x*y), range(1, 1000+1))
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The following command will stop the interpreter if executed. It is not useful inside a *Jupyter* notebook. Hence, the next line should not be evaluated. However, if you evaluate the following line, nothing bad will happen as the interpreter is just restarted by *Jupyter*.
exit()
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
In order to write something to the screen, we can use the function print. This function can print objects of any type. In the following example, this function prints a string. In *Python* any character sequence enclosed in single quotes is string.
print('Hello, World!')
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The last expression in every notebook cell is automatically printed.
'Hello, World!'
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
If we want to supress the last expression from being printed, we can end the expression with a semicolon:
'Hello, World!';
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Instead of using single quotes we can also use double quotes as seen in the next example. However, the convention is to use single quotes, unless the string itself contains a single quote.
"Hello, World!"
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The function print accepts any number of arguments. For example, to print the string "36 * 37 / 2 = " followed by the value of the expression $36 \cdot 37 / 2$ we can use the following print statement:
print('36 * 37 / 2 =', 36 * 37 // 2)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
In the expression "36 \* 37 // 2" we have used the operator "//" in order to enforce *integer division*. If we had used the operator "/" instead, *Python* would have used *floating point division* and therefore it would have printed the floating point number 666.0 instead of the integer 666.
print('36 * 37 / 2 =', 36 * 37 / 2) 5 // 3, 5 % 3 range(1, 9+1) A = set(range(1, 9+1)) A
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The function `sum` can be used to some up all elements of a set (or a list).
sum(A)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The following script reads a natural number $n$ and computes the sum $\sum\limits_{i=1}^n i$. The function input prompts the user to enter a string. This string is then converted into an integer using the function int. Next, the set S is created such that $$\texttt{s} = \{1, \cdots, n\}. $$ The set S is constructed using the function range. A function call of the form $\texttt{range}(a, b + 1)$ returns a generator that produces the natural numbers starting from $a$ upto and including $b$. By using this generator as an argument to the function set, a set is created that contains all the natural number starting from $a$ upto and including $b$. The precise mechanics of generators will be explained later. The print statement uses the function sum to add up all the elements of the set s. The effect of the last argument sep='' is to prevent print from separating the previous arguments by spaces.
n = input('Type a natural number and press return: ') n = int(n) S = set(range(1, n+1)) print('The sum 1 + 2 + ... + ', n, ' is equal to ', sum(S), '.', sep='')
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
If we input $36$, which happens to be equal to $6^2$ above, then we discover the following remarkable identity:$$ \sum\limits_{i=1}^{6^2} i = 666. $$ The following example shows how *functions* can be defined in *Python*. The function $\texttt{sum}(n)$ is supposed to compute the sum of all the numbers in the set $\{1, \cdots, n\}$. Therefore, we have$$\texttt{sum}(n) = \sum\limits_{i=1}^n i. $$ The function sum is defined *recursively*. The recursive implementation of the function sum can best by understood if we observe that it satisfies the following two equations: $\texttt{sum}(0) = 0$, $\texttt{sum}(n) = \texttt{sum}(n-1) + n \quad$ provided that $n > 0$.The keyword def is used to signal that we define a function.
def sum(n): if n == 0: return 0 return sum(n-1) + n sum sum(3) def sum(n): print(f'calling sum({n})') if n == 0: print('sum(0) = 0') return 0 snm1 = sum(n-1) print(f'sum({n}) = sum({n-1}) + {n} = {snm1} + {n} = {snm1 + n}') return snm1 + n sum(3)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Let us discuss the implementation of the function sum line by line: The keyword def starts the definition of the function. It is followed by the name of the function that is defined. The name is followed by the list of the parameters of the function. This list is enclosed in parentheses. If there had been more than one parameter, the parameters would have been separated by commas. Finally, there needs to be a colon at the end of the first line. The body of the function is indented. Contrary to most other programming languages, Python is space sensitive. The first statement of the body is a conditional statement, which starts with the keyword if. The keyword is followed by a test. In this case we test whether the variable $n$ is equal to the number $0$. Note that this test is followed by a colon. The next line contains a return statement. Note that this statement is again indented. All statements indented by the same amount that follow an if-statement are considered as the body of the if-statement. In this case the body contains only a single statement. The print statement in the penultimate line contains a so called f-string. Expressions enclosed in curly braces are evaluated, the result is converted to a string and inserted back into the f-string. This behaviour is known as string interpolation. The last line of the function definition contains the recursive invocation of the function sum. Using the function sum, we can compute the sum $\sum\limits_{i=1}^n i$ as follows:
n = int(input("Enter a natural number: ")) total = sum(n) if n > 2: print("0 + 1 + 2 + ... + ", n, " = ", total, sep='') else: print(total)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Sets in *Python* *Python* supports sets as a **native** datatype. This is one of the reasons that have lead me to choose *Python* as the programming language for this course. To get a first impression how sets are handled in *Python*, let us define two simple sets $A$ and $B$ and print them:
A = {1, 2, 3} B = {2, 3, 4} print(f'A = {A}, B = {B}')
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
There is a caveat here, we cannot define the empty set using the expression {} since this expression creates the empty dictionary instead. (We will discuss the data type of *dictionaries* later.) To define the empty set $\emptyset$, we therefore have to use the following expression:
S = set() S
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Note that the empty set is also printed as set() in *Python* and not as {}. Next, let us compute the union $A \cup B$. This is done using the operator "|".
A | B
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
To compute the intersection $A \cap B$, we use the operator "&":
A & B
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The set difference $A \backslash B$ is computed using the operator "-":
A - B, B - A
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
It is easy to test whether $A$ is a subset of $B$, i.e. whether $A \subseteq B$ holds:
A <= B
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Testing whether an object $x$ is an element of a set $M$, i.e. to test whether $x \in M$ holds, is straightforward:
1 in A
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
On the other hand, the number $1$ is not an element of the set $B$, i.e. we have $1 \not\in B$:
1 not in B
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
It is important to know that sets are not ordered. The reason is that sets are implemented as hash tables. We discuss hash tables in the lecture on algorithms in the second semester.
print({-1,2,-3,4})
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
However, if a set is displayed by a **Jupyter notebook** without a print statement, the elements are sorted.
{-1,2,-3,4}
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Defining Sets via Selection and Images Remember how we can define subsets of a given set $M$ via the axiom of selection. If $p$ is a property such that for any object $x$ from the set $M$ the expression $p(x)$ is either True or False, the subset of all those elements of $M$ such that $p(x)$ is True can be defined as$$ \{ x \in M \mid p(x) \}. $$For example, if $M$ is the set $\{1, \cdots, 100\}$ and we want to compute the subset of this set that contains all numbers from $M$ that are divisible by $7$, then this set can be defined as$$ \{ x \in M \mid x \texttt{%} 7 = 0 \}. $$In *Python*, the definition of this set can be given as follows:
M = set(range(1, 100+1)) { x for x in M if x % 7 == 0 }
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
In general, in *Python* the set$$ \{ x \in M \mid p(x) \} $$is computed by the expression$$ \{\; x\; \texttt{for}\; x\; \texttt{in}\; M\; \texttt{if}\; p(x)\; \}. $$This is called a *set comprehension*.*Image* sets can be computed in a similar way. If $f$ is a function defined for all elements of a set $M$, the image set $$ \{ f(x) \mid x \in M \} $$can be computed in *Python* as follows:$$ \{\; f(x)\; \texttt{for}\; x\; \texttt{in}\; M\; \}. $$For example, the following expression computes the set of all squares of numbers from the set $\{1,\cdots,10\}$:
M = set(range(1,10+1)) { x*x for x in M }
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The computation of image sets and selections can be *combined.* If $M$ is a set, $p$ is a property such that $p(x)$ is either True or False for elements of $M$, and $f$ is a function such that $f(x)$ is defined for all $x \in M$ then we can compute set $$ \{ f(x) \mid x \in M \wedge p(x) \} $$of all images $f(x)$ from those $x\in M$ that satisfy the property $p(x)$ via the expression$$ \{\; f(x)\; \texttt{for}\; x\; \texttt{in}\; M\; \texttt{if}\; p(x)\; \}. $$For example, to compute the set of those squares of numbers from the set $\{1,\cdots,10\}$ that are even we can write
{ x*x for x in M if x % 2 == 0 }
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
We can iterate over more than one set. For example, let us define the set of all products $p \cdot q$ of numbers $p$ and $q$ from the set $\{2, \cdots, 10\}$, i.e. we intend to define the set$$ \bigl\{ p \cdot q \bigm| p \in \{2,\cdots,10\} \wedge q \in \{2,\cdots,10\} \bigr\}. $$In *Python*, this set is defined as follows:
{ p * q for p in range(2, 6+1) for q in range(2, 6+1) }
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
We can use this set to compute the set of *prime numbers*. After all, the set of prime numbers is the set of all those natural numbers bigger than $1$ that can not be written as a proper product, that is a number $x$ is *prime* if $x$ is bigger than $1$ and there are no natural numbers $p$ and $q$ both bigger than $1$ such that $x = p \cdot q$ holds.More formally, the set $\mathbb{P}$ of prime numbers is defined as follows:$$ \mathbb{P} = \Bigl\{ x \in \mathbb{N} \;\bigm|\; x > 1 \wedge \neg \exists p, q \in \mathbb{N}: \bigl(x = p \cdot q \wedge p > 1 \wedge q > 1\bigr)\Bigr\}. $$Hence the following code computes the set of all primes less than 100:
S = set(range(2, 100+1)) print(S - { p * q for p in S for q in S })
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
An alternative way to compute primes works by noting that a number $p$ is prime iff there is no number $t$ that is different from both $1$ and $p$ and, furthermore, divides the number $p$. The function `dividers` given below computes the set of all numbers dividing a given number $p$ evenly:
def dividers(p): ''' Compute the set of numbers that divide the number p. This is just an auxiliary function. ''' return { t for t in range(1, p+1) if p % t == 0 } dividers(20) n = 100 primes = { p for p in range(2, n) if dividers(p) == {1, p} } print(primes)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Computing the Power Set Unfortunately, there is no operator to compute the power set $2^M$ of a given set $M$. Since the power set is needed frequently, we have to implement a function power to compute this set ourselves. The easiest way to compute the power set $2^M$ of a set $M$ is to implement the following recursive equations: The power set of the empty set contains only the empty set: $$2^{\{\}} = \bigl\{\{\}\bigr\}$$ If a set $M$ can be written as $M = C \cup \{x\}$, where the element $x$ does not occur in the set $C$, then the power set $2^M$ consists of two sets: Firstly, all subsets of $C$ are also subsets of $M$. Secondly, if A is a subset of $C$, then the set $A \cup\{x\}$ is also a subset of $M$. If we combine these parts we get the following equation: $$2^{C \cup \{x\}} = 2^C \cup \bigl\{ A \cup \{x\} \bigm| A \in 2^C \bigr\}$$ But there is another problem: In Python we can't create a set that has elements that are sets themselves! The expression {{1,2}, {2,3}} raises an exception when evaluated! Instead, we have to use frozensets as shown below:
{{1,2}, {2,3}} {frozenset({1,2}), frozenset({2,3})}
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The reason we got the error when trying to evaluate the expression``` {{1,2}, {2,3}}``` is that in *Python* sets are implemented via *hash tables* and therefore the elements of a set need to be *hashable*. (The notion of a *hash table* will be discussed in more detail in the lecture on *Algorithms*.) However, sets are *mutable* and *mutable* objects are not *hashable*. Fortunately, there is aworkaround: *Python* provides the data type of *frozen sets*. These sets behave like sets but are are lacking certain function and hence are **immutable**. So if we use *frozen sets* as elements of the power set, we can compute the power set of a given set. The function power given below shows how this works.
def power(M): "This function computes the power set of the set M." if M == set(): return { frozenset() } else: C = set(M) # C is a copy of M as we don't want to change the set M x = C.pop() # pop removes some element x from the set C P1 = power(C) P2 = { A | {x} for A in P1 } return P1 | P2 power(A)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Let us print this in a more readable way. To this end we implement a function prettify that turns a set of frozensets into a string that looks like a set of sets.
def prettify(M): """Turn the set of frozen sets M into a string that looks like a set of sets. M is assumed to be the power set of some set. """ result = "{{}, " # The empty set is always an element of a power set. for A in M: if A == set(): # The empty set has already been taken care of. continue result += str(set(A)) + ", " # A is converted from a frozen set to a set result = result[:-2] # remove the trailing substring ", " result += "}" return result prettify(power(A))
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The function $S\texttt{.add}(x)$ insert the element $x$ into the set $S$.
S = {1, 2, 3} S.add(4) S
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
In *Python*, variables are references and assignments do not copy values. Instead, they just create new references to the old values! This is the reason that below both A and B change their value, even so it seems that we only change A.
A = {1,2,3} B = A A.add(4) print(f'A = {A}') print(f'B = {B}')
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
In order to prevent this behaviour, we have to make a copy of the set A. This can be done by calling the function $\texttt{set}(\texttt{A})$.
A = {1,2,3} B = set(A) A.add(4) print(f'A = {A}') print(f'B = {B}')
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Pairs and Cartesian Products In *Python*, pairs can be created by enclosing the components of the pair in parentheses. For example, to compute the pair $\langle 1, 2 \rangle$ we can write:
(1, 2)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
It is not even necessary to enclose the components of a pair in parentheses. For example, to compute the pair $\langle 1, 2 \rangle$ we can also use the following expression:
1, 2
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The Cartesian product $A \times B$ of two sets $A$ and $B$ can now be computed via the following expression:$$ \{\; (x, y) \;\texttt{for}\; x \;\texttt{in}\; A\; \texttt{for}\; y\; \texttt{in}\; B\; \} $$ For example, as we have defined $A$ as $\{1,2,3\}$ and $B$ as $\{4,5\}$, the Cartesian product of $A$ and $B$ is computed as follows:
A = {1, 2, 3} B = {4, 5} { (x, y) for x in A for y in B }
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Tuples *Tuples* are a generalization of pairs. For example, to compute the tuple $\langle 1, 2, 3 \rangle$ we can use the following expression:
(1, 2, 3)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Tuples are not sets, the order of the elements matters:
(1, 2, 3) != (2, 3, 1)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Longer tuples can be build using the function range in combination with the function tuple:
tuple(range(1, 10+1))
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Tuple can be *concatenated* using the operator +:
T1 = (1, 2, 3) T2 = (4, 5, 6) T3 = T1 + T2 T3
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The *length* of a tuple is computed using the function len:
len(T3)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The components of a tuple can be extracted using square brackets. Note, that the first component of a tuple has the index $0$! This is similar to the behaviour of *arrays* in the programming language C.
print("T3[0] =", T3[0]) print("T3[1] =", T3[1]) print("T3[2] =", T3[2])
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
If we use negative indices, then we index from the back of the tuple, as shown in the following example:
print(f'T3[-1] = {T3[-1]}') # last element print(f'T3[-2] = {T3[-2]}') # penultimate element print(f'T3[-3] = {T3[-3]}') # antepenultimate element T3
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The slicing operator extracts a subtuple from a given tuple. If $L$ is a tuple and $a$ and $b$ are natural numbers such that $a \leq b$ and $a,b \in \{0, \texttt{len}(L) \}$, then the syntax of the slicing operator is as follows:$$ L[a:b] $$The expression $L[a:b]$ extracts the subtuple that starts with the element $L[a]$ up to and excluding the element $L[b]$. The following shows an example:
L = tuple(range(1,10+1)) print(f'L = {L}, L[2:6] = {L[2:6]}')
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Slicing works with negative indices, too:
L[2:-2]
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Slicing also works for strings.
s = 'abcdef' s[2:-2]
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
If we want to create a tuple of length $1$, we have to use the following syntax:
L = (1,) L
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Note that above the comma is **not** optional as the expression $(1)$ would be interpreted as the number $1$. Similar to working with sets, it is often convenient to build long tuples using *comprehensions*.In order to create all square numbers that are odd and $\leq$ 100 we can do the following:
G = (x*x for x in range(10+1) if x % 2 == 1) G
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Above, `G` is a *generator object*. To turn this into a tuple we use the predefined function `tuple`:
tuple(G)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Lists Next, we discuss the data type of lists. Lists are a lot like tuples, but in contrast to tuples, lists are mutatable, i.e. we can change lists. To construct a list, we use square backets:
L = [1, 2, 3] L
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
In a list, the order of the elements does matter:
[1, 2, 3] == [3, 2, 1]
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The *index operator* $[\cdot]$ is a postfix operator that is used to return the element that is stored at a given index in a list.
L[0]
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
To change the first element of a list, we can use the *index operator* on the left hand side of an assignment:
L[0] = 7 L
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
This last operation would not be possible if L had been a tuple instead of a list.Lists support concatenation in the same way as tuples:
[1,2,3] + [4,5,6]
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The function `len` computes the length of a list:
len([4,5,6])
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Lists support the functions max and min. The expression $\texttt{max}(L)$ computes the maximum of all the elements of the list (or tuple) $L$, while $\texttt{min}(L)$ computes the smallest element of $L$. These functions also operate on tuples or sets. They even work on list of lists or set of frozensets, but this is not really useful.
max([1,2,3]) min([1,2,3]) max({1,2,3}) max([[1,2], [2,3,4], [5]]) max({frozenset({1,2}), frozenset({2,3,4}), frozenset({5})})
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Boolean Values and Boolean Operators In *Python*, the *truth values*, also known as *Boolean values*, are written as True and False.
True False
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The following function is needed for pretty-printing. It assumes that the argument val is a truth value. This truth value is then turned into a string that has a size of exactly 5 characters.
def toStr(val): if val: return 'True ' return 'False'
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
These values can be combined using the Boolean operators $\wedge$, $\vee$, and $\neg$. In *Python*, these operators are denoted as `and`, `or`, and `not`. The following table shows how the operator `and` is defined:
B = (True, False) for x in B: for y in B: print(toStr(x), 'and', toStr(y), '=', x and y)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The *disjunction* of two Boolean values is only *False* if both values are *False*:
for x in B: for y in B: print(toStr(x), 'or', toStr(y), '=', x or y)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Finally, the negation operator works as expected:
for x in B: print('not', toStr(x), '=', not x)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Boolean values are created by comparing numbers using the follwing comparison operators: $a\;\texttt{==}\;b$ is true iff $a$ is equal to $b$. $a\;\texttt{!=}\;b$ is true iff $a$ is different from $b$. $a\;\texttt{ $a\;\texttt{ $a\;\texttt{>=}\;b$ is true iff $a$ is bigger than or equal to $b$. $a\;\texttt{>}\;b$ is true iff $a$ is bigger than $b$.
1 == 2 1 != 2 1 < 2 1 <= 2 1 > 2 1 >= 2
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Comparison operators can be chained as shown in the following example:
1 < 2 > -1
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
*Python* supports the universal quantifier $\forall$. If $L$ is a list of Boolean values, then we can check whether all elements of $L$ are True by writing$$ \texttt{all}(L). $$For example, to check whether all elements of a list $L$ are even we can write the following:
L = [2, 4, 6, 7] all(x % 2 == 0 for x in L)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
*Python* also supports the existential quantifier $\exists$. If $L$ is a list of Boolean values, the expression$$ \texttt{any}(L) $$is true iff there exists an element $x \in L$ such that $x$ is true.
any(x ** 2 > 2 ** x for x in range(1,4+1))
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Control Structures First of all, *Python* supports *branching*. The following example is taken from the *Python* tutorial at [https://python.org](https://docs.python.org/3/tutorial/controlflow.html):
x = int(input("Please enter an integer: ")) if x < 0: print('The number is negative!') elif x == 0: print('The number is zero.') elif x == 1: print("It's a one.") else: print("It's more than one.")
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
*Loops* can be used to iterate over sets, lists, tuples, or generators. The following example prints the numbers from 1 to 10.
for x in range(1, 10+1): print(x)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The same can be achieved with a `while` loop:
x = 1 while x <= 10: print(x, end=' ') x += 1
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The following program computes the prime numbers according to an[algorithm given by Eratosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes). 1. We set $n$ equal to 100 as we want to compute the set all prime numbers less or equal that 100. 2. `primes` is the list of numbers from 0 upto $n$, i.e. we have initially $$ \texttt{primes} = [0,1,2,\cdots,n] $$ Therefore, we have $$ \texttt{primes}[i] = i \quad \mbox{for all $i \in \{0,1,\cdots,n\}$.} $$ The idea is to set $\texttt{primes}[i]$ to zero iff $i$ is a proper product of two numbers. 3. To this end we iterate over all $i$ and $j$ from the set $\{2,\cdots,n\}$ and set the product $\texttt{primes}[i\cdot j]$ to zero. This is achieved by the two `for` loops in line 3 and 4 below. Note that we have to check that the product $i * j$ is not bigger than $n$ for otherwise we would get an *out of range error* when trying to assign $\texttt{primes}[i*j]$. 4. After the iteration, all non-prime elements greater than one of the list primes have been set to zero. 5. Finally, we compute the set of primes by collecting those elements that have not been set to $0$.
n = 100 primes = list(range(0, n+1)) primes[1] = 0 for i in range(2, n+1): for j in range(2, n+1): if i * j <= n: primes[i * j] = 0 print(primes) print({ i for i in range(2, n+1) if primes[i] != 0 })
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The algorithm given above can be improved by using the following observations: 1. If a number $x$ can be written as a product $a \cdot b$, then at least one of the numbers $a$ or $b$ has to be less than $\sqrt{x}$. Therefore, the `for` loop in line 5 below iterates as long as $i \leq \sqrt{x}$. The function `ceil` is needed to cast the square root of $x$ to a natural number. In order to use the functions `sqrt` and `ceil` we have to import them from the module `math`. This is done in line 1 of the program shown below. 2. When we iterate over $j$ in the inner loop, it is sufficient if we start with $j = i$ since all products of the form $i \cdot j$ where $j < i$ have already been eliminated at the time when the multiples of $i$ had been eliminated. 3. If $\texttt{primes}[i] = 0$, then $i$ is not a prime and hence it has to be a product of two numbers $a$ and $b$ both of which are smaller than $i$. However, since all the multiples of $a$ and $b$ have already been eliminated, there is no point in eliminating the multiples of $i$ since these are also multiples of both $a$ and $b$ and hence they have already been eliminated. Therefore, if $\texttt{primes}[i] = 0$ we can immediately jump to the next value of $i$. This is achieved by the *continue* statement in line 8 below. The program shown below is easily capable of computing all prime numbers less than a million.
%%time from math import sqrt, ceil n = 1000000 primes = list(range(n+1)) for i in range(2, ceil(sqrt(n))): if primes[i] == 0: continue j = i while i * j <= n: primes[i * j] = 0 j += 1 P = { i for i in range(2, n+1) if primes[i] != 0 } print(sorted(list(P)))
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Numerical Functions *Python* provides all of the mathematical functions that you learned at school. A detailed listing of these functions can be found at [https://docs.python.org/3.6/library/math.html](https://docs.python.org/3.6/library/math.html). We just show the most important functions and constants. In order to make the module `math` available, we use the following `import` statement:
import math
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The mathematical constant [Pi](https://en.wikipedia.org/wiki/Pi) which is most often written as $\pi$ is available as `math.pi`.
math.pi
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The sine function is called as follows:
math.sin(math.pi/6)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The cosine function is called as follows:
math.cos(0.0)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The tangent function is called as follows:
math.tan(math.pi/4)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
The *arc sine*, *arc cosine*, and *arc tangent* are called by prefixing the character `'a'` to the name of the function as seen below:
math.asin(1.0) math.acos(1.0) math.atan(1.0)
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic
Euler's number $e$ can be computed as follows:
math.e
_____no_output_____
MIT
Python/Introduction.ipynb
BuserLukas/Logic