This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| instance = {'pickuplon': random.uniform(0, 1), | |
| 'pickuplat': random.uniform(1, 2), | |
| 'dropofflon': random.uniform(3, 4), | |
| 'dropofflat': random.uniform(4, -5), | |
| 'passengers': random.randint(1000, 2000)} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| instance = {'pickuplon': random.uniform(-71, -75), | |
| 'pickuplat': random.uniform(38, 42), | |
| 'dropofflon': random.uniform(-71, -75), | |
| 'dropofflat': random.uniform(38, 42), | |
| 'passengers': random.randint(1, 10)} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def is_retraining_needed(context, dag_run_obj): | |
| current_version = utils.get_model_current_version(MODEL_NAME) | |
| label_mean_query = "SELECT labelMean FROM training_jobs WHERE versionName = '" + current_version + "'" | |
| predictions_query = "SELECT prediction FROM predictions WHERE versionName = '" + current_version + "'" | |
| hook = PostgresHook('cloud_sql_proxy_conn') | |
| try: | |
| label_mean = float(hook.get_records(label_mean_query)[0][0]) | |
| except IndexError: # probably caused by manual training job not persisting metrics | |
| label_mean = np.inf | |
| print('label mean: {} '.format(label_mean)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gcloud ai-platform versions list --model=taxi_fare_predictor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Clone the gitlab repository | |
| git clone https://gitlab.com/marcdjoh/tensorflow-taxi-fare-predictor.git | |
| # Navigate to the manifest folder | |
| cd tensorflow-taxi-fare-predictor/manifests | |
| # Create the namespace | |
| kubectl apply -f namespace.yaml | |
| # Create the deployment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE predictions ( | |
| versionName varchar(200) NOT NULL, | |
| pickuplon numeric NOT NULL, | |
| pickuplat numeric NOT NULL, | |
| dropofflat numeric NOT NULL, | |
| dropofflon numeric NOT NULL, | |
| passengers integer NOT NULL, | |
| prediction numeric NOT NULL); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE training_jobs ( | |
| jobName varchar(200) NOT NULL, | |
| versionName varchar(200) NOT NULL, | |
| evalLoss numeric NOT NULL, | |
| labelMean numeric NOT NULL); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gcloud composer environments create ml-model-retraining-prod --location=europe-west1 --zone=europe-west1-b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gsutil cp path/to/cloud_sql_to_bq.py <dag_folder_name>/cloud_sql_to_bq.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| gcloud composer environments describe data-synchronization-env --location=europe-west1 |