[00:00.000 --> 00:04.660] Okay, looks like everybody's got a seat at this point pretty much. [00:04.820 --> 00:11.440] And I wanted to let you guys know that I will be putting the code on GitHub that goes along with [00:11.440 --> 00:18.360] the presentation that I'm giving. So if any of you are new to data analysis and want some code [00:18.360 --> 00:30.570] to get started with, that will be available on GitHub. And my talk will be a combination of [00:30.570 --> 00:48.400] different ways to explore... Oh, sorry about that. Okay. Oh, okay. Okay. So my talk is going [00:48.400 --> 00:55.160] to be a combination of why you should do exploratory analysis and how to do exploratory [00:55.160 --> 01:02.980] analysis. I'm not going to cover everything because that could take weeks, but just a couple [01:02.980 --> 01:09.560] of graphs to get everyone started and thinking about why we do exploratory analysis, why it's [01:09.560 --> 01:19.800] important, and what happens if you don't do it. So the biggest problem that I have seen with [01:19.800 --> 01:26.200] machine learning is not that we don't have enough algorithms to use or that we don't have [01:26.200 --> 01:32.440] enough techniques. It's that people don't want to start with the basics. They want to jump right to [01:32.440 --> 01:39.720] the exciting stuff. Oh, let's throw a neural net at it. Oh, that'll fix it. Rather than just [01:39.720 --> 01:46.360] looking at the basics of the problem. Kind of like eating your vegetables. People aren't super [01:46.360 --> 01:52.900] excited about vegetables generally, but they help make you stronger and healthy. And exploratory [01:52.900 --> 02:05.460] analysis can also help you make your data healthier. So some examples of why you want to do [02:05.460 --> 02:11.200] exploratory analysis or even just sort of think about what you're doing with your data. [02:11.720 --> 02:24.340] Because this article as an example, they were trying to identify criminals based on facial [02:24.340 --> 02:30.280] recognition. Not a specific criminal, just criminals in general. That doesn't really [02:30.280 --> 02:36.840] sound like a great idea if you think about it. Especially when you realize that, oh, hey, [02:36.840 --> 02:45.220] they weren't even comparing pictures from the same source. They were comparing mug shots to [02:45.880 --> 02:50.000] photos that they found on the internet of smiling people. [02:52.700 --> 02:58.980] So, yeah, I think most of you are probably familiar enough with data science to realize [02:58.980 --> 03:06.880] why that's a problem. But it's easy to just get so involved in what you're doing that you don't [03:06.880 --> 03:18.780] stop and think about, is this actually a good idea, what I'm about to do? And another example [03:21.900 --> 03:27.320] is this one I'm not as sure about. I think it's an interesting example [03:29.060 --> 03:34.880] because there are some diseases that have hyphens in the name. And it turns out having a bunch of [03:34.880 --> 03:42.460] hyphens in the title of your article has a negative correlation with how many citations your paper has. [03:43.700 --> 03:52.200] Well, this could be a thing. Or it could just be that longer titles generally have more hyphens [03:52.200 --> 04:01.280] and also are a more specialized article. So then it's going to be cited less because you're talking [04:01.280 --> 04:10.500] about a niche within medical research. So maybe, maybe not. A lot of interesting correlations out [04:10.500 --> 04:19.900] there. Something that I think needs to be looked into more. But just an example of why we need [04:19.900 --> 04:28.980] exploratory analysis. We need to figure out what's actually there, what might not be important. [04:35.210 --> 04:39.630] And the good news is that there's all sorts of Python packages out there to help you with your [04:39.630 --> 04:48.770] data. And I'm going to go through a couple of my favorites and show you guys some examples of what [04:48.770 --> 04:59.300] you can do with them. So I'm not going to cover a lot about feature extraction just because it's [04:59.300 --> 05:08.750] very specific to the kind of data you have. For my dissertation research, I used inertial sensors. [05:09.480 --> 05:15.790] So I dealt a lot with time series data. That is completely different from language processing. [05:16.490 --> 05:24.070] So how you extract features from your data. Look within whatever area of research you're doing, [05:24.070 --> 05:32.510] but also other areas that might have similar data. When I did my research, I used a lot of papers [05:32.510 --> 05:39.770] that were from the aviation industry. Because it turns out it's a lot more important to keep a [05:39.770 --> 05:45.310] plane upright while it's flying through the air than it is to make sure that you know the exact [05:45.310 --> 05:51.010] position of grandma's ankle when she's walking around the house. So there's been a lot more [05:51.010 --> 05:56.770] research for aviation applications. So had I just looked in medical journals, I would have missed [05:57.330 --> 06:02.790] a lot of valuable information about how to deal with the data from these sensors. [06:03.610 --> 06:08.810] So just something to keep in mind that you don't have to stick to exactly the application that [06:08.810 --> 06:21.370] you're using something for. And another thing to keep in mind with feature extraction. [06:23.120 --> 06:31.100] So for categorical data, there's really two different kinds of categorical data. [06:31.100 --> 06:40.420] Some of it is in order, some of it not really so much. And I've seen these mixed up and [06:41.040 --> 06:50.320] people will try and turn nominal data into numerical data. [06:51.360 --> 06:58.760] It can work if you look at it and you see if there's some sort of correlation, put it in a [06:58.760 --> 07:05.980] specific order. I mean there's always exceptions. It is specific to the data you use, but in general [07:05.980 --> 07:12.500] if you haven't explored your data, you probably don't want to take something like colors, like [07:12.500 --> 07:19.520] what's someone's favorite color, and just randomly say, oh zero is going to be blue and one is going [07:19.520 --> 07:33.990] to be red, without looking at your data first. And another thing that I just wanted to mention [07:33.990 --> 07:42.050] was binning, because I've seen that done a variety of different ways. [07:42.410 --> 07:46.390] When something is not continuously distributed, [07:46.390 --> 07:50.810] it's probably worth looking at your data before you make your bins. [07:52.970 --> 08:01.010] I'm going to use an example of the Titanic data set from Kaggle, just because there's so many [08:01.010 --> 08:08.970] different options out there for code to analyze it already. Once you get familiar with that [08:08.970 --> 08:15.590] particular data set, then looking at the different ways it's been reanalyzed is a good way to get [08:15.590 --> 08:22.670] started with visualization. I think that's how I decided to get started looking into different [08:22.670 --> 08:31.990] kinds of visualization, so I'm going to use the same example here, except for a couple of [08:31.990 --> 08:38.690] different graphs that don't really lend themselves well to the data from the Titanic data set. [08:44.980 --> 08:49.100] So the first thing that I usually do is just use describe, [08:51.950 --> 08:56.470] and that will work on your numerical data sets. [08:56.470 --> 09:02.890] A good way to get started, find out how many things there are, [09:02.890 --> 09:12.030] some standard information, very easy to do, worthwhile information. [09:16.720 --> 09:27.900] The next thing is pandas profiling. If you haven't heard of pandas profiling, it's really great. [09:30.240 --> 09:36.920] Please use it. It gives you so much information. It can be overwhelming if you're not used to doing [09:36.920 --> 09:41.980] data analysis, but it's a great place to get started. You get a bunch of different graphs [09:41.980 --> 09:49.380] with distributions of the different features that you have. It will give you warnings. I've put an [09:49.380 --> 09:56.720] example up on the screen of what happens when you run pandas profiling on the Titanic data set. [09:59.970 --> 10:07.470] So definitely pandas profiling, great way to get started. It won't necessarily tell you everything [10:07.470 --> 10:12.950] you need to know about your data though, so that shouldn't be the only thing you do. It just sort [10:12.950 --> 10:25.230] of gives you a direction to figure out what you might want to explore further. So the cons of [10:25.230 --> 10:37.110] profiling, the output is HTML. I normally use spider. Spider is not super happy about HTML [10:37.110 --> 10:44.270] files. You can save it to a file. That's pretty much your only option with spider. [10:44.430 --> 10:50.530] If you use it with Jupyter notebooks, then it's going to be a lot easier. [10:56.330 --> 11:03.070] But definitely worth using. I'll even open up Jupyter notebooks, even though it's not what I [11:03.070 --> 11:10.390] usually use, just to look at something in pandas profiling real quick before I get started. [11:14.950 --> 11:21.870] So once you use pandas profiling, get an idea of what might be interesting. [11:22.430 --> 11:29.030] Then, if you have time series data, it's good to start with just a simple graph. [11:30.190 --> 11:38.230] This graph is from the data analysis that I did as part of the data science boot camp that I went [11:38.230 --> 11:46.910] to. And I realized partway through my project at the data science boot camp that, oh, hey, [11:47.520 --> 11:55.240] I was classifying data that had come from two different wards of a hospital. [11:55.590 --> 12:04.770] And I realized, oop, I'm pretty sure that they had two different kinds of sensors on the patients [12:04.770 --> 12:13.330] in the two different wards. And that was kind of a problem, because I was classifying based on [12:13.330 --> 12:20.210] what sensor they were using instead of if the patient was actually in the cardiac ward of the [12:20.210 --> 12:28.270] hospital or not. So that was unfortunate for my project, but at least I didn't think that I [12:28.270 --> 12:35.050] actually had something that was super exciting and useful. And then it turns out, oh, hey, [12:35.050 --> 12:39.830] I was just classifying an artifact of the different machines that were used to collect the data. [12:41.330 --> 12:47.110] So, yeah, I'm telling all of you guys about my very embarrassing story, just so that you know [12:47.110 --> 12:57.930] that everyone has these stories. If they say they don't, they're lying. So, yeah, if I had started [12:57.930 --> 13:03.950] with doing some of these graphs, just a simple graph of the data from the two different groups [13:03.950 --> 13:09.750] that I was trying to classify, I could have saved myself a lot of time, and then it would have been [13:09.750 --> 13:16.530] early enough into the boot camp that I could have picked a different project and not had to tell [13:16.530 --> 13:21.970] potential employers that, oh, hey, here's this analysis I did. I think it might actually just [13:21.970 --> 13:28.430] be a giant steaming pile, but it's what I did, because I figured it out too late to start a new [13:28.430 --> 13:50.220] project. So, heat maps. Everyone loves heat maps. I like using them to help show data to people [13:50.220 --> 13:57.960] that are not necessarily data scientists. It can be a good way to see what might be interesting [13:57.960 --> 14:05.440] and correlated, but also it's easy for someone that's not super technical to understand. So, [14:05.440 --> 14:10.480] I am a fan of heat maps. I realize that not everyone might be, [14:11.840 --> 14:18.100] but I do find value in them. And it's also part of Panda's profiling, so [14:18.100 --> 14:24.680] you get one of those without having to really do any extra analysis. [14:25.680 --> 14:34.820] Oh, well, that's not great. Okay. But another thing that I like is violin plots, especially [14:34.820 --> 14:40.300] if you have a binary classification, because then you can put your two classes on either side [14:40.300 --> 14:48.560] and see if they are similarly distributed. So, this example is from the Titanic data set, [14:48.560 --> 14:58.440] and you can see that, okay, this data is definitely dependent upon age, [14:59.180 --> 15:05.440] which makes sense. They put all the children on the lifeboats first. Well, [15:05.440 --> 15:14.480] especially the male children, it looks like. But, yeah, if you look back at the heat map [15:14.480 --> 15:21.720] between survival and age, there's not really much of a correlation. But then if you start [15:21.720 --> 15:32.240] breaking it out into different ages versus just age, then you can see, oh, hey, I might should [15:32.240 --> 15:39.740] make my bins according to where these probabilities are. So, that's what I was talking about with [15:39.740 --> 15:45.680] looking at your data first before you decide to bin it. Because this one, if you had just taken [15:45.680 --> 15:50.900] the youngest and the oldest and divided it into a certain number of groups, you might have not [15:51.720 --> 15:57.800] had the best classification based on the probabilities that are in there. [16:01.340 --> 16:07.480] So, I prefer to look at data before just randomly assigning it to bins. [16:11.890 --> 16:21.070] And another thing that I like, pair plots. And pair plots are great because you can see [16:21.070 --> 16:27.110] how two variables are related. This is not the best example of a pair plot, [16:29.610 --> 16:37.590] but you can sometimes see just, okay, all it really takes is those two variables to [16:37.590 --> 16:43.130] separate out your classes, if you're lucky. That happened with the pair plot for my [16:43.130 --> 16:50.930] dissertation research, but unfortunately that one was really large and I wanted to [16:50.930 --> 16:59.690] keep this consistent with showing you guys the same data. But it's not necessarily that [17:00.310 --> 17:05.270] if you don't see a separation on a pair plot, you won't be able to classify your data. [17:05.270 --> 17:11.850] It's just, if you see it, that's good news for you. Your life just got easier because you know [17:11.850 --> 17:25.470] that, oh, hey, these two variables definitely can show you something. Okay. And here is a little [17:25.470 --> 17:33.530] more of me showing you guys just how terrible my idea at the data science boot camp was. [17:33.530 --> 17:41.030] Okay. Because if I can't be an example, at least I can be a terrible warning for all of you. [17:41.590 --> 17:49.090] So this drift feature that was the most important when I used a tree-based classifier, [17:49.610 --> 17:59.650] that was when I did that midline. So back, oh, I should have put these two slides next to each [17:59.650 --> 18:12.530] other. Okay. So here when I did that midline correction, so that orange line, I took that [18:12.530 --> 18:19.670] out and then you get the green one. So that orange line, the standard deviation of that line [18:21.190 --> 18:28.750] was the most important feature that I found for my project. The thing that I took out to [18:28.750 --> 18:38.150] try and make the two different datasets the same, yeah, that was my most important feature. [18:38.150 --> 18:47.590] Because one of the datasets had already been normalized and had that midline correction [18:47.590 --> 18:57.330] and the other did not. So, yeah, that was a frustrating experience for me. [18:57.330 --> 19:05.450] But at least I found it out before I went any further with it. So I can't really complain. [19:05.710 --> 19:10.030] And, I mean, I did learn something from going to the data science boot camp because [19:11.110 --> 19:19.910] now I know the importance of doing much more EDA much earlier before I have to commit to an idea. [19:24.750 --> 19:33.770] So, yeah, that was my boot camp experience. I would say if you are thinking about going to [19:33.950 --> 19:40.950] a data science boot camp, they might tell you not to pick a project before you go there. [19:41.210 --> 19:45.950] Definitely find some data you're interested in and look into it a little bit first. [19:45.950 --> 19:51.990] Try to avoid doing what I did and realizing your project is a steaming pile [19:52.490 --> 20:08.170] when it's too far in to switch. So, yeah, that just my rant on data science boot camps, but... [20:08.750 --> 20:16.950] Okay. So, this was another thing that I did while I was at the data science boot camp because [20:17.950 --> 20:26.630] I needed to get results that didn't look too terrible. So I just threw a bunch of classifiers [20:26.630 --> 20:32.850] at my data because I was running out of ideas. I'm not saying that it's a bad idea to try a [20:32.850 --> 20:40.890] bunch of different classifiers, but at least look at your data first so you don't end up [20:40.890 --> 20:49.800] in the same situation that I was in. And in this case, yeah, there were a bunch of ones [20:49.800 --> 21:01.060] that were overfitting. I should have also used more data. But it was a learning experience. [21:08.480 --> 21:19.520] And here's another graph with me just telling you guys how terrible my idea was. So, yeah, [21:19.520 --> 21:27.300] really high training accuracy, really low test accuracy. I was overfitting and it was so bad. [21:29.740 --> 21:39.660] But... I at least was able to look at false positives versus false negatives. Since this [21:39.660 --> 21:46.660] was a medical application, it's a little bit different than security. For medicine, we really, [21:46.660 --> 21:53.200] to miss anything, like saying that, oh, hey, someone that's having a cardiac event is fine [21:53.200 --> 22:00.100] is real bad. Better to accidentally say, oh, hey, someone might be having a cardiac event when they [22:00.100 --> 22:14.580] aren't. So this is a little bit different than security. But... yeah. So... [22:17.700 --> 22:23.440] Does anyone have any questions? Because... [22:25.180 --> 22:30.700] I could just keep on going. But... okay. I guess... [22:58.850 --> 23:08.570] So for that, there's a bunch of different techniques you can use. You could do... [23:11.410 --> 23:17.910] dimensional reduction, so combining those features, seeing what features end up being combined. [23:18.930 --> 23:22.270] But... yeah. I was just showing some ways to get started. [23:22.390 --> 23:27.670] Definitely just looking at two variables together is not the only thing you want to do. [23:27.670 --> 23:31.730] If two variables is all you need to start getting it separated, then [23:32.330 --> 23:38.110] that's really good. But that's not how it usually works. [23:40.350 --> 24:02.690] Sorry. Did I answer your question? There are a bunch of different techniques for that. [24:03.410 --> 24:12.090] Principal component analysis, lasso, sorry, I'm drawing a blank on all of them. But yes, [24:12.090 --> 24:20.170] there are definitely ways to do that. And then, again, one option you can use is [24:21.170 --> 24:25.470] running it through a tree-based classifier. That might not be what you end up using in the end, [24:25.470 --> 24:31.950] but it can show you if there are multiple variables that are important. So for this one, [24:31.950 --> 24:36.730] it showed there wasn't just one or two standout variables that, okay, [24:36.730 --> 24:41.310] that's the one that was really predicting what was going on. [24:43.630 --> 24:48.850] So as far as if you want to visualize it, that could be an option, looking at that feature [24:48.850 --> 25:02.790] importance. Oh, he was asking about when there would be more than two features that would be [25:02.790 --> 25:13.270] important. So I was just, because I'd shown the pair plot, which only shows two features [25:13.270 --> 25:19.270] combined with each other, but a lot of the time you're going to have a combination of [25:19.270 --> 25:29.230] more than two features that will end up being what you use to predict whatever it is that [25:29.230 --> 25:34.890] you're classifying. So yeah, there are other techniques beyond what I showed. This was just [25:34.890 --> 25:41.610] more of a starting to think about your data and please, please think about what you're doing. [25:41.610 --> 25:45.350] And if there's bias in your data before it was even collected, [25:47.990 --> 25:56.370] like the example that I gave of my data science bootcamp project, where it turns out I was just [25:56.370 --> 26:03.150] checking to see which kind of sensor had been used to collect the data versus what I was trying to [26:03.150 --> 26:12.010] do. There's so much bias data out there and it's easy to not really think about where the data [26:12.010 --> 26:26.050] came from. Is this a good idea? And that sort of thing. Like the, sorry, I keep on coming back to [26:26.050 --> 26:37.250] this, but it's just, it's so bad. Like this, like if they would have just thought about, oh hey, [26:37.250 --> 26:45.290] why am I trying to separate criminals from non-criminals? I feel like if they just spent [26:45.410 --> 26:50.170] a little more time thinking about that, maybe they wouldn't have put that out there and [26:51.390 --> 26:54.550] now everyone's seen it and sort of makes fun of it. [27:01.950 --> 27:23.890] Okay. Oh yes. There are a lot of people I've seen that skip EDA because they either don't know how [27:23.890 --> 27:29.010] to do it or they just get really excited about their project and want to just go straight to [27:29.010 --> 27:49.630] classification. So I think EDA is so easy that there's not really any excuse to skip it. Like [27:50.330 --> 27:56.410] you're never going to look back at a project and say, I really wish I hadn't spent that hour or [27:56.410 --> 28:04.330] two looking into my data to make sure that it's what I think it is. But there are plenty of times [28:04.330 --> 28:11.010] like my bootcamp project where I looked back and thought, I really wish I had spent more time [28:11.010 --> 28:19.310] looking into that project before I committed to it. Yeah. So that's sort of why I am now [28:20.670 --> 28:26.650] very passionate about EDA because I don't want to have any more of those experiences [28:27.210 --> 28:34.130] and I want to help prevent others from having that experience because it was fairly unpleasant for me. [28:34.790 --> 28:41.510] I mean, also I'm happy that I did discover it during the bootcamp and not try and submit it [28:41.510 --> 28:47.150] and get a grant and then realize after I told even more people about it. So [28:51.490 --> 28:55.050] but yeah, it would have been better if I'd found that earlier for sure. [28:57.430 --> 29:15.600] Okay. Oh, and your question? So to be honest, most of my experiences with medical data [29:16.200 --> 29:19.840] where there's not really an issue of ever having too much data [29:21.440 --> 29:28.200] because there's so much regulation around medical data and rightly so, we don't want [29:28.200 --> 29:32.160] medical records just being available freely on the internet. [29:34.180 --> 29:39.480] So in medical research, it's more a problem of needing to get more data. [29:40.260 --> 29:48.720] If you have tons and tons of data, then okay, number one, I'm jealous. I want your data. [29:49.530 --> 29:56.400] I want that problem. But also, you can always take a subset of your data to [29:57.040 --> 30:04.680] do some exploratory analysis with and then maybe do a couple of different comparisons [30:04.680 --> 30:10.320] to make sure that that subset you took is representative of the entire data set. [30:10.620 --> 30:15.220] If you want to do something like pandas profiling, running that on a very large [30:15.220 --> 30:21.040] data set is going to take quite a while. So you could take a subset, do a couple of basic [30:21.040 --> 30:27.880] comparisons to make sure that they are similar and then run that subset through your EDA [30:31.290 --> 30:35.710] to do more extensive analysis. Some of the things like the correlation [30:36.810 --> 30:42.270] coefficients can take a while if you've got a very large data set. [30:44.790 --> 30:49.670] But definitely taking that step to do that comparison of, oh, hey, is this subset [30:50.510 --> 31:07.680] comparative to the whole of the data set? That's valuable. Okay. Any other questions? [31:10.120 --> 31:11.640] Okay. [31:11.860 --> 31:18.970] How would you handle data that has sparsely populated features? [31:18.970 --> 31:31.230] Sparsely populated features. So for that, probably the best way to deal with sparsely [31:31.230 --> 31:40.910] populated features is to look into how language processing is done, because that is a common [31:40.910 --> 31:49.950] problem in language processing, because they will vectorize word strings, or strings, [31:49.950 --> 31:55.410] and then vectorize it. So one hot encoding of each word that is in a sentence, for example. [31:55.410 --> 32:02.770] So there is a lot of very sparse data in NLP. So I'm not super familiar with NLP. I don't want to [32:02.770 --> 32:08.690] tell you for sure. I do this and that. But even if you're not dealing with language data, I would [32:08.690 --> 32:20.130] say look at some of the different processes that are used for NLP. And, yeah, one of the things [32:20.130 --> 32:28.850] that is used for NLP is combining some of the fields so that then you don't have as many [32:28.850 --> 32:37.870] different dimensions that are sparsely populated. And there's a bunch of different ways to do that. [32:37.870 --> 32:57.340] It's going to be specific to your data. So, okay. Well, I guess that's all the questions. [32:57.960 --> 33:05.760] Thank you for coming to my talk. And hopefully, if I have even prevented one person from making [33:05.760 --> 33:14.760] the same mistake that I did, then I am very happy. Because it's really frustrating to get far into a [33:14.760 --> 33:23.600] project and then realize, oh, hey, I missed a fundamental flaw in my data. Okay. [33:23.640 --> 33:24.000] Thank you.