<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Predicting Flight Delays Tutorial
Step1:  This notebook will develop a model aimed at predicting flight delays at take-off.
The focus is not on the results but instead on the process behind developing a machine learning classifier that can do the job.
We will discuss separating your data into training and test sets, how to build linear and polynomial models for univariate or multivariate regressions, and how to regularize parameters.
Let's have a quick look at our data
Step2:  A description of the variable names can be found here, and we can see that we are dealing with ~5.8 million flights from 2015.
The categories that we will deal with in this notebook are
Step3:  Now it's time for a look at our airports data
<ASSISTANT_TASK:>
Python Code:
import datetime, warnings, scipy 
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from matplotlib.patches import ConnectionPatch
from collections import OrderedDict
from matplotlib.gridspec import GridSpec
# https://github.com/matplotlib/basemap
# from mpl_toolkits.basemap import Basemap
# https://stackoverflow.com/questions/42299352/installing-basemap-on-mac-python
from sklearn import metrics, linear_model
from sklearn.preprocessing import PolynomialFeatures, StandardScaler
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
from sklearn.model_selection import train_test_split, cross_val_score, cross_val_predict
from scipy.optimize import curve_fit
plt.rcParams["patch.force_edgecolor"] = True
plt.style.use('fivethirtyeight')
mpl.rc('patch', edgecolor = 'dimgray', linewidth=1)
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "last_expr"
pd.options.display.max_columns = 50
%matplotlib inline
warnings.filterwarnings("ignore")
Explanation: Predicting Flight Delays Tutorial
End of explanation
df = pd.read_csv('flight_delays_data/flights.csv', low_memory=False)
df.shape
df.describe()
df.head()
Explanation: This notebook will develop a model aimed at predicting flight delays at take-off.
The focus is not on the results but instead on the process behind developing a machine learning classifier that can do the job.
We will discuss separating your data into training and test sets, how to build linear and polynomial models for univariate or multivariate regressions, and how to regularize parameters.
Let's have a quick look at our data:
End of explanation
tab_info = pd.DataFrame(df.dtypes).T.rename(index={0:'column type'})
tab_info
tab_info = tab_info.append(pd.DataFrame(df.isnull().sum()).T.rename(index={0:'null values'}))
tab_info
tab_info = tab_info.append(pd.DataFrame(df.isnull().sum() / df.shape[0] * 100).T.rename(index={0:'% null values'}))
tab_info
Explanation: A description of the variable names can be found here, and we can see that we are dealing with ~5.8 million flights from 2015.
The categories that we will deal with in this notebook are:
 YEAR, MONTH, DAY, DAY_OF_WEEK: dates of the flight.
 AIRLINE: An identification number assigned by US DOT to identify a unique airline.
* ORIGIN_AIRPORT and DESTINATION_AIRPORT: code attributed by IATA to identify the airports.
* SCHEDULED_DEPARTURE and SCHEDULED_ARRIVAL: scheduled times of take-off and landing.
* DEPARTURE_TIME and ARRIVAL_TIME: real times at which take-off and landing took place.
* DEPARTURE_DELAY and ARRIVAL_DELAY: difference (in minutes) between planned and real times.
* DISTANCE: distance (in miles)
Let's find out about the column types and number of null values:
End of explanation
airports = pd.read_csv('flight_delays_data/airports.csv')
# Wouldn't it be nice if your data was always just cleaned up and ready to go?
# TODO: Teach machines to clean my data.
airports.describe()
airports.head()
Explanation: Now it's time for a look at our airports data:
End of explanation
<END_TASK>