CommencerCommencer gratuitement

Visualizing three numeric variables

There are also some "flat" alternatives to 3D plots that provide easier interpretation, though they require a little thinking about to make. A good approach is plotting the two numeric explanatory variables on the x- and y-axis of a scatter plot, and coloring the points according to the response variable.

taiwan_real_estate is available.

Cet exercice fait partie du cours

Intermediate Regression with statsmodels in Python

Afficher le cours

Instructions

  • Calculate the square-root of the distance to the nearest MRT stop as sqrt_dist_to_mrt_m.
  • With the taiwan_real_estate dataset, draw a scatter plot of sqrt_dist_to_mrt_m versus the number of nearby convenience stores, colored by house price.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Transform dist_to_mrt_m to sqrt_dist_to_mrt_m
taiwan_real_estate["sqrt_dist_to_mrt_m"] = ____

# Draw a scatter plot of sqrt_dist_to_mrt_m vs. n_convenience colored by price_twd_msq
____

# Show the plot
plt.show()
Modifier et exécuter le code