To understand how variables in a dataset are related to one another and how that relationship is dependent on other variables, we perform statistical analysis. This Statistical analysis helps to visualize the trends and identify various patterns in the dataset. One of the functions which can be used to get the relationship between two variables in Seaborn is
Relplot() combines FacetGrid with either of the two axes-level functions scatterplot() and lineplot(). Scatterplot is default kind of relplot(). Using this we can visualize joint distribution of two variables through a cloud of points. We can draw scatterplot in seaborn using various ways. The most common one is when both the variables are numeric.
Example: Let’s take an example of a dataset that consists a data of CO2 emissions of different vehicles. To get the dataset click here.
Let’s plot the basic scatterplot for visualizing the relation between the target variable “CO2EMISSIOnS” and “ENGINE SIZE”
We can add visualize one more variable by adding another dimension to the plot. This can be done by using “hue”, which colors the points of the third variable, thus adding a meaning to it.
To highlight the different classes, we can add marker styles
In the previous example, hue semantic was for a categorical variable, so it had a default qualitative palette. But if we use a numerical variable instead of categorical, then the default palette used is sequential, which can be modified too.
We can also change the size of points for the third variable.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.