1 00:00:00,000 --> 00:00:01,166 2 00:00:01,166 --> 00:00:06,966 Hello, and welcome to a video on correlation matrices in Python. Let's use the ADD data again. 3 00:00:06,966 --> 00:00:07,499 4 00:00:07,500 --> 00:00:13,566 So, as usual, we're going to be importing pandas as PD, and from Google Colab we'll import drive, so that 5 00:00:13,566 --> 00:00:17,732 we can mount our drive, set our file path, and read in our data through that file path. 6 00:00:17,733 --> 00:00:20,599 7 00:00:20,600 --> 00:00:26,866 Okay, so you can see, for the ADD data set, we have some new variables 8 00:00:26,866 --> 00:00:33,399 that we get to work with. We have GPA, social probability, dropout rates, IQ, 9 00:00:33,400 --> 00:00:33,433 10 00:00:33,433 --> 00:00:39,633 ADDSC, which is some score related to psychology, but I wouldn't 11 00:00:39,633 --> 00:00:45,899 know off the top of my head what it is. Let's say we'd like to know the correlations 12 00:00:45,900 --> 00:00:45,933 13 00:00:45,933 --> 00:00:52,033 between ADDSC, GPA, and IQ. The code to do this is fairly straightforward. So first, let's 14 00:00:52,033 --> 00:00:57,933 subset our data. We'll create a subset data frame, equal to DF, 15 00:00:57,933 --> 00:00:58,233 16 00:00:58,233 --> 00:01:04,399 and it's important to have these two braces here when you're subsetting. This lets Python know we would 17 00:01:04,400 --> 00:01:04,700 18 00:01:04,700 --> 00:01:11,100 like just these variables from this data set. We want ADDSC, GPA, 19 00:01:11,100 --> 00:01:11,133 20 00:01:11,133 --> 00:01:17,133 and IQ. Next, we'll make our correlation matrix. So, I've made a variable called 21 00:01:17,133 --> 00:01:22,366 correlation matrix. That is equal to subset, DF, dot, core. 22 00:01:22,366 --> 00:01:23,566 23 00:01:23,566 --> 00:01:29,699 This is something that's available through regular Python. So, we don't have to import any special libraries to do it. Next, we'll 24 00:01:29,700 --> 00:01:35,800 print our correlation matrix. And that's it. We can see we have a positive 25 00:01:35,800 --> 00:01:35,833 26 00:01:35,833 --> 00:01:41,333 correlation between GPA and IQ and negative correlations between all the the rest of them. 27 00:01:41,333 --> 00:01:43,233 28 00:01:43,233 --> 00:01:47,933 All right, that's all we have to say about correlation matrices. Happy coding!