1 00:00:00,510 --> 00:00:01,620 Welcome back. 2 00:00:02,310 --> 00:00:04,290 Now I've got a Jupiter notebook running. 3 00:00:04,440 --> 00:00:08,260 It's time to see what we can actually do in this notebook. 4 00:00:08,490 --> 00:00:12,530 Remember in the last lesson we went through this this is like your standard menu bar. 5 00:00:12,540 --> 00:00:13,600 This is a tool bar. 6 00:00:13,620 --> 00:00:20,020 But we're going to avoid using the tool bar because we want to become experts at using our keyboard. 7 00:00:20,020 --> 00:00:27,760 All of the things here that you can do like saving adding cutting copying pasting etc. You can do with 8 00:00:27,760 --> 00:00:28,440 the keyboard. 9 00:00:28,440 --> 00:00:35,910 So what will this save you while instead of clicking run on a cell so run is how you run some codes. 10 00:00:35,910 --> 00:00:37,120 If you go here. 11 00:00:37,130 --> 00:00:46,540 Now you want to print a nice message Hello world I'm learning about Jupiter. 12 00:00:46,570 --> 00:00:48,550 No books. 13 00:00:48,770 --> 00:00:52,150 We hit shift and enter we could have done that. 14 00:00:52,150 --> 00:00:52,570 I'll see. 15 00:00:52,570 --> 00:00:53,800 I've done that out of habit. 16 00:00:53,830 --> 00:00:54,190 Right. 17 00:00:54,220 --> 00:00:54,920 That's what we're going to. 18 00:00:54,970 --> 00:00:59,990 We're going to be focused on is it rather than just learning how to use this toolbar to begin with. 19 00:01:00,100 --> 00:01:06,610 We're going to be focused from a start on using the keyboard so I can keep pressing run here or I could 20 00:01:06,610 --> 00:01:08,350 keep pressing shift enter. 21 00:01:08,440 --> 00:01:14,560 And now what you might be noticing is that the number on the left is going up every time I hit shift 22 00:01:14,620 --> 00:01:15,600 and enter. 23 00:01:15,850 --> 00:01:20,380 Remember I'm just got this cell highlighted pressing shift enter. 24 00:01:20,560 --> 00:01:23,260 That's how you run a piece of code energy but a notebook. 25 00:01:23,260 --> 00:01:24,910 Beautiful isn't it. 26 00:01:24,950 --> 00:01:30,360 This this cell phone numbers going up all that's saying is that this is a 13th cell. 27 00:01:30,370 --> 00:01:31,810 Remember this is a cell. 28 00:01:31,810 --> 00:01:33,870 Could be code or markdown. 29 00:01:33,880 --> 00:01:35,610 We'll see that in a second. 30 00:01:35,710 --> 00:01:43,360 This cell or there have been 13 cells run in total and Jupiter where this is helpful is if you had something 31 00:01:43,360 --> 00:01:51,500 like a equals five 14 and then you go A we didn't mean that a equals six. 32 00:01:51,540 --> 00:01:52,740 So what does what do you think. 33 00:01:52,800 --> 00:02:00,490 A equals now because this is 14 and this is 16 if we hit this and hit shift into a is going to equal 34 00:02:00,490 --> 00:02:01,390 six. 35 00:02:01,410 --> 00:02:06,570 So these numbers are helpful to show us what order our notebook has been running. 36 00:02:06,570 --> 00:02:12,220 So for example if we had 100 of these different cells with different information in an ideal world a 37 00:02:12,220 --> 00:02:14,830 notebook is run from top to bottom. 38 00:02:15,060 --> 00:02:21,780 But in some cases you might be working on a project and run a cell up here and then rerun it down here 39 00:02:21,960 --> 00:02:27,460 and later on in your notebook a few hundred cells down you've got some kind of error. 40 00:02:27,600 --> 00:02:33,090 This is what you can use to figure out what order your your notebook was run in. 41 00:02:33,240 --> 00:02:39,120 Now because we've got code here we can run all of Python's functionality from right in the Jupiter notebook 42 00:02:39,150 --> 00:02:47,220 shift into one plus two you'll notice some cells have in and some cells have out now. 43 00:02:47,280 --> 00:02:54,150 If a cell has an output like some sort of code output it will usually have an outnumber the outnumber 44 00:02:54,240 --> 00:02:56,100 matches in number. 45 00:02:56,100 --> 00:03:01,610 So this is just saying hey there's some input code here and we've got some output code here. 46 00:03:01,740 --> 00:03:06,010 Now we did have a brief look at this before code and markdown. 47 00:03:06,180 --> 00:03:13,410 This is where the absolute beauty of Jupiter in April comes into play is that you can have code and 48 00:03:13,410 --> 00:03:18,840 formatted text which is what markdown is within the same notebook. 49 00:03:18,840 --> 00:03:20,540 Let me show you an example. 50 00:03:20,550 --> 00:03:27,400 So we wanted to start a project called Heart Disease project and remember Jupiter notebooks are the 51 00:03:27,390 --> 00:03:30,150 workspace of your data science projects. 52 00:03:30,240 --> 00:03:35,880 So you can run machine learning code and describe what you're doing right from the notebook. 53 00:03:35,880 --> 00:03:40,800 We're gonna see this in practice throughout but I just want to highlight what turning a cell into markdown 54 00:03:40,830 --> 00:03:41,920 does. 55 00:03:42,270 --> 00:03:47,820 So we can change that to markdown but remember where we don't want to get used to using the toolbar. 56 00:03:47,820 --> 00:03:49,440 So how do we do that. 57 00:03:49,920 --> 00:03:54,990 Well another beautiful thing about Jupiter is that the cells have two simple modes. 58 00:03:55,020 --> 00:04:01,410 One is called edit and you'll notice this little pencil up here and this green box around it. 59 00:04:01,500 --> 00:04:04,140 The other is called command mode. 60 00:04:04,140 --> 00:04:05,910 Now how do we switch between the two. 61 00:04:06,480 --> 00:04:11,910 Well as you might have guessed we can also use a keyboard because remember we're not getting used to 62 00:04:11,910 --> 00:04:13,070 using this toolbar. 63 00:04:13,180 --> 00:04:16,110 You guys all pretend it's not even there. 64 00:04:16,110 --> 00:04:20,730 So to change from edits to command mode we're going to press escape. 65 00:04:20,730 --> 00:04:21,480 Beautiful. 66 00:04:21,570 --> 00:04:28,860 Now we notice that the little green bar has changed to a blue bar and the pencil has gone away. 67 00:04:28,860 --> 00:04:34,290 Now before we run this cell how do we get back to edit mode to do that. 68 00:04:34,380 --> 00:04:35,890 Press enter. 69 00:04:35,910 --> 00:04:39,690 Now we get our green box back and the little pencil comes back. 70 00:04:40,050 --> 00:04:40,960 Excellent. 71 00:04:41,340 --> 00:04:43,010 But we actually want to be in command mode. 72 00:04:43,020 --> 00:04:44,310 So we'll go back. 73 00:04:44,310 --> 00:04:45,360 Escape. 74 00:04:45,630 --> 00:04:47,070 Blue Box is back. 75 00:04:47,070 --> 00:04:48,080 Pencil is gone. 76 00:04:48,090 --> 00:04:53,130 You'll get used to running this escape and enter after you've had some experience. 77 00:04:53,220 --> 00:04:59,070 I just know how to do these things because I've run thousands of cells and in my experience and we're 78 00:04:59,070 --> 00:05:06,770 going to press M for markdown and to think about that because to change it back to code is why. 79 00:05:06,800 --> 00:05:11,690 So watch this little box up here while we're in edit command mode. 80 00:05:11,720 --> 00:05:19,100 Sorry with the blue box we can press M for markdown or Y for code but we want markdown in this case 81 00:05:19,970 --> 00:05:24,090 m and to run this cell we're going to hit shift enter. 82 00:05:24,110 --> 00:05:30,170 Now you see this is some nicely formatted text so what you could imagine in the future is for a project 83 00:05:30,170 --> 00:05:34,730 you might start it off with a heading up here and then you might add some information below it. 84 00:05:34,730 --> 00:05:45,560 So this project is about classifying whether or not a patient has heart disease. 85 00:05:45,560 --> 00:05:51,290 So this is how you can start to communicate your work right from the right from the very beginning of 86 00:05:51,290 --> 00:05:52,480 a project. 87 00:05:52,500 --> 00:05:54,110 Now what else could you do here. 88 00:05:54,110 --> 00:05:58,160 Well let's let's see some data if we go back to our keynote. 89 00:05:58,160 --> 00:06:03,710 We want to set up this kind of setup so we want some data in our project folder and we want to run this 90 00:06:03,710 --> 00:06:08,910 data through our workspace which is a Jupiter notebook and try to use some of these tools. 91 00:06:08,970 --> 00:06:10,880 Let's get a little taste of that. 92 00:06:10,910 --> 00:06:18,350 So if we go here import pandas as PD what this is saying is this is code it's telling Python to go hey 93 00:06:18,350 --> 00:06:24,920 Python go and get pandas imported as the shortcut PD which is very common for pandas we'll see a little 94 00:06:24,920 --> 00:06:26,960 bit more of pandas in a future video. 95 00:06:27,110 --> 00:06:32,370 What I'm doing is exemplifying the different types of things you can do in a DuPont notebook. 96 00:06:32,390 --> 00:06:37,790 And please if you're following along make sure you're typing this code out by yourself. 97 00:06:37,790 --> 00:06:43,790 But if we go type this line of code and hit shift enter what that's going to do is import pandas to 98 00:06:43,790 --> 00:06:44,920 this notebook. 99 00:06:44,960 --> 00:06:51,650 So now we have access to use pandas which is one of the tools we installed in our environment within 100 00:06:51,650 --> 00:06:53,010 our workspace. 101 00:06:53,010 --> 00:07:00,340 The Jupiter notebook so do you remember in the last lesson how we uploaded some files here. 102 00:07:00,340 --> 00:07:02,170 How would we get these files. 103 00:07:02,170 --> 00:07:03,380 So this is a heart disease. 104 00:07:03,380 --> 00:07:04,260 Don't CSB. 105 00:07:04,270 --> 00:07:06,070 How would we get that. 106 00:07:06,070 --> 00:07:07,420 Now if you've never heard of V. 107 00:07:07,450 --> 00:07:10,330 It's a format called comma separated values. 108 00:07:10,330 --> 00:07:12,690 It's very common way to store data. 109 00:07:12,910 --> 00:07:16,350 But how do you think we'd get that into here. 110 00:07:16,350 --> 00:07:16,820 That's right. 111 00:07:16,820 --> 00:07:20,620 If you don't know because you might not have ever gone through this before. 112 00:07:20,760 --> 00:07:28,170 But what we're going to do is use panders to create a data frame D F stands for data frame rate CSP 113 00:07:29,030 --> 00:07:30,710 and we're going to use the file name. 114 00:07:30,720 --> 00:07:38,400 Now another beautiful thing about Jupiter notebooks is that if you have a file in here you can use tab 115 00:07:38,520 --> 00:07:39,720 for auto complete. 116 00:07:39,720 --> 00:07:45,720 So if we press tab it's going to pick up heart disease Delta CSP and we've already got the other inverted 117 00:07:45,720 --> 00:07:46,080 commas. 118 00:07:46,080 --> 00:07:49,420 So we're going to select this one. 119 00:07:49,460 --> 00:07:55,630 So what is this line of code doing well it's going data frame equals PD so panders dot read CSB. 120 00:07:55,640 --> 00:08:04,170 So this is a function and we're passing the file name heart disease dot CSP to the read CSC function. 121 00:08:04,250 --> 00:08:10,910 We'll have a complete section on pandas later on but this is just to exemplify what you can do with 122 00:08:10,910 --> 00:08:12,120 energy put a notebook. 123 00:08:12,460 --> 00:08:14,470 So we're going to hit shift enter. 124 00:08:14,580 --> 00:08:17,650 You can see that it's run because that number has gone up. 125 00:08:18,010 --> 00:08:20,550 But how would we view our data. 126 00:08:20,590 --> 00:08:25,590 So another beautiful thing about DuPont in notebooks is that you can view what you're working on straight 127 00:08:25,590 --> 00:08:26,390 away. 128 00:08:26,560 --> 00:08:31,520 So DLF dot head shows the first five rows of your data frame. 129 00:08:32,120 --> 00:08:36,030 So look here we've got different columns we've got different examples. 130 00:08:36,130 --> 00:08:40,320 Maybe we wanted to view the first 10 to get a better look. 131 00:08:40,420 --> 00:08:41,620 There we go. 132 00:08:41,620 --> 00:08:46,930 We'll have a look at this in a in a future project but this is just to show you what kind of data Jupiter 133 00:08:46,930 --> 00:08:48,520 notebooks can display. 134 00:08:48,610 --> 00:08:51,120 So we might even put a cell in here. 135 00:08:51,400 --> 00:08:54,640 So we go escape B for a new cell below. 136 00:08:54,640 --> 00:08:59,800 You can also press a for a new cell above but we're going to remove this one. 137 00:08:59,830 --> 00:09:13,010 So escape Double D for delete beautiful and go the following table shows heart disease information for 138 00:09:13,160 --> 00:09:20,720 patients escape and press M for Mark down shift enter. 139 00:09:20,940 --> 00:09:24,120 Now we've got some communication happening here. 140 00:09:24,330 --> 00:09:24,630 OK. 141 00:09:24,660 --> 00:09:26,190 Well we've seen a table. 142 00:09:26,190 --> 00:09:31,500 What if we wanted to to maybe put in a little graph or something like that and see what this information 143 00:09:31,500 --> 00:09:32,180 actually looked like. 144 00:09:32,180 --> 00:09:34,290 Because this is pretty confusing. 145 00:09:34,350 --> 00:09:36,910 We're going to target column which is full of ones and zeros. 146 00:09:36,910 --> 00:09:40,050 I only know that because I've seen this table four. 147 00:09:40,170 --> 00:09:45,360 But one means someone has heart disease and a zero you can't see any on this at the moment means someone 148 00:09:45,360 --> 00:09:46,960 doesn't have heart disease. 149 00:09:46,980 --> 00:09:52,140 So what if we wanted to graph that quickly and have a look at at how many patients have heart disease 150 00:09:52,140 --> 00:09:53,990 and how many don't. 151 00:09:54,330 --> 00:09:57,260 And each row here by the way is an individual patient. 152 00:09:57,270 --> 00:09:59,280 And so these are their parameters. 153 00:09:59,370 --> 00:10:07,440 Let's have a look and go deaf dot target which just means access the target value of DLF. 154 00:10:07,620 --> 00:10:12,630 We're going to go value counts which just means count the number of occurrences of different different 155 00:10:12,630 --> 00:10:20,000 values in this column then dot plot which means create a plot of kind. 156 00:10:20,690 --> 00:10:25,940 We got that mixed up colon bar which just means let's create a bar graph. 157 00:10:26,090 --> 00:10:28,890 See hit shift enter by the way. 158 00:10:28,950 --> 00:10:33,220 Why didn't that show up well Matt bluntly I've got access. 159 00:10:33,220 --> 00:10:33,760 Mm hmm. 160 00:10:33,790 --> 00:10:37,650 We go back to our little environments set up here. 161 00:10:37,660 --> 00:10:40,350 We've been using pandas to look at this data frame. 162 00:10:41,260 --> 00:10:44,950 But we need map plot lived to look at graphs. 163 00:10:45,010 --> 00:10:46,150 Okay. 164 00:10:46,240 --> 00:10:49,990 No reason I know that it's because I've had experience but we're gonna have a look at each of these 165 00:10:49,990 --> 00:10:50,830 tools in depth. 166 00:10:51,340 --> 00:10:52,480 So what could we do here. 167 00:10:52,480 --> 00:11:02,180 Maybe we try to go import that plot lib dot pie plot as BLT party as a shortcut from that plot lib or 168 00:11:02,350 --> 00:11:05,950 hit shift into nothing happens. 169 00:11:05,950 --> 00:11:07,750 Why is that. 170 00:11:07,750 --> 00:11:12,250 Well remember Jupiter notebooks are executed in order of operation. 171 00:11:12,250 --> 00:11:17,370 So just because we ran a cell down down here doesn't mean it's going to influence the cell up here. 172 00:11:17,380 --> 00:11:22,870 So what we'll have to do is come back up here and rerun this cell. 173 00:11:22,870 --> 00:11:23,950 There we go. 174 00:11:23,950 --> 00:11:33,580 So now if we look at the numbers in 24 in 25 out 25 you see what just happened there because we ran 175 00:11:33,580 --> 00:11:41,350 this cell before is 24 and this was 23 running this piece of code didn't effect this until we reran 176 00:11:41,350 --> 00:11:42,010 it. 177 00:11:42,040 --> 00:11:46,990 So that's a very important thing to think about with Jupiter notebooks is that they're executed in order 178 00:11:46,990 --> 00:11:48,320 of operation. 179 00:11:48,400 --> 00:11:55,450 And so the other takeaway here is that not only can we look at our data in a table format we can start 180 00:11:55,450 --> 00:12:00,060 to look at it in graph format so you might be starting to see here. 181 00:12:00,070 --> 00:12:00,740 OK. 182 00:12:00,820 --> 00:12:08,320 If I can run code cells as well as tech cells as well as image cells I could do my entire project from 183 00:12:08,320 --> 00:12:12,030 within this notebook which is exactly right. 184 00:12:12,040 --> 00:12:18,330 See one more thing and that's if we wanted to import another image so we'll change this cell to mark 185 00:12:18,330 --> 00:12:25,570 down escape and we're going to use exclamation mark if you've never written markdown code before there 186 00:12:25,570 --> 00:12:31,270 are some great guides online on how to write markdown code but essentially any kind of markdown code 187 00:12:31,270 --> 00:12:34,260 you can write you can write in a Jupiter cell. 188 00:12:34,720 --> 00:12:42,820 So we're going to we want to import the image that we uploaded earlier that page and you can do this 189 00:12:42,820 --> 00:12:44,280 with any image. 190 00:12:44,320 --> 00:12:49,690 So this is within this file folder here we're just writing it here. 191 00:12:49,690 --> 00:12:51,070 You can do this with your own image. 192 00:12:51,220 --> 00:12:55,920 Basically what this is is markdown code for saying import this image to the notebook. 193 00:12:55,920 --> 00:12:58,040 If we hit shift into. 194 00:12:58,290 --> 00:12:59,690 There we go. 195 00:12:59,700 --> 00:13:01,970 So this is our framework. 196 00:13:01,970 --> 00:13:02,530 OK. 197 00:13:02,550 --> 00:13:04,270 We've seen this before. 198 00:13:04,380 --> 00:13:12,840 Now what we might do is create a section for each of these steps so you could do mark down again escape 199 00:13:13,050 --> 00:13:22,990 M number one problem definition where we could say predict heart disease. 200 00:13:23,110 --> 00:13:28,960 I'm typing out something small here you might want to do something longer and then we could have a Skype 201 00:13:29,110 --> 00:13:38,200 BBB to create five or six cells for I can't really count two data. 202 00:13:38,340 --> 00:13:46,610 This is the data we're using we're going to hit escape M and then shift into. 203 00:13:46,620 --> 00:13:50,310 So now you can start to imagine we've got our framework. 204 00:13:50,310 --> 00:13:52,540 We could start off with a problem definition. 205 00:13:52,680 --> 00:13:59,880 We could then look at a data just like we've done here we could move this down to the data section then 206 00:13:59,880 --> 00:14:04,600 we could create an evaluation metric and we could look at the features of our data. 207 00:14:04,620 --> 00:14:11,160 We could do some modeling and then we could run experiments all of this from within a Jupiter notebook. 208 00:14:11,380 --> 00:14:15,880 Now there's one more thing before we finish up this lecture because getting a bit long that you can 209 00:14:15,880 --> 00:14:22,420 do with energy Jupiter notebook the main to take away so far is that you can run code text and images 210 00:14:22,540 --> 00:14:24,700 all within the same space. 211 00:14:24,850 --> 00:14:30,260 And the final thing is that you can also run terminal commands from within a Jupiter notebook. 212 00:14:30,670 --> 00:14:36,310 So say for example we wanted to run less just as if we are running less on the terminal. 213 00:14:36,910 --> 00:14:46,790 So if I go here and I put in a less it's going to list all of the files in my user account if we do 214 00:14:46,790 --> 00:14:53,500 the same in Jupiter notebook if we just ran less in a code cell and hit shift center. 215 00:14:53,900 --> 00:14:55,010 That's interesting. 216 00:14:55,010 --> 00:14:55,940 That might be an update. 217 00:14:55,940 --> 00:14:57,410 I haven't seen before. 218 00:14:57,470 --> 00:15:01,910 Usually you'd have to type in exclamation mark Ellis. 219 00:15:02,120 --> 00:15:02,700 Well there you go. 220 00:15:02,750 --> 00:15:04,040 You'll learn something new every day. 221 00:15:04,070 --> 00:15:10,460 Maybe you don't need the exclamation mark but generally to run a command like l s like list you would 222 00:15:10,460 --> 00:15:13,820 need the exclamation mark in front of the terminal command. 223 00:15:14,210 --> 00:15:20,810 And what this is going to do is go into Jupiter instead of executing this command like some Python code 224 00:15:21,170 --> 00:15:27,380 execute it because it's got the exclamation mark there as if I was running it on the terminal. 225 00:15:27,380 --> 00:15:34,340 Like this and so the L S command is just showing us the different files that we have here. 226 00:15:35,850 --> 00:15:36,410 All right. 227 00:15:36,550 --> 00:15:38,390 Well that's enough for this lesson. 228 00:15:38,600 --> 00:15:44,740 Remember sound like a broken record here but this is important to take away is that Jupiter notebooks 229 00:15:44,740 --> 00:15:47,840 cells are run in order of the number. 230 00:15:47,920 --> 00:15:50,740 So if we ran here a equals five. 231 00:15:51,160 --> 00:15:55,900 If we came down to this one and skip this one it's going to be a equals five. 232 00:15:55,930 --> 00:16:08,920 But then if we ran this I would equal six and you can run mark down cells code cells as well as plot 233 00:16:08,920 --> 00:16:12,620 different images all within the notebook. 234 00:16:12,700 --> 00:16:16,780 We're going to have plenty of hands on experience with this throughout the rest of the course so stay 235 00:16:16,780 --> 00:16:17,170 tuned.