1 00:00:00,594 --> 00:00:04,097 What is the distribution of Attack for each type? 2 00:00:04,097 --> 00:00:08,481 The catplot function has another subfamily of plots that will help us 3 00:00:08,481 --> 00:00:12,723 visualize the distribution of data with a categorical variable. 4 00:00:12,723 --> 00:00:16,013 We'll make some box plots to look at that. 5 00:00:16,013 --> 00:00:19,557 sns.catplot, and 6 00:00:19,557 --> 00:00:25,811 this time we'll call the kind box, 7 00:00:25,811 --> 00:00:31,648 data=pokemon, x='Type', 8 00:00:31,648 --> 00:00:35,406 and y='Attack'. 9 00:00:35,406 --> 00:00:39,309 And again, let's fix the aspect so 10 00:00:39,309 --> 00:00:44,904 that the x-axis labels are better spaced apart for 11 00:00:44,904 --> 00:00:48,430 ease of reading, aspect=2. 12 00:00:48,430 --> 00:00:53,506 Recall that a box plot gives us a summary of the spread of data. 13 00:00:53,506 --> 00:00:58,359 By using the catplot function, we are able to get the spread of data for 14 00:00:58,359 --> 00:01:00,921 each type of Pokemon all on one plot. 15 00:01:00,921 --> 00:01:04,749 Notice that the diamond markers represent outliers. 16 00:01:04,749 --> 00:01:08,032 And where there's a line, instead of a box plot, 17 00:01:08,032 --> 00:01:12,816 that means that there's only one observation for that type of Pokemon. 18 00:01:12,816 --> 00:01:17,414 For each of these box and whisker plots, we have a five-number summary. 19 00:01:17,414 --> 00:01:21,680 The line in the middle of the box represents the median value, or 20 00:01:21,680 --> 00:01:24,531 their central tendency of Attack points. 21 00:01:24,531 --> 00:01:28,751 Then we have the first and third quartiles, and 22 00:01:28,751 --> 00:01:34,566 then the whiskers, which represent the max and minimum values. 23 00:01:34,566 --> 00:01:39,680 Another way of visualizing the distribution is by using the violin plot. 24 00:01:39,680 --> 00:01:44,563 The violin plot is like a mix of a box and whisker plot and a KDE. 25 00:01:44,563 --> 00:01:49,585 Violin plots are analogous to box plots, but recall that the KDE 26 00:01:49,585 --> 00:01:54,991 lets us make inferences about the data based on a probability curve. 27 00:01:54,991 --> 00:01:59,993 We can easily make a violin plot by copying cell 20, 28 00:01:59,993 --> 00:02:04,893 and changing the time parameter from box to violin. 29 00:02:09,666 --> 00:02:14,366 Notice that the violin plot includes part of the box and whiskers that 30 00:02:14,366 --> 00:02:19,322 are found in the box plot, the median and the first and third quartiles. 31 00:02:19,322 --> 00:02:23,137 So it provides a similar summary of the spread of data. 32 00:02:23,137 --> 00:02:25,504 That's one of the joys of using Seaborn. 33 00:02:25,504 --> 00:02:29,693 There are different plot types that can give us similar findings for our data. 34 00:02:29,693 --> 00:02:32,356 Let's take a look at our question again. 35 00:02:32,356 --> 00:02:36,754 What is the distribution of Attack for each type of Pokemon? 36 00:02:36,754 --> 00:02:41,656 For this example, I'll answer it for the Normal Type of Pokemon. 37 00:02:41,656 --> 00:02:45,940 According to our box and whiskers plot, 38 00:02:45,940 --> 00:02:51,484 the minimum Attack points lies between 0 and 10, 39 00:02:51,484 --> 00:02:58,165 let's say 5, while the maximum goes all the way up to 110. 40 00:02:58,165 --> 00:03:04,712 The median Attack points for Normal Type Pokemon looks to be about 75. 41 00:03:04,712 --> 00:03:09,108 And the first and third quartiles 42 00:03:09,108 --> 00:03:13,665 look to be around 55 and 105. 43 00:03:13,665 --> 00:03:16,959 Now let's record our observations in a new markdown cell. 44 00:03:25,043 --> 00:03:33,343 For the Normal Type Pokemon, 45 00:03:33,343 --> 00:03:40,647 the minimum Attack is 5, 46 00:03:40,647 --> 00:03:47,287 the maximum is 110, 47 00:03:47,287 --> 00:03:51,939 median is 75. 48 00:03:51,939 --> 00:03:54,792 The first and 49 00:03:54,792 --> 00:03:59,720 third quartiles are, 50 00:03:59,720 --> 00:04:04,905 say, 55 and 105, 51 00:04:04,905 --> 00:04:08,546 respectively. 52 00:04:14,743 --> 00:04:19,440 Awesome, now try practicing using the Defense stats of the Pokemon.