Explore and create ML datasets

In this notebook, we will explore data corresponding to taxi rides in New York City to build a Machine Learning model in support of a fare-estimation tool. The idea is to suggest a likely fare to taxi riders so that they are not surprised, and so that they can protest if the charge is much higher than expected.

Learning Objectives

  • Access and explore a public BigQuery dataset on NYC Taxi Cab rides
  • Visualize your dataset using the Seaborn library
  • Inspect and clean-up the dataset for future ML model training
  • Create a benchmark to judge future ML model performance off of

Each learning objective will correspond to a #TODO in the student lab notebook -- try to complete that notebook first before reviewing this solution notebook.

Let's start with the Python imports that we need.


In [ ]:
!sudo chown -R jupyter:jupyter /home/jupyter/training-data-analyst

In [1]:
from google.cloud import bigquery
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

Extract sample data from BigQuery

The dataset that we will use is a BigQuery public dataset. Click on the link, and look at the column names. Switch to the Details tab to verify that the number of records is one billion, and then switch to the Preview tab to look at a few rows.

Let's write a SQL query to pick up interesting fields from the dataset. It's a good idea to get the timestamp in a predictable format.


In [2]:
%%bigquery
SELECT
    FORMAT_TIMESTAMP(
        "%Y-%m-%d %H:%M:%S %Z", pickup_datetime) AS pickup_datetime,
    pickup_longitude, pickup_latitude, dropoff_longitude,
    dropoff_latitude, passenger_count, trip_distance, tolls_amount, 
    fare_amount, total_amount 
FROM
    `nyc-tlc.yellow.trips` # TODO 1
LIMIT 10


Out[2]:
pickup_datetime pickup_longitude pickup_latitude dropoff_longitude dropoff_latitude passenger_count trip_distance tolls_amount fare_amount total_amount
0 2010-03-04 00:35:16 UTC -74.035201 40.721548 -74.035201 40.721548 1 0.0 0.0 0.0 0.0
1 2010-03-15 17:18:34 UTC 0.000000 0.000000 0.000000 0.000000 1 0.0 0.0 0.0 0.0
2 2015-03-18 01:07:02 UTC 0.000000 0.000000 0.000000 0.000000 5 0.0 0.0 0.0 0.0
3 2015-03-09 18:24:03 UTC -73.937248 40.758202 -73.937263 40.758190 1 0.0 0.0 0.0 0.0
4 2010-03-06 06:33:41 UTC -73.785514 40.645400 -73.784564 40.648681 2 4.1 0.0 0.0 0.0
5 2013-08-07 00:42:45 UTC -74.025817 40.763044 -74.046752 40.783240 1 4.8 0.0 0.0 0.0
6 2015-04-26 02:56:37 UTC -73.987656 40.771656 -73.987556 40.771751 1 0.0 0.0 0.0 0.0
7 2015-04-29 18:45:03 UTC 0.000000 0.000000 0.000000 0.000000 1 1.0 0.0 0.0 0.0
8 2010-03-11 21:24:48 UTC -74.571511 40.910800 -74.628928 40.964321 1 68.4 0.0 0.0 0.0
9 2013-08-24 01:58:23 UTC -73.972171 40.759439 0.000000 0.000000 4 0.0 0.0 0.0 0.0

Let's increase the number of records so that we can do some neat graphs. There is no guarantee about the order in which records are returned, and so no guarantee about which records get returned if we simply increase the LIMIT. To properly sample the dataset, let's use the HASH of the pickup time and return 1 in 100,000 records -- because there are 1 billion records in the data, we should get back approximately 10,000 records if we do this.

We will also store the BigQuery result in a Pandas dataframe named "trips"


In [3]:
%%bigquery trips
SELECT
    FORMAT_TIMESTAMP(
        "%Y-%m-%d %H:%M:%S %Z", pickup_datetime) AS pickup_datetime,
    pickup_longitude, pickup_latitude, 
    dropoff_longitude, dropoff_latitude,
    passenger_count,
    trip_distance,
    tolls_amount,
    fare_amount,
    total_amount
FROM
    `nyc-tlc.yellow.trips`
WHERE
    ABS(MOD(FARM_FINGERPRINT(CAST(pickup_datetime AS STRING)), 100000)) = 1

In [4]:
print(len(trips))


10789

In [5]:
# We can slice Pandas dataframes as if they were arrays
trips[:10]


Out[5]:
pickup_datetime pickup_longitude pickup_latitude dropoff_longitude dropoff_latitude passenger_count trip_distance tolls_amount fare_amount total_amount
0 2009-02-12 17:51:38 UTC -73.965325 40.769670 -73.980505 40.748393 1 1.70 0.0 11.1 11.60
1 2012-02-27 09:19:10 UTC -73.874431 40.774011 -73.983967 40.744082 1 11.60 4.8 27.7 38.00
2 2014-05-20 23:09:00 UTC -73.995203 40.727307 -73.948775 40.813487 1 10.31 0.0 33.5 38.00
3 2014-04-30 16:45:10 UTC -73.989434 40.756601 -73.949989 40.826892 1 6.20 0.0 24.5 31.20
4 2013-04-09 09:39:13 UTC -73.981443 40.763466 -74.010072 40.704927 1 6.50 0.0 24.5 30.00
5 2014-04-19 14:08:46 UTC -73.964716 40.773071 -73.997511 40.697289 1 8.70 0.0 26.5 33.75
6 2009-03-08 08:51:42 UTC -73.777129 40.645050 -73.944360 40.662902 1 15.40 0.0 38.9 38.90
7 2014-05-17 15:15:00 UTC -73.980682 40.734032 -73.961948 40.755545 1 2.20 0.0 22.5 23.00
8 2009-11-01 02:59:23 UTC -74.006934 40.734067 -73.895708 40.851511 4 12.10 0.0 28.5 29.50
9 2009-03-28 20:30:35 UTC -73.973926 40.757725 -73.981695 40.761591 1 0.50 0.0 4.6 4.60

Exploring data

Let's explore this dataset and clean it up as necessary. We'll use the Python Seaborn package to visualize graphs and Pandas to do the slicing and filtering.


In [6]:
# TODO 2
ax = sns.regplot(
    x="trip_distance", y="fare_amount",
    fit_reg=False, ci=None, truncate=True, data=trips)
ax.figure.set_size_inches(10, 8)


Hmm ... do you see something wrong with the data that needs addressing?

It appears that we have a lot of invalid data that is being coded as zero distance and some fare amounts that are definitely illegitimate. Let's remove them from our analysis. We can do this by modifying the BigQuery query to keep only trips longer than zero miles and fare amounts that are at least the minimum cab fare ($2.50).

Note the extra WHERE clauses.


In [7]:
%%bigquery trips
SELECT
    FORMAT_TIMESTAMP(
        "%Y-%m-%d %H:%M:%S %Z", pickup_datetime) AS pickup_datetime,
    pickup_longitude, pickup_latitude, 
    dropoff_longitude, dropoff_latitude,
    passenger_count,
    trip_distance,
    tolls_amount,
    fare_amount,
    total_amount
FROM
    `nyc-tlc.yellow.trips`
WHERE
    ABS(MOD(FARM_FINGERPRINT(CAST(pickup_datetime AS STRING)), 100000)) = 1
# TODO 3
    AND trip_distance > 0
    AND fare_amount >= 2.5

In [8]:
print(len(trips))


10716

In [9]:
ax = sns.regplot(
    x="trip_distance", y="fare_amount",
    fit_reg=False, ci=None, truncate=True, data=trips)
ax.figure.set_size_inches(10, 8)


What's up with the streaks around 45 dollars and 50 dollars? Those are fixed-amount rides from JFK and La Guardia airports into anywhere in Manhattan, i.e. to be expected. Let's list the data to make sure the values look reasonable.

Let's also examine whether the toll amount is captured in the total amount.


In [10]:
tollrides = trips[trips["tolls_amount"] > 0]
tollrides[tollrides["pickup_datetime"] == "2012-02-27 09:19:10 UTC"]


Out[10]:
pickup_datetime pickup_longitude pickup_latitude dropoff_longitude dropoff_latitude passenger_count trip_distance tolls_amount fare_amount total_amount
2 2012-02-27 09:19:10 UTC -73.874431 40.774011 -73.983967 40.744082 1 11.6 4.8 27.7 38.0

In [12]:
notollrides = trips[trips["tolls_amount"] == 0]
notollrides[notollrides["pickup_datetime"] == "2012-02-27 09:19:10 UTC"]


Out[12]:
pickup_datetime pickup_longitude pickup_latitude dropoff_longitude dropoff_latitude passenger_count trip_distance tolls_amount fare_amount total_amount
47 2012-02-27 09:19:10 UTC -73.972311 40.753067 -73.957389 40.817824 1 5.6 0.0 16.9 22.62
7750 2012-02-27 09:19:10 UTC -73.987582 40.725468 -74.016628 40.715534 1 2.8 0.0 12.1 15.75
10544 2012-02-27 09:19:10 UTC -74.015483 40.715279 -73.998045 40.756273 1 3.3 0.0 10.9 13.40

Looking at a few samples above, it should be clear that the total amount reflects fare amount, toll and tip somewhat arbitrarily -- this is because when customers pay cash, the tip is not known. So, we'll use the sum of fare_amount + tolls_amount as what needs to be predicted. Tips are discretionary and do not have to be included in our fare estimation tool.

Let's also look at the distribution of values within the columns.


In [13]:
trips.describe()


Out[13]:
pickup_longitude pickup_latitude dropoff_longitude dropoff_latitude passenger_count trip_distance tolls_amount fare_amount total_amount
count 10716.000000 10716.000000 10716.000000 10716.000000 10716.000000 10716.000000 10716.000000 10716.000000 10716.000000
mean -72.602192 40.002372 -72.594838 40.002052 1.650056 2.856395 0.226428 11.109446 13.217078
std 9.982373 5.474670 10.004324 5.474648 1.283577 3.322024 1.135934 9.137710 10.953156
min -74.258183 0.000000 -74.260472 0.000000 0.000000 0.010000 0.000000 2.500000 2.500000
25% -73.992153 40.735936 -73.991566 40.734310 1.000000 1.040000 0.000000 6.000000 7.300000
50% -73.981851 40.753264 -73.980373 40.752956 1.000000 1.770000 0.000000 8.500000 10.000000
75% -73.967400 40.767340 -73.964142 40.767510 2.000000 3.160000 0.000000 12.500000 14.600000
max 0.000000 41.366138 0.000000 41.366138 6.000000 42.800000 16.000000 179.000000 179.000000

Hmm ... The min, max of longitude look strange.

Finally, let's actually look at the start and end of a few of the trips.


In [14]:
def showrides(df, numlines):
    lats = []
    lons = []
    for iter, row in df[:numlines].iterrows():
        lons.append(row["pickup_longitude"])
        lons.append(row["dropoff_longitude"])
        lons.append(None)
        lats.append(row["pickup_latitude"])
        lats.append(row["dropoff_latitude"])
        lats.append(None)

    sns.set_style("darkgrid")
    plt.figure(figsize=(10, 8))
    plt.plot(lons, lats)

In [15]:
showrides(notollrides, 10)



In [16]:
showrides(tollrides, 10)


As you'd expect, rides that involve a toll are longer than the typical ride.

Quality control and other preprocessing

We need to do some clean-up of the data:

  1. New York city longitudes are around -74 and latitudes are around 41.
  2. We shouldn't have zero passengers.
  3. Clean up the total_amount column to reflect only fare_amount and tolls_amount, and then remove those two columns.
  4. Before the ride starts, we'll know the pickup and dropoff locations, but not the trip distance (that depends on the route taken), so remove it from the ML dataset
  5. Discard the timestamp

We could do preprocessing in BigQuery, similar to how we removed the zero-distance rides, but just to show you another option, let's do this in Python. In production, we'll have to carry out the same preprocessing on the real-time input data.

This sort of preprocessing of input data is quite common in ML, especially if the quality-control is dynamic.


In [17]:
def preprocess(trips_in):
    trips = trips_in.copy(deep=True)
    trips.fare_amount = trips.fare_amount + trips.tolls_amount
    del trips["tolls_amount"]
    del trips["total_amount"]
    del trips["trip_distance"]  # we won't know this in advance!

    qc = np.all([
        trips["pickup_longitude"] > -78,
        trips["pickup_longitude"] < -70,
        trips["dropoff_longitude"] > -78,
        trips["dropoff_longitude"] < -70,
        trips["pickup_latitude"] > 37,
        trips["pickup_latitude"] < 45,
        trips["dropoff_latitude"] > 37,
        trips["dropoff_latitude"] < 45,
        trips["passenger_count"] > 0
    ], axis=0)

    return trips[qc]

tripsqc = preprocess(trips)
tripsqc.describe()


Out[17]:
pickup_longitude pickup_latitude dropoff_longitude dropoff_latitude passenger_count fare_amount
count 10476.000000 10476.000000 10476.000000 10476.000000 10476.000000 10476.000000
mean -73.975206 40.751526 -73.974373 40.751199 1.653303 11.349003
std 0.038547 0.029187 0.039086 0.033147 1.278827 9.878630
min -74.258183 40.452290 -74.260472 40.417750 1.000000 2.500000
25% -73.992336 40.737600 -73.991739 40.735904 1.000000 6.000000
50% -73.982090 40.754020 -73.980780 40.753597 1.000000 8.500000
75% -73.968517 40.767774 -73.965851 40.767921 2.000000 12.500000
max -73.137393 41.366138 -73.137393 41.366138 6.000000 179.000000

The quality control has removed about 300 rows (11400 - 11101) or about 3% of the data. This seems reasonable.

Let's move on to creating the ML datasets.

Create ML datasets

Let's split the QCed data randomly into training, validation and test sets. Note that this is not the entire data. We have 1 billion taxicab rides. This is just splitting the 10,000 rides to show you how it's done on smaller datasets. In reality, we'll have to do it on all 1 billion rides and this won't scale.


In [18]:
shuffled = tripsqc.sample(frac=1)
trainsize = int(len(shuffled["fare_amount"]) * 0.70)
validsize = int(len(shuffled["fare_amount"]) * 0.15)

df_train = shuffled.iloc[:trainsize, :]
df_valid = shuffled.iloc[trainsize:(trainsize + validsize), :]
df_test = shuffled.iloc[(trainsize + validsize):, :]

In [19]:
df_train.head(n=1)


Out[19]:
pickup_datetime pickup_longitude pickup_latitude dropoff_longitude dropoff_latitude passenger_count fare_amount
9718 2011-07-27 09:45:56 UTC -73.98012 40.730552 -73.990246 40.756076 2 11.3

In [20]:
df_train.describe()


Out[20]:
pickup_longitude pickup_latitude dropoff_longitude dropoff_latitude passenger_count fare_amount
count 7333.000000 7333.000000 7333.000000 7333.000000 7333.000000 7333.000000
mean -73.975458 40.751361 -73.974390 40.751321 1.642029 11.339677
std 0.035886 0.027382 0.038016 0.032218 1.258757 9.643396
min -74.258183 40.608573 -74.260472 40.561076 1.000000 2.500000
25% -73.992532 40.737748 -73.991604 40.736398 1.000000 6.000000
50% -73.982140 40.754077 -73.980835 40.753983 1.000000 8.500000
75% -73.968541 40.767605 -73.965786 40.768035 2.000000 12.500000
max -73.137393 41.366138 -73.137393 41.366138 6.000000 179.000000

In [21]:
df_valid.describe()


Out[21]:
pickup_longitude pickup_latitude dropoff_longitude dropoff_latitude passenger_count fare_amount
count 1571.000000 1571.000000 1571.000000 1571.000000 1571.000000 1571.000000
mean -73.973921 40.752835 -73.973232 40.751910 1.698281 11.190777
std 0.047222 0.034633 0.045578 0.039445 1.330913 10.243204
min -74.043078 40.452290 -74.181608 40.417750 1.000000 2.500000
25% -73.991508 40.738050 -73.991885 40.735402 1.000000 6.000000
50% -73.981873 40.754845 -73.980273 40.753456 1.000000 8.100000
75% -73.968047 40.768333 -73.963515 40.768279 2.000000 12.100000
max -73.137393 41.366138 -73.137393 41.366138 6.000000 144.800000

In [22]:
df_test.describe()


Out[22]:
pickup_longitude pickup_latitude dropoff_longitude dropoff_latitude passenger_count fare_amount
count 1572.000000 1572.000000 1572.000000 1572.000000 1572.000000 1572.000000
mean -73.975317 40.750986 -73.975436 40.749916 1.660941 11.550636
std 0.040827 0.031306 0.036921 0.030409 1.317821 10.571027
min -74.187541 40.633522 -74.187541 40.590919 1.000000 2.900000
25% -73.992529 40.736388 -73.992098 40.734470 1.000000 6.000000
50% -73.982109 40.753436 -73.981128 40.752893 1.000000 8.500000
75% -73.969370 40.767797 -73.967812 40.766533 2.000000 12.500000
max -73.137393 41.366138 -73.776288 41.001380 6.000000 99.300000

Let's write out the three dataframes to appropriately named csv files. We can use these csv files for local training (recall that these files represent only 1/100,000 of the full dataset) just to verify our code works, before we run it on all the data.


In [23]:
def to_csv(df, filename):
    outdf = df.copy(deep=False)
    outdf.loc[:, "key"] = np.arange(0, len(outdf))  # rownumber as key
    # Reorder columns so that target is first column
    cols = outdf.columns.tolist()
    cols.remove("fare_amount")
    cols.insert(0, "fare_amount")
    print (cols)  # new order of columns
    outdf = outdf[cols]
    outdf.to_csv(filename, header=False, index_label=False, index=False)

to_csv(df_train, "taxi-train.csv")
to_csv(df_valid, "taxi-valid.csv")
to_csv(df_test, "taxi-test.csv")


['fare_amount', 'pickup_datetime', 'pickup_longitude', 'pickup_latitude', 'dropoff_longitude', 'dropoff_latitude', 'passenger_count', 'key']
['fare_amount', 'pickup_datetime', 'pickup_longitude', 'pickup_latitude', 'dropoff_longitude', 'dropoff_latitude', 'passenger_count', 'key']
['fare_amount', 'pickup_datetime', 'pickup_longitude', 'pickup_latitude', 'dropoff_longitude', 'dropoff_latitude', 'passenger_count', 'key']

In [24]:
!head -10 taxi-valid.csv


6.0,2013-10-13 10:02:20 UTC,-73.950821,40.810753,-73.964465,40.807449,1,0
120.0,2015-04-28 15:00:24 UTC,-73.86323547363281,40.76896286010742,-73.964599609375,40.9226188659668,1,1
7.5,2012-12-31 21:07:30 UTC,-74.000094,40.738104,-73.985071,40.736013,2,2
9.5,2014-11-16 09:00:22 UTC,-73.968167,40.75261,-73.958636,40.778393,2,3
9.3,2012-02-03 19:07:41 UTC,-73.970027,40.789105,-73.987416,40.761225,1,4
4.5,2015-04-21 23:19:43 UTC,-73.97529602050781,40.76133728027344,-73.96334838867188,40.75605392456055,1,5
6.1,2011-11-22 07:39:09 UTC,-73.969197,40.764832,-73.980742,40.774061,2,6
20.0,2013-04-02 21:15:20 UTC,-73.992788,40.749358,-73.963698,40.716271,1,7
5.7,2012-04-13 22:23:16 UTC,-73.99782,40.745847,-73.993732,40.732632,1,8
8.9,2009-07-18 01:19:34 UTC,-73.987535,40.749581,-73.991891,40.721913,1,9

Verify that datasets exist


In [25]:
!ls -l *.csv


-rw-r--r-- 1 jupyter jupyter 123269 Nov  6 04:53 taxi-test.csv
-rw-r--r-- 1 jupyter jupyter 579473 Nov  6 04:53 taxi-train.csv
-rw-r--r-- 1 jupyter jupyter 123017 Nov  6 04:53 taxi-valid.csv

We have 3 .csv files corresponding to train, valid, test. The ratio of file-sizes correspond to our split of the data.


In [26]:
%%bash
head taxi-train.csv


11.3,2011-07-27 09:45:56 UTC,-73.98012,40.730552,-73.990246,40.756076,2,0
10.0,2014-12-08 21:50:00 UTC,-73.97866,40.752247,-73.955233,40.777127,1,1
11.0,2013-12-26 18:32:32 UTC,-73.873022,40.774008,-73.907011,40.779224,1,2
8.5,2013-03-07 17:27:13 UTC,-73.951629,40.766381,-73.9672,40.763297,1,3
17.5,2014-05-17 15:15:00 UTC,-73.973497,40.75226,-73.98016,40.783375,1,4
4.5,2012-07-19 06:27:00 UTC,-73.986312,40.762285,-73.989482,40.7522,2,5
6.9,2012-04-18 22:37:09 UTC,-73.955483,40.77361,-73.950013,40.775647,3,6
8.1,2010-12-21 13:08:00 UTC,-73.96252,40.754513,-73.988832,40.755882,5,7
7.3,2010-12-19 18:25:51 UTC,-73.967995,40.765737,-73.981012,40.7446,1,8
7.5,2014-10-06 15:16:00 UTC,-73.99088,40.73448,-74.00699,40.72737,1,9

Looks good! We now have our ML datasets and are ready to train ML models, validate them and evaluate them.

Benchmark

Before we start building complex ML models, it is a good idea to come up with a very simple model and use that as a benchmark.

My model is going to be to simply divide the mean fare_amount by the mean trip_distance to come up with a rate and use that to predict. Let's compute the RMSE of such a model.


In [27]:
def distance_between(lat1, lon1, lat2, lon2):
    # Haversine formula to compute distance "as the crow flies".
    lat1_r = np.radians(lat1)
    lat2_r = np.radians(lat2)
    lon_diff_r = np.radians(lon2 - lon1)
    sin_prod = np.sin(lat1_r) * np.sin(lat2_r)
    cos_prod = np.cos(lat1_r) * np.cos(lat2_r) * np.cos(lon_diff_r)
    minimum = np.minimum(1, sin_prod + cos_prod)
    dist = np.degrees(np.arccos(minimum)) * 60 * 1.515 * 1.609344

    return dist

def estimate_distance(df):
    return distance_between(
        df["pickuplat"], df["pickuplon"], df["dropofflat"], df["dropofflon"])

def compute_rmse(actual, predicted):
    return np.sqrt(np.mean((actual - predicted) ** 2))

def print_rmse(df, rate, name):
    print ("{1} RMSE = {0}".format(
        compute_rmse(df["fare_amount"], rate * estimate_distance(df)), name))

# TODO 4
FEATURES = ["pickuplon", "pickuplat", "dropofflon", "dropofflat", "passengers"]
TARGET = "fare_amount"
columns = list([TARGET])
columns.append("pickup_datetime")
columns.extend(FEATURES)  # in CSV, target is first column, after the features
columns.append("key")
df_train = pd.read_csv("taxi-train.csv", header=None, names=columns)
df_valid = pd.read_csv("taxi-valid.csv", header=None, names=columns)
df_test = pd.read_csv("taxi-test.csv", header=None, names=columns)
rate = df_train["fare_amount"].mean() / estimate_distance(df_train).mean()
print ("Rate = ${0}/km".format(rate))
print_rmse(df_train, rate, "Train")
print_rmse(df_valid, rate, "Valid") 
print_rmse(df_test, rate, "Test")


Rate = $2.5942426114682986/km
Train RMSE = 7.037332431803795
Valid RMSE = 7.5827177000074
Test RMSE = 9.751687930029119

Benchmark on same dataset

The RMSE depends on the dataset, and for comparison, we have to evaluate on the same dataset each time. We'll use this query in later labs:


In [28]:
validation_query = """
SELECT
    (tolls_amount + fare_amount) AS fare_amount,
    pickup_datetime,
    pickup_longitude AS pickuplon,
    pickup_latitude AS pickuplat,
    dropoff_longitude AS dropofflon,
    dropoff_latitude AS dropofflat,
    passenger_count*1.0 AS passengers,
    "unused" AS key
FROM
    `nyc-tlc.yellow.trips`
WHERE
    ABS(MOD(FARM_FINGERPRINT(CAST(pickup_datetime AS STRING)), 10000)) = 2
    AND trip_distance > 0
    AND fare_amount >= 2.5
    AND pickup_longitude > -78
    AND pickup_longitude < -70
    AND dropoff_longitude > -78
    AND dropoff_longitude < -70
    AND pickup_latitude > 37
    AND pickup_latitude < 45
    AND dropoff_latitude > 37
    AND dropoff_latitude < 45
    AND passenger_count > 0
"""

client = bigquery.Client()
df_valid = client.query(validation_query).to_dataframe()
print_rmse(df_valid, 2.59988, "Final Validation Set")


Final Validation Set RMSE = 8.135336354024895

The simple distance-based rule gives us a RMSE of $8.14. We have to beat this, of course, but you will find that simple rules of thumb like this can be surprisingly difficult to beat.

Let's be ambitious, though, and make our goal to build ML models that have a RMSE of less than $6 on the test set.

Copyright 2020 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.