Python Tutorial: Regression Plots in Seaborn

preview_player
Показать описание

---
Now that we have taken a look at distribution plots in Seaborn, we will transition to another basic visualization process by plotting linear regression lines. The previous analysis we performed is often referred to as univariate analysis because we only look at one variable. Regression analysis is bivariate because we are looking for relationships between two variables.

The regplot() function is the basis for building regression plots in Seaborn. The basic function call is similar to distplot(), but we explicitly define the x and y variables as well as the source of the data. Since we are using a pandas DataFrame, the x and y variables refer to the columns in the DataFrame. This basic process is similar for many other Seaborn plots so it is good to make sure you understand this well before moving on to more complex plots.

In this specific plot, we are interested in any relationship between the alcohol content of the wine and the pH levels. The regression line hints that there might be a slight increase in pH values as the alcohol content increases.

One of the confusing points about Seaborn is that it may seem like there is more than one way to do the same plot. In the previous exercises, we looked at distplots and briefly discussed kde plots as a building block for the more robust distplot(). In a similar manner, the lower level regplot() and higher level lmplot() are related. They are called the same way and produce similar output. However, the lmplot() is much more powerful. In this example, we can look at the relationship between alcohol content and quality using both of these plot types. The output looks similar except for the aspect ratio. In the next slide, I will show how the lmplot() is much more flexible.

The use of hue and columns is a powerful concept that is present throughout many of Seaborn's functions. The use of plotting multiple graphs while changing a single variable is often called faceting. In this case, faceting can be accomplished by using the lmplot() function. The base function is very similar to regplot() but it provides much more power by allowing you to add additional information using columns, colors, or rows. There are an entire class of functions in Seaborn that support this type of faceting and we will continue to explore them throughout the course.

It is time to put these concepts into practice. In the following exercises, we will go through some more examples of using the regplot() and lmplot() functions to analyze a dataset. By the end of the exercises, you should have a good understanding of how Seaborn works and be prepared for learning about additional plot types supported by Seaborn.

#PythonTutorial #DataCamp #Data #Visualization #Seaborn #python #distribution #plot #Regression
Рекомендации по теме
Комментарии
Автор

Good Day! How can I plot logistic regression model?

sageguru