Creating your first ML model

In this section, we will build and implement the code in our first ML model. We will use the diamond prices dataset. Before moving on, let's load the libraries we will use in this notebook:

import numpy as npimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport os%matplotlib inline

Now, load the diamonds dataset and apply the transformations we have done before:

DATA_DIR = '../data'FILE_NAME = 'diamonds.csv'data_path = os.path.join(DATA_DIR, FILE_NAME)diamonds = pd.read_csv(data_path)## Preparation done from Chapter 2diamonds = diamonds.loc[(diamonds['x']>0) | (diamonds['y']>0)]diamonds.loc[11182, 'x'] = diamonds['x'].median()diamonds = diamonds.loc[~((diamonds['y'] > 30) | (diamonds['z'] ...

Get Hands-On Predictive Analytics with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.