By deploying or using this software you agree to comply with the AI Hub Terms of Service and the Google APIs Terms of Service. To the extent of a direct conflict of terms, the AI Hub Terms of Service will control.

Overview

This notebook provides an example workflow of using the K-Nearest Neighbors ML container for training a regression ML model.

Dataset

The notebook uses the Boston housing price regression dataset. It containers 506 observations with 13 features describing a house in Boston and a corresponding house price, stored in a 506x14 table.

Objective

The goal of this notebook is to go through a common training workflow:

  • Create a dataset
  • Train an ML model using the AI Platform Training service
  • Identify if the model was trained successfully by looking at the generated "Run Report"

Costs

This tutorial uses billable components of Google Cloud Platform (GCP):

  • Cloud AI Platform
  • Cloud Storage

Learn about Cloud AI Platform pricing and Cloud Storage pricing, and use the Pricing Calculator to generate a cost estimate based on your projected usage.

Set up your local development environment

If you are using Colab or AI Platform Notebooks, your environment already meets all the requirements to run this notebook. You can skip this step.

Otherwise, make sure your environment meets this notebook's requirements. You need the following:

  • The Google Cloud SDK
  • Git
  • Python 3
  • virtualenv
  • Jupyter notebook running in a virtual environment with Python 3

The Google Cloud guide to Setting up a Python development environment and the Jupyter installation guide provide detailed instructions for meeting these requirements. The following steps provide a condensed set of instructions:

  1. Install and initialize the Cloud SDK.

  2. Install Python 3.

  3. Install virtualenv and create a virtual environment that uses Python 3.

  4. Activate that environment and run pip install jupyter in a shell to install Jupyter.

  5. Run jupyter notebook in a shell to launch Jupyter.

  6. Open this notebook in the Jupyter Notebook Dashboard.

Set up your GCP project

The following steps are required, regardless of your notebook environment.

  1. Select or create a GCP project.. When you first create an account, you get a $300 free credit towards your compute/storage costs.

  2. Make sure that billing is enabled for your project.

  3. Enable the AI Platform APIs and Compute Engine APIs.

  4. Enter your project ID in the cell below. Then run the cell to make sure the Cloud SDK uses the right project for all the commands in this notebook.

Note: Jupyter runs lines prefixed with ! as shell commands, and it interpolates Python variables prefixed with $ into these commands.


In [ ]:
PROJECT_ID = "[your-project-id]" #@param {type:"string"}
! gcloud config set project $PROJECT_ID

Authenticate your GCP account

If you are using AI Platform Notebooks, your environment is already authenticated. Skip this step.

If you are using Colab, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.

Otherwise, follow these steps:

  1. In the GCP Console, go to the Create service account key page.

  2. From the Service account drop-down list, select New service account.

  3. In the Service account name field, enter a name.

  4. From the Role drop-down list, select Machine Learning Engine > AI Platform Admin and Storage > Storage Object Admin.

  5. Click Create. A JSON file that contains your key downloads to your local environment.

  6. Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell.


In [ ]:
import sys

# If you are running this notebook in Colab, run this cell and follow the
# instructions to authenticate your GCP account. This provides access to your
# Cloud Storage bucket and lets you submit training jobs and prediction
# requests.

if 'google.colab' in sys.modules:
  from google.colab import auth as google_auth
  google_auth.authenticate_user()

# If you are running this notebook locally, replace the string below with the
# path to your service account key and run this cell to authenticate your GCP
# account.
else:
  %env GOOGLE_APPLICATION_CREDENTIALS ''

Create a Cloud Storage bucket

The following steps are required, regardless of your notebook environment.

You need to have a "workspace" bucket that will hold the dataset and the output from the ML Container. Set the name of your Cloud Storage bucket below. It must be unique across all Cloud Storage buckets.

You may also change the REGION variable, which is used for operations throughout the rest of this notebook. Make sure to choose a region where Cloud AI Platform services are available. You may not use a Multi-Regional Storage bucket for training with AI Platform.


In [ ]:
BUCKET_NAME = "[your-bucket-name]" #@param {type:"string"}
REGION = 'us-central1' #@param {type:"string"}

Only if your bucket doesn't already exist: Run the following cell to create your Cloud Storage bucket.


In [ ]:
! gsutil mb -l $REGION gs://$BUCKET_NAME

Finally, validate access to your Cloud Storage bucket by examining its contents:


In [ ]:
! gsutil ls -al gs://$BUCKET_NAME

Import libraries and define constants


In [ ]:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import pandas as pd
import tensorflow as tf
import os
import time
from IPython.core.display import HTML

Create a dataset


In [4]:
bh = tf.keras.datasets.boston_housing
(X_train, y_train), (X_eval, y_eval) = bh.load_data()

# standartize
data_mean = X_train.mean(axis=0)
data_std = X_train.std(axis=0)

X_train = (X_train - data_mean) / data_std
X_eval = (X_eval - data_mean) / data_std

# normalize
data_min = X_train.min()
data_max = X_train.max()

X_train = (X_train - data_min) / (data_max - data_min)
X_eval = (X_eval - data_min) / (data_max - data_min)

training = pd.DataFrame(X_train)
training.columns = ["f{}".format(c) for c in training.columns]
training['target'] = y_train

validation = pd.DataFrame(X_eval)
validation.columns = ["f{}".format(c) for c in validation.columns]
validation['target'] = y_eval

print('Training data head')
display(training.head())

training_data = os.path.join('gs://', BUCKET_NAME, 'data/train.csv')
validation_data = os.path.join('gs://', BUCKET_NAME, 'data/valid.csv')

print('Copy the data in bucket ...')
with tf.io.gfile.GFile(training_data, 'w') as f:
  training.to_csv(f, index=False)
with tf.io.gfile.GFile(validation_data, 'w') as f:
  validation.to_csv(f, index=False)


Training data head
f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 target
0 0.271604 0.255410 0.259076 0.272785 0.279804 0.278944 0.354756 0.301404 0.244482 0.246863 0.380456 0.326792 0.355688 15.2
1 0.261554 0.521681 0.190264 0.272785 0.199360 0.437600 0.146098 0.388048 0.226844 0.265767 0.160822 0.325554 0.190624 42.3
2 0.302035 0.255410 0.371249 0.272785 0.340627 0.152279 0.377544 0.201486 0.420862 0.412389 0.352566 0.309365 0.192211 50.0
3 0.261702 0.255410 0.225852 0.272785 0.264761 0.267596 0.197714 0.377290 0.253301 0.208594 0.352566 0.326792 0.242438 21.1
4 0.292031 0.255410 0.371249 0.272785 0.394256 0.304234 0.345696 0.248135 0.420862 0.412389 0.352566 0.322334 0.312651 17.7
Copy the data in bucket ...

Cloud training

Accelerator and distribution support

GPU Multi-GPU Node TPU Workers Parameter Server
Yes Yes No No No

To have distribution and/or accelerators to your AI Platform training call, use parameters similar to the examples as shown below.

--master-machine-type standard_gpu

AI Platform training

Local Training


In [ ]:
output_location = os.path.join('gs://', BUCKET_NAME, 'output')

job_name = "knn_regression_{}".format(time.strftime("%Y%m%d%H%M%S"))
!gcloud ai-platform jobs submit training $job_name \
    --master-image-uri gcr.io/aihub-c2t-containers/kfp-components/oob_algorithm/knn:latest \
    --region $REGION \
    --scale-tier CUSTOM \
    --master-machine-type standard \
    -- \
    --output-location {output_location} \
    --training-data {training_data} \
    --validation-data {validation_data} \
    --target-column target \
    --data-type csv \
    --k-neighbors 5 \
    --fresh-start True \
    --objective regression

Local training snippet

Note that the training can also be done locally with Docker

docker run \
    -v /tmp:/tmp \
    -it gcr.io/aihub-c2t-containers/kfp-components/oob_algorithm/knn:latest \
    --output-location /tmp/knn_regression \
    --training-data /tmp/train.csv \
    --validation-data /tmp/valid.csv \
    --target-column target \
    --data-type csv \
    --k-neighbors 5 \
    --objective regression

Inspect the Run Report

The "Run Report" will help you identify if the model was successfully trained.


In [6]:
if not tf.io.gfile.exists(os.path.join(output_location, 'report.html')):
  raise RuntimeError('The file report.html was not found. Did the training job finish?')

with tf.io.gfile.GFile(os.path.join(output_location, 'report.html')) as f:
  display(HTML(f.read()))


temp_input_nb
+ Table of Contents

Runtime arguments

value
k_neighbors 5
target_column target
objective regression
fresh_start True
training_data gs://aihub-content-test/knn_regression/data/train.csv
validation_data gs://aihub-content-test/knn_regression/data/valid.csv
testing_data None
output_location gs://aihub-content-test/knn_regression/output
data_type csv
remainder None

Tensorboard snippet

To see the training progress, you can need to install the latest tensorboard with the command: pip install -U tensorboard and then run one of the following commands.

Local tensorboard

tensorboard --logdir gs://aihub-content-test/knn_regression/output

Publicly shared tensorboard

tensorboard dev upload --logdir gs://aihub-content-test/knn_regression/output

Datasets

Data reading snippet

import tensorflow as tf
import pandas as pd

sample = pd.DataFrame()
for filename in tf.io.gfile.glob('gs://aihub-content-test/knn_regression/data/valid.csv'):
  with tf.io.gfile.GFile(filename, 'r') as f:
    sample = sample.append(
      pd.read_csv(f, nrows=sample_size-len(sample)))
  if len(sample) >= sample_size:
    break

Training dataset preview

f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 target
0 0.2623 0.2554 0.3018 0.2728 0.3027 0.3494 0.3482 0.2414 0.2180 0.2312 0.3805 0.3240 0.2263 22.0
1 0.2618 0.2554 0.3238 0.5908 0.2877 0.2515 0.2567 0.2687 0.2533 0.2326 0.2201 0.3235 0.3006 23.3
... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
402 0.3534 0.2554 0.3712 0.2728 0.3975 0.3080 0.3775 0.2214 0.4209 0.4124 0.3526 0.2631 0.3166 16.7
403 0.2621 0.4006 0.2061 0.2728 0.2137 0.3664 0.1620 0.3960 0.2533 0.2888 0.1783 0.3111 0.2117 37.0

404 rows × 14 columns

Validation dataset preview

f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 target
0 0.3804 0.2554 0.3712 0.2728 0.3295 0.2883 0.3446 0.2249 0.4209 0.4124 0.3526 0.3157 0.2964 21.4
1 0.2623 0.2554 0.4798 0.2728 0.3262 0.2618 0.3322 0.2309 0.2445 0.4331 0.3491 0.3268 0.2989 20.1
... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
100 0.2619 0.3845 0.2396 0.5908 0.2203 0.3529 0.1788 0.3349 0.2445 0.2224 0.2619 0.3240 0.2017 33.1
101 0.2631 0.2554 0.4798 0.2728 0.3262 0.1656 0.3721 0.2200 0.2445 0.4331 0.3491 0.2628 0.4716 8.1

102 rows × 14 columns

Dataset inspection

You can use AI Platform to create a detailed inspection report for your dataset with the following console snippet:

DATA=gs://aihub-content-test/knn_regression/data/valid.csv
#DATA=gs://aihub-content-test/knn_regression/data/train.csv
OUTPUT_LOCATION=gs://aihub-content-test/knn_regression/output
# can be one of: tfrecord, parquet, avro, csv, json, bigquery
DATA_TYPE=csv
MAX_SAMPLE_SIZE=10000
JOB_NAME=tabular_data_inspection_$(date '+%Y%m%d_%H%M%S')

gcloud ai-platform jobs submit training $JOB_NAME \
  --stream-logs \
  --master-image-uri gcr.io/kf-pipeline-contrib/kfp-components/oob_algorithm/tabular_data_inspection:latest \
  -- \
  --output-location $OUTPUT_LOCATION \
  --data $DATA \
  --data-type $DATA_TYPE \
  --max-sample-size $MAX_SAMPLE_SIZE

Predictions

Local predictions snippet

import tensorflow as tf

# The input data should have format: {f1: [[1],[2]], f2: [[4,2],[3,1], ...]}
saved_model = 'gs://aihub-content-test/knn_regression/output'
predict_fn = tf.contrib.predictor.from_saved_model(saved_model)
predictions = predict_fn(estimator_input)

Local predictions snippet

import faiss
import scipy
import numpy as np
import tensorflow as tf


objective = 'classification' # or 'regression'

# copy the model files to local dir
tf.io.gfile.copy('gs://aihub-content-test/knn_regression/output/model.faiss'), '/tmp/model.faiss')
tf.io.gfile.copy('gs://aihub-content-test/knn_regression/output/label.txt'), '/tmp/label.txt')

# load model files
index = faiss.read_index('/tmp/model.faiss')
train_labels = np.loadtxt('/tmp/label.txt')

# create predictions
features = np.ascontiguousarray(data.values.astype(np.float32))
distance, features_index = index.search(features, k=5)

if objective == 'classification'
  y_pred = scipy.stats.mode(train_labels[features_index], axis=1)[0].ravel()
else:
  assert objective == 'regression'
  y_pred = train_labels[features_index].mean(axis=1)

Sample of the resulting predictions

Training predictions sample

400    20.2
238    21.6
60     30.6
230    22.6
134    23.6
dtype: float64

Validation predictions sample

26    20.8
92    18.2
2     23.6
55    21.0
91    18.2
dtype: float64

Metrics

Actual VS Prediction

Distribution of the predictions

Distribution of the residuals

Absolute value of the residuals

Absolute value of the residuals as a percent of the target

Prediction tables

Training data and prediction

Best predictions

target predicted-target residual_abs residual f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12
row
277 23 23 0 0 0.2639 0.2554 0.2505 0.2728 0.2504 0.2973 0.1823 0.3558 0.2533 0.2376 0.3316 0.3268 0.2228
108 20.6 20.6 3.815e-07 3.815e-07 0.3015 0.2554 0.3712 0.2728 0.3092 0.2533 0.2491 0.2702 0.4209 0.4124 0.3526 0.3197 0.2788
384 19.4 19.4 3.815e-07 -3.815e-07 0.2636 0.2554 0.2638 0.2728 0.268 0.2883 0.3534 0.2473 0.2533 0.2824 0.377 0.3222 0.3222
362 8.4 8.4 3.815e-07 -3.815e-07 0.3749 0.2554 0.3712 0.2728 0.4119 0.2566 0.3443 0.2199 0.4209 0.4124 0.3526 0.05948 0.5175
298 13.6 13.6 3.815e-07 3.815e-07 0.2718 0.2554 0.2591 0.2728 0.2798 0.2171 0.3723 0.2946 0.2445 0.2469 0.3805 0.3102 0.38
128 19.2 19.2 7.629e-07 7.629e-07 0.2642 0.2554 0.4139 0.2728 0.336 0.3131 0.3745 0.2312 0.2445 0.3068 0.3874 0.3253 0.291
226 20.2 20.2 7.629e-07 7.629e-07 0.268 0.2554 0.2591 0.2728 0.2798 0.2048 0.2035 0.2946 0.2445 0.2469 0.3805 0.2388 0.2814
299 18.3 18.2 0.1 0.1 0.2636 0.2554 0.2765 0.2728 0.3105 0.2413 0.2968 0.2604 0.2621 0.2856 0.3177 0.3268 0.3068
326 31.7 31.8 0.1 -0.1 0.2652 0.2554 0.2372 0.2728 0.2576 0.4162 0.3141 0.2899 0.2798 0.2469 0.255 0.3099 0.2133
358 21.7 21.8 0.1 -0.1 0.2627 0.2554 0.2891 0.2728 0.1981 0.2594 0.151 0.3509 0.2445 0.2459 0.3177 0.3105 0.2622
180 23.3 23.2 0.1 0.1 0.2627 0.3361 0.2252 0.2728 0.2242 0.2793 0.1832 0.4464 0.2798 0.2363 0.3351 0.3217 0.2303
400 20.3 20.2 0.1 0.1 0.2643 0.2554 0.2789 0.2728 0.2837 0.2606 0.3136 0.2684 0.2445 0.2455 0.2898 0.3263 0.2632
311 14.9 14.8 0.1 0.1 0.3257 0.2554 0.3712 0.2728 0.3943 0.2961 0.3328 0.2563 0.4209 0.4124 0.3526 0.2252 0.3294
200 8.7 8.6 0.1 0.1 0.3874 0.2554 0.3712 0.2728 0.4119 0.28 0.3775 0.2235 0.4209 0.4124 0.3526 0.01087 0.4374
143 10.5 10.6 0.1 -0.1 0.4444 0.2554 0.3712 0.2728 0.4119 0.2439 0.3567 0.2217 0.4209 0.4124 0.3526 0.3224 0.3915
35 13.5 13.4 0.1 0.1 0.3294 0.2554 0.3712 0.2728 0.3943 0.2567 0.3235 0.2561 0.4209 0.4124 0.3526 0.006128 0.3369
172 14.5 14.4 0.1 0.1 0.3319 0.2554 0.3712 0.2728 0.3099 0.3012 0.3394 0.2287 0.4209 0.4124 0.3526 0.0713 0.3443
38 23.5 23.4 0.1 0.1 0.2617 0.5136 0.2054 0.2728 0.1882 0.2949 0.1519 0.401 0.2445 0.2607 0.2096 0.3268 0.2071
278 11.7 11.8 0.1 -0.1 0.3769 0.2554 0.3712 0.2728 0.3943 0.2861 0.3638 0.2351 0.4209 0.4124 0.3526 0.0853 0.3181
319 22.9 23 0.1 -0.1 0.2617 0.3458 0.3368 0.2728 0.2314 0.3114 0.2502 0.2897 0.2445 0.2298 0.2828 0.3253 0.244
27 18.9 19 0.1 -0.1 0.2619 0.2554 0.2345 0.2728 0.2543 0.2564 0.2902 0.2781 0.2533 0.234 0.3177 0.3268 0.2601
106 10.9 11 0.1 -0.1 0.574 0.2554 0.3712 0.2728 0.372 0.2854 0.3191 0.2215 0.4209 0.4124 0.3526 0.01862 0.3113
302 19.7 19.6 0.1 0.1 0.2621 0.3232 0.2309 0.2728 0.2151 0.2596 0.2285 0.4086 0.2445 0.2174 0.234 0.3257 0.3
34 19.3 19.4 0.1 -0.1 0.2631 0.2554 0.2638 0.2728 0.268 0.2784 0.343 0.2537 0.2533 0.2824 0.377 0.3248 0.2999
46 18.2 18.4 0.2 -0.2 0.2674 0.2554 0.2591 0.2728 0.2798 0.2341 0.2938 0.2946 0.2445 0.2469 0.3805 0.3219 0.277
366 25.2 25.4 0.2 -0.2 0.2627 0.32 0.2458 0.2728 0.2314 0.2895 0.1477 0.3185 0.2357 0.2081 0.2968 0.3268 0.2274
78 21.6 21.8 0.2 -0.2 0.2636 0.2554 0.2789 0.2728 0.2837 0.2923 0.3303 0.2744 0.2445 0.2455 0.2898 0.3239 0.2413
197 24.4 24.2 0.2 0.2 0.2623 0.32 0.2458 0.2728 0.2314 0.3217 0.2642 0.2992 0.2357 0.2081 0.2968 0.3252 0.2395
195 21.4 21.2 0.2 0.2 0.2622 0.2554 0.3119 0.2728 0.2137 0.2945 0.2265 0.3213 0.2533 0.2888 0.3003 0.3156 0.2523
279 15.6 15.8 0.2 -0.2 0.2793 0.2554 0.3879 0.2728 0.4976 0.2234 0.3775 0.2084 0.2533 0.2911 0.1608 0.1412 0.3338

Worst predictions

target predicted-target residual_abs residual f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12
row
255 50 24 26 26 0.338 0.2554 0.3712 0.2728 0.3406 0.2869 0.3775 0.1953 0.4209 0.4124 0.3526 0.3017 0.2585
163 16.8 36.6 19.8 -19.8 0.2964 0.2554 0.3712 0.5908 0.4315 0.2423 0.3473 0.2231 0.4209 0.4124 0.3526 0.291 0.3125
144 17.8 36.6 18.8 -18.8 0.3359 0.2554 0.3712 0.5908 0.4315 0.2865 0.3704 0.2313 0.4209 0.4124 0.3526 0.3112 0.3438
111 50 32.4 17.6 17.6 0.274 0.2554 0.3879 0.5908 0.3236 0.5203 0.3608 0.2328 0.2533 0.2911 0.1608 0.3199 0.1928
339 50 33.6 16.4 16.4 0.302 0.2554 0.3712 0.2728 0.3406 0.1523 0.3775 0.2015 0.4209 0.4124 0.3526 0.3094 0.1922
39 50 36.6 13.4 13.4 0.3157 0.2554 0.3712 0.5908 0.3406 0.3734 0.3707 0.1966 0.4209 0.4124 0.3526 0.3228 0.189
315 50 36.6 13.4 13.4 0.3084 0.2554 0.3712 0.5908 0.3406 0.3374 0.3688 0.2024 0.4209 0.4124 0.3526 0.3092 0.1972
337 50 36.6 13.4 13.4 0.33 0.2554 0.3712 0.5908 0.3648 0.2501 0.349 0.1938 0.4209 0.4124 0.3526 0.2868 0.2516
234 50 37.2 12.8 12.8 0.2781 0.2554 0.3879 0.2728 0.3236 0.4721 0.3671 0.2284 0.2533 0.2911 0.1608 0.3043 0.1969
357 50 37.4 12.6 12.6 0.2735 0.2554 0.3879 0.2728 0.3236 0.4245 0.3523 0.2256 0.2533 0.2911 0.1608 0.3085 0.176
159 46 33.6 12.4 12.4 0.2619 0.32 0.2049 0.5908 0.2176 0.4414 0.2394 0.3481 0.2533 0.2049 0.1678 0.3106 0.1896
391 36.2 24.6 11.6 11.6 0.2619 0.2554 0.1951 0.2728 0.2471 0.2792 0.2738 0.2493 0.2357 0.1943 0.2689 0.3268 0.2577
264 50 39.6 10.4 10.4 0.2664 0.32 0.2121 0.2728 0.3511 0.5558 0.3416 0.2192 0.2533 0.227 0.1016 0.3209 0.2119
206 48.8 39.6 9.2 9.2 0.2657 0.32 0.2121 0.2728 0.3511 0.5228 0.3542 0.2376 0.2533 0.227 0.1016 0.3186 0.2202
354 43.8 35.2 8.6 8.6 0.2621 0.2554 0.1999 0.2728 0.219 0.4603 0.2043 0.2832 0.2268 0.2326 0.2759 0.324 0.1955
152 17.9 10.2 7.7 7.7 0.4175 0.2554 0.3712 0.2728 0.3184 0.1153 0.3775 0.2099 0.4209 0.4124 0.3526 0.02674 0.5212
18 37.2 29.8 7.4 7.4 0.2619 0.2554 0.1951 0.2728 0.2471 0.3695 0.2633 0.258 0.2357 0.1943 0.2689 0.3268 0.211
121 43.5 36.2 7.3 7.3 0.2659 0.32 0.2121 0.2728 0.304 0.4225 0.2474 0.2597 0.2533 0.227 0.1016 0.3214 0.1912
162 50 42.8 7.2 7.2 0.2615 0.5459 0.181 0.5908 0.1902 0.4714 0.1711 0.3735 0.218 0.1966 0.1225 0.3257 0.1912
185 37.9 31.2 6.7 6.7 0.2621 0.2554 0.1951 0.2728 0.2471 0.3884 0.3561 0.2532 0.2357 0.1943 0.2689 0.3245 0.2087
373 37.6 44 6.4 -6.4 0.2645 0.2554 0.2372 0.2728 0.2576 0.4841 0.3405 0.2726 0.2798 0.2469 0.255 0.319 0.1908
50 11.9 18.2 6.3 -6.3 0.2618 0.2554 0.3018 0.2728 0.3027 0.2668 0.3248 0.2458 0.218 0.2312 0.3805 0.3268 0.2411
94 16.3 10 6.3 6.3 0.4993 0.2554 0.3712 0.2728 0.3184 0.1723 0.3775 0.2112 0.4209 0.4124 0.3526 0.1752 0.3701
218 34.9 28.8 6.1 6.1 0.2616 0.562 0.184 0.2728 0.1915 0.369 0.145 0.4403 0.2357 0.2907 0.241 0.3268 0.206
15 37.3 31.2 6.1 6.1 0.262 0.5136 0.2231 0.2728 0.1967 0.3877 0.179 0.3445 0.2445 0.2183 0.3177 0.3268 0.1954
36 23.2 17.2 6 6 0.3053 0.2554 0.3712 0.2728 0.3858 0.2691 0.3295 0.233 0.4209 0.4124 0.3526 0.3117 0.3561
344 50 44 6 6 0.2657 0.2554 0.2372 0.2728 0.2576 0.5581 0.3309 0.2605 0.2798 0.2469 0.255 0.3146 0.2067
28 23.6 29.6 6 -6 0.2618 0.2554 0.2058 0.2728 0.2478 0.3724 0.3399 0.2804 0.2268 0.2298 0.2689 0.3268 0.2159
112 39.8 34 5.8 5.8 0.2619 0.2554 0.1951 0.2728 0.2471 0.4544 0.3317 0.2547 0.2357 0.1943 0.2689 0.3257 0.2377
54 45.4 39.8 5.6 5.6 0.2617 0.32 0.2049 0.2728 0.2176 0.4603 0.2801 0.3285 0.2533 0.2049 0.1678 0.319 0.1975

Validation data and prediction

Best predictions

target predicted-target residual_abs residual f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12
row
22 12 12 0 0 0.3861 0.2554 0.3712 0.2728 0.3295 0.1884 0.3701 0.2305 0.4209 0.4124 0.3526 0.2881 0.4211
89 19 19 0 0 0.2618 0.2554 0.2259 0.2728 0.2648 0.262 0.2276 0.333 0.2533 0.2086 0.3526 0.3268 0.2607
40 13.1 13.2 0.1 -0.1 0.3337 0.2554 0.3712 0.2728 0.3812 0.3145 0.3742 0.2163 0.4209 0.4124 0.3526 0.3228 0.3388
4 21.5 21.4 0.1 0.1 0.2623 0.2554 0.3238 0.5908 0.2877 0.2583 0.3605 0.2603 0.2533 0.2326 0.2201 0.3268 0.3472
18 18.9 19 0.1 -0.1 0.2623 0.2958 0.256 0.2728 0.2706 0.2646 0.3306 0.3864 0.2533 0.2487 0.1783 0.3268 0.2981
5 32.4 32.6 0.2 -0.2 0.2618 0.3845 0.2396 0.5908 0.2203 0.3455 0.1933 0.3052 0.2445 0.2224 0.2619 0.3268 0.1951
14 19.8 19.6 0.2 0.2 0.2634 0.2554 0.2789 0.2728 0.2837 0.24 0.2998 0.3035 0.2445 0.2455 0.2898 0.3268 0.3263
95 23.4 23.2 0.2 0.2 0.263 0.2554 0.2891 0.2728 0.1981 0.2901 0.12 0.3509 0.2445 0.2459 0.3177 0.3107 0.2375
3 10.2 10 0.2 0.2 0.3804 0.2554 0.3712 0.2728 0.3858 0.1426 0.3775 0.2112 0.4209 0.4124 0.3526 0.3072 0.4815
67 22 21.8 0.2 0.2 0.2619 0.2958 0.2358 0.2728 0.1954 0.2504 0.1617 0.3967 0.2445 0.2644 0.3072 0.3262 0.2434
0 21.4 21.6 0.2 -0.2 0.3804 0.2554 0.3712 0.2728 0.3295 0.2883 0.3446 0.2249 0.4209 0.4124 0.3526 0.3157 0.2964
70 20.1 19.8 0.3 0.3 0.3699 0.2554 0.3712 0.2728 0.3073 0.2326 0.2587 0.2578 0.4209 0.4124 0.3526 0.3268 0.3138
49 20.2 20.6 0.4 -0.4 0.3097 0.2554 0.3712 0.2728 0.3943 0.319 0.3498 0.257 0.4209 0.4124 0.3526 0.3243 0.2665
86 17.6 18 0.4 -0.4 0.2631 0.3264 0.2334 0.2728 0.2098 0.2196 0.313 0.4517 0.2709 0.2575 0.3142 0.3069 0.2899
64 20 20.4 0.4 -0.4 0.2622 0.2554 0.2345 0.2728 0.2543 0.2464 0.2716 0.2788 0.2533 0.234 0.3177 0.311 0.2784
100 33.1 32.6 0.5 0.5 0.2619 0.3845 0.2396 0.5908 0.2203 0.3529 0.1788 0.3349 0.2445 0.2224 0.2619 0.324 0.2017
28 18.5 18 0.5 0.5 0.263 0.3264 0.2334 0.2728 0.2098 0.2209 0.2957 0.4517 0.2709 0.2575 0.3142 0.3205 0.3529
48 21.9 22.4 0.5 -0.5 0.2618 0.5136 0.2084 0.2728 0.1843 0.2753 0.1908 0.4995 0.218 0.2506 0.2201 0.3235 0.2272
91 18.8 18.2 0.6 0.6 0.2624 0.2554 0.2801 0.2728 0.2857 0.2542 0.3581 0.2401 0.2621 0.3045 0.2689 0.3252 0.3291
52 21.6 22.2 0.6 -0.6 0.2616 0.2554 0.247 0.2728 0.2347 0.3091 0.3196 0.3388 0.2268 0.2169 0.2689 0.3268 0.2544
75 22 21.4 0.6 0.6 0.2623 0.3522 0.2229 0.2728 0.2079 0.3605 0.2521 0.3905 0.2621 0.2436 0.2271 0.3222 0.2781
2 22.9 23.6 0.7 -0.7 0.2617 0.3361 0.2221 0.2728 0.2066 0.2816 0.2312 0.3552 0.2445 0.2349 0.3107 0.3217 0.2372
33 20.9 21.6 0.7 -0.7 0.2617 0.5136 0.2084 0.2728 0.1843 0.2502 0.1554 0.4995 0.218 0.2506 0.2201 0.3254 0.2555
29 19.8 19 0.8 0.8 0.2618 0.2554 0.2039 0.2728 0.2288 0.2792 0.1914 0.3731 0.2445 0.3036 0.2375 0.3037 0.2539
77 20.5 19.6 0.9 0.9 0.2621 0.2554 0.4563 0.2728 0.3079 0.2594 0.3581 0.23 0.2268 0.192 0.3142 0.3115 0.3473
31 14.5 13.6 0.9 0.9 0.2696 0.2554 0.2591 0.2728 0.2798 0.2434 0.3775 0.3059 0.2445 0.2469 0.3805 0.3249 0.368
13 9.7 10.6 0.9 -0.9 0.3575 0.2554 0.3712 0.2728 0.3858 0.1594 0.3693 0.218 0.4209 0.4124 0.3526 0.3268 0.4293
11 14.1 13.2 0.9 0.9 0.3449 0.2554 0.3712 0.2728 0.3099 0.3536 0.3619 0.23 0.4209 0.4124 0.3526 0.06957 0.3659
35 19.6 18.6 1 1 0.2949 0.2554 0.3712 0.2728 0.2759 0.2883 0.352 0.2682 0.4209 0.4124 0.3526 0.3255 0.2938
99 24.2 23.2 1 1 0.2621 0.2554 0.2891 0.2728 0.1981 0.3087 0.1211 0.3509 0.2445 0.2459 0.3177 0.3161 0.2288

Worst predictions

target predicted-target residual_abs residual f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12
row
19 21.9 43.4 21.5 -21.5 0.2902 0.2554 0.3712 0.5908 0.3975 0.564 0.3306 0.2231 0.4209 0.4124 0.3526 0.2923 0.2137
57 42.8 25 17.8 17.8 0.2644 0.3264 0.2334 0.2728 0.2098 0.5077 0.1261 0.4877 0.2709 0.2575 0.3142 0.3268 0.1952
58 50 32.4 17.6 17.6 0.2766 0.2554 0.3879 0.5908 0.3236 0.4584 0.3726 0.2282 0.2533 0.2911 0.1608 0.3209 0.178
76 21.7 36.6 14.9 -14.9 0.2933 0.2554 0.3712 0.5908 0.4315 0.3063 0.3528 0.2458 0.4209 0.4124 0.3526 0.3223 0.2981
56 46.7 32.4 14.3 14.3 0.2638 0.2554 0.2372 0.2728 0.2576 0.4458 0.1497 0.2787 0.2798 0.2469 0.255 0.311 0.1992
73 22.7 36.6 13.9 -13.9 0.3046 0.2554 0.3712 0.5908 0.4315 0.2773 0.332 0.254 0.4209 0.4124 0.3526 0.3256 0.2791
51 27.5 14.2 13.3 13.3 0.3812 0.2554 0.3712 0.2728 0.3184 0.3557 0.3775 0.2065 0.4209 0.4124 0.3526 0.1495 0.3669
25 50 38 12 12 0.2618 0.2554 0.1951 0.2728 0.2471 0.4615 0.2502 0.272 0.2357 0.1943 0.2689 0.3233 0.2048
59 29.8 20.2 9.6 9.6 0.2999 0.2554 0.3712 0.2728 0.3295 0.3695 0.2886 0.2468 0.4209 0.4124 0.3526 0.3087 0.281
36 27.1 17.6 9.5 9.5 0.2626 0.2958 0.256 0.2728 0.2706 0.2822 0.3668 0.376 0.2533 0.2487 0.1783 0.3268 0.3602
41 33 23.8 9.2 9.2 0.2615 0.3119 0.1829 0.2728 0.2001 0.3829 0.2664 0.4996 0.2357 0.2049 0.2968 0.3238 0.2429
39 50 41 9 9 0.2662 0.32 0.2121 0.2728 0.304 0.5118 0.2869 0.2426 0.2533 0.227 0.1016 0.3167 0.2364
30 35.4 27 8.4 8.4 0.2617 0.32 0.2049 0.2728 0.2176 0.3682 0.2051 0.3493 0.2533 0.2049 0.1678 0.323 0.2063
87 43.1 35.6 7.5 7.5 0.2658 0.32 0.2121 0.2728 0.3511 0.4279 0.3484 0.232 0.2533 0.227 0.1016 0.3198 0.2345
88 35.1 27.8 7.3 7.3 0.2631 0.32 0.2049 0.2728 0.2176 0.3514 0.1914 0.3061 0.2533 0.2049 0.1678 0.3268 0.209
61 7 14.2 7.2 -7.2 0.2629 0.2554 0.4798 0.2728 0.3262 0.2003 0.3729 0.2175 0.2445 0.4331 0.3491 0.2837 0.4112
42 35.4 29 6.4 6.4 0.2615 0.5459 0.1811 0.2728 0.1915 0.3986 0.1631 0.4797 0.2533 0.2095 0.2724 0.326 0.2086
54 30.1 24.4 5.7 5.7 0.2615 0.5459 0.1902 0.2728 0.1961 0.3423 0.2021 0.6093 0.2533 0.1915 0.241 0.3167 0.2053
101 8.1 13.8 5.7 -5.7 0.2631 0.2554 0.4798 0.2728 0.3262 0.1656 0.3721 0.22 0.2445 0.4331 0.3491 0.2628 0.4716
37 27 21.4 5.6 5.6 0.2719 0.2554 0.3879 0.5908 0.3236 0.2906 0.3572 0.2191 0.2533 0.2911 0.1608 0.2795 0.2159
46 32.5 27 5.5 5.5 0.2622 0.2554 0.1951 0.2728 0.2471 0.3244 0.3655 0.2587 0.2357 0.1943 0.2689 0.3268 0.2178
27 7.2 12.4 5.2 -5.2 0.3796 0.2554 0.3712 0.2728 0.3812 0.3007 0.3775 0.2106 0.4209 0.4124 0.3526 0.3268 0.3726
78 29.6 24.6 5 5 0.2621 0.3264 0.2334 0.2728 0.2098 0.367 0.1217 0.4877 0.2709 0.2575 0.3142 0.318 0.1951
71 28.1 23.2 4.9 4.9 0.2625 0.2554 0.2867 0.2728 0.2478 0.3041 0.1917 0.3002 0.2445 0.233 0.2968 0.3178 0.2569
7 10.2 14.6 4.4 -4.4 0.363 0.2554 0.3712 0.2728 0.3099 0.246 0.2669 0.2266 0.4209 0.4124 0.3526 0.02337 0.3236
53 29.6 25.4 4.2 4.2 0.2619 0.2554 0.1951 0.2728 0.2471 0.2801 0.2919 0.2751 0.2357 0.1943 0.2689 0.3188 0.2968
26 25 20.8 4.2 4.2 0.3089 0.2554 0.3712 0.2728 0.2759 0.3783 0.3144 0.28 0.4209 0.4124 0.3526 0.3255 0.2319
65 24.5 20.4 4.1 4.1 0.2637 0.2554 0.2765 0.2728 0.3105 0.2556 0.22 0.2411 0.2621 0.2856 0.3177 0.3268 0.3014
12 18.6 14.6 4 4 0.2633 0.2554 0.2638 0.2728 0.268 0.3074 0.3375 0.2537 0.2533 0.2824 0.377 0.06098 0.2701
50 5.6 9.6 4 -4 0.4693 0.2554 0.3712 0.2728 0.3812 0.2622 0.3775 0.2112 0.4209 0.4124 0.3526 0.3268 0.4408

Cleaning up

To clean up all GCP resources used in this project, you can delete the GCP project you used for the tutorial.


In [ ]:
# If training job is still running, cancel it
! gcloud ai-platform jobs cancel $job_name --quiet

# Delete Cloud Storage objects that were created
! gsutil -m rm -r $BUCKET_NAME