Key Word(s): visualization, plotting, graphing, matplotlib, design
Title¶
Exercise: Visualization
Description¶
For this exercise, we will continue to work with the Boston housing prices dataset that comes with sklearn
(as we did in Lecture 13). Details about the dataset and its columns are available here.
In this Exercise, I want you all to get creative and experiment! Instead of rigidly plotting exactly something that we ask, I want you to think of what you would be interested in plotting and exploring. Specifically, for this exercise, you have the utmost freedom to plot anything that you'd like from this data. You're expected to produce two plots, both of which should adhere to the principles learned in lecture (e.g., make it clear to understand/digest, effective, simple, not misleading, etc). Please feel inspired to challenge yourself by making a a type of plot you've never made before -- perhaps never even seen before! Further, you are not confined to using matplotlib; you can use any Python visualization library you want.
We load the data into a Pandas DataFrame for you, in case you find this helpful. Feel free to ignore this DataFrame if you rather just work directly with the data. It's totally up to you!
Resource: for tons of great coding examples, visit the matplotlib website.
CS109A Introduction to Data Science
Lecture 14, Exercise: Visualization¶
Harvard University
Fall 2020
Instructors: Pavlos Protopapas, Kevin Rader, and Chris Tanner
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.datasets import load_boston
# load the boston housing dataset
boston = load_boston()
boston_pd = pd.DataFrame(boston.data)
boston_pd.columns = boston.feature_names
boston_pd.describe()
# our canonical example
plt.figure(figsize=(5, 4))
plt.hist(boston.target)
plt.title('Boston Housing Prices')
plt.xlabel('Price ($1000s)')
plt.ylabel('# of Houses')
plt.show()
# YOUR FIRST PLOT
# YOUR SECOND PLOT