R vs Python ANOVA Interaction Plot

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

^Downloadable code & more! ANOVA Interaction plots

In python we will read it in using pandas dot read_csv we will use a regular expression to operate by space so slash s plus.

And here is what the data looks like in python. Let me go back over here to R to show you what the data looks like in R as well. And lets delete those now that we have seen that it read the data in correctly for both languages.

Now before we continue by making sure the gender is a factor. In R we will just resign the column using the factor function.

In Python we will use the dot as type string to make sure it uses the values in gender as a category and not a numerical value.

Now we are read for the interaction plots. In R we do interaction dot plot In this example we will do type first, then second comes the numerical score value, in this case days, and last is our other categorial variable, so gender.

And there is the plot in R. It defaults to this black and white, with a legend.

In Python we do interaction underscore plot. The order in python is a bit different than R. We will put our categories both first and then the numerical days at the end. So type, gender, and lastly days.

And there is the interaction plot between Type and gender in python. This defaults to red and blue with a legend as well.

In python there are a lot of customizations you can do to this plot. Let’s take a look at those by bringing up the documentation. So interaction_plot ? . You can change line style and colors. If you want… and I may or my not have done this for fun before, you can make it look exactly like R’s default interaction plot output.

So there you have it that is how you can create Analysis of Variance Interaction plots in both Python and R. Explosion at beginning is from the Mask of Zorro.

Be sure to watch some of my other python videos, and don’t forget to hit subscribe. :D

This is a Python anaconda tutorial for help with coding, programming, or computer science. These are short python videos dedicated to troubleshooting python problems and learning Python syntax. For more videos see Python Help playlist by Rylan Fowers.





#PythonMarathon #LearnPython #PythonTutorial
Рекомендации по теме
Комментарии
Автор

How would you test if the interaction is significant though?

Sam-tgii
Автор

Thank you so much for the wonderful video! How would you do this if the interaction is between two continuous variables? One was I found was to do a median split and make them categorical. But is there another way? Like making the third variable into low, average and high (as in a moderation analysis plot). Can that be done in Python?

nithinth
Автор

Is there a way to plot the adjusted confidence intervals for the scores in either language?

sabioo
Автор

In Python, is there a way to get at this data rather than a plot? I've got several hundred features and I'd like to programatically call out the ones that need a plot.

GamingTeaParty