Visualizing numeric vs. categorical
If the explanatory variable is categorical, the scatter plot that you used before to visualize the data doesn't make sense. Instead, a good option is to draw a histogram for each category.
The Taiwan real estate dataset has a categorical variable in the form of the age of each house. The ages have been split into 3 groups: 0 to 15 years, 15 to 30 years, and 30 to 45 years.
taiwan_real_estate is available.
Deze oefening maakt deel uit van de cursus
Introduction to Regression with statsmodels in Python
Oefeninstructies
- Using
taiwan_real_estate, plot a histogram ofprice_twd_msqwith10bins. Split the plot byhouse_age_yearsto give 3 panels.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Histograms of price_twd_msq with 10 bins, split by the age of each house
sns.____(data=____,
x=____,
____=____,
____=____)
# Show the plot
____