<jupyter_start><jupyter_text>9 - (b) What is the range of each quantitative predictor?  9 - (c) What is the mean and standard deviation of each quantitative predictor?<jupyter_code>X.describe()<jupyter_output><empty_output><jupyter_text>9 - (d) Now remove the 10th through 85th observations. What is the range, mean, and standard deviation of each predictor in the subset of the data that remains?<jupyter_code>X2 = X.drop(list(range(9, 32)) + list(range(33, 85)), axis = 0)
X2.describe()<jupyter_output><empty_output><jupyter_text>9 - (e) Using the full data set, investigate the predictors graphically, using scatterplots or other tools of your choice. Create some plots highlighting the relationships among the predictors. Comment on your findings.  9 - (f) Suppose that we wish to predict gas mileage (mpg) on the basis of the other variables. Do your plots suggest that any of the other variables might be useful in predicting mpg? Justify your answer.<jupyter_code>fcols = X.columns.copy()
X = X.reset_index(drop = True)
X.columns = fcols
sns.pairplot(X.iloc[:, :-2])
# the correlation removes the variance thus X2 / X makes no difference
Y = X.iloc[:, :-2].corr()
plt.figure(figsize = (7, 7))
# Generate a mask for the upper triangle
mask = np.zeros_like(Y, dtype=np.bool)
mask[np.triu_indices_from(mask)] = True
# Generate a custom diverging colormap
cmap = sns.diverging_palette(220, 10, as_cmap=True)
sns.heatmap(Y, mask=mask, cmap=cmap, vmax=.5, vmin = -.5, linewidths=.5, square=True, cbar_kws={"shrink": .5})
# since there are too many unique 'name', create 'brand' column instead
Nrow, Ncol = X.shape
brands = []
for i in range(Nrow):
    ibrand = X['name'].iloc[i].split(' ')[0]
    brands.append(ibrand)
brands = pd.DataFrame(brands, columns = ['brand'])
X = pd.concat([X, brands], axis = 1)
brands0 = X['brand'].value_counts()
plt.figure(figsize = (20, 8))
cnt = 0
for ibrand in range(len(brands0)):
    if brands0[ibrand] < 15: continue # only keep brands with 'enough' observations
    cnt += 1
    plt.subplot(2, 5, cnt)
    sns.distplot(X[X['brand'] == brands0.index[ibrand]]['mpg'])
    plt.xlabel(brands0.index[ibrand])<jupyter_output>/Users/pinqingkan/anaconda/lib/python3.6/site-packages/matplotlib/axes/_axes.py:6462: UserWarning: The 'normed' kwarg is deprecated, and has been replaced by the 'density' kwarg.
  warnings.warn("The 'normed' kwarg is deprecated, and has been "
/Users/pinqingkan/anaconda/lib/python3.6/site-packages/matplotlib/axes/_axes.py:6462: UserWarning: The 'normed' kwarg is deprecated, and has been replaced by the 'density' kwarg.
  warnings.warn("The 'normed' kwarg is deprecated, and has been "
/Users/pinqingkan/anaconda/lib/python3.6/site-packages/matplotlib/axes/_axes.py:6462: UserWarning: The 'normed' kwarg is deprecated, and has been replaced by the 'density' kwarg.
  warnings.warn("The 'normed' kwarg is deprecated, and has been "
/Users/pinqingkan/anaconda/lib/python3.6/site-packages/matplotlib/axes/_axes.py:6462: UserWarning: The 'normed' kwarg is deprecated, and has been replaced by the 'density' kwarg.
  warnings.warn("The 'normed' kwarg is deprecated, and has been "
/Users/pinqingkan/an[...]
{'fraction_non_alphanumeric': 0.12646221941195068, 'fraction_numerical': 0.023079355042681, 'mean_word_length': 5.026666666666666, 'pattern_counts': {'":': 1, '<': 13, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '274328', 'license': 'MIT', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1075, 'n_words': 334, 'path': 'chap2_autoData.ipynb', 'repo_name': 'rongqingpin/ISLR7', 'size': '3163'}