Using Copilot with Jupyter Notebooks

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
did you know that GitHub copilot can be a great assistant helping you writing your Jupiter notebook giving you suggestions with your python code or your data analysis task I'm kalota castelluccio Cloud Advocate at Microsoft focusing on artificial intelligence and machine learning and in this video I'm going to give you a practical example of it a Jupiter notebook is one of the most popular tools used by data scientists for data and machine learning projects it lets you easily combine markdown text and executable source code on one canvas and let you quickly visualize the results of your experiments or your data if you are new to copilot you might want to watch an introductory video about this powerful AIS system before deep diving with me in this video into how it helps you with jupyter notebook development for this time we are going to create a jupyter notebook in Visual Studio code we are going to use two extensions GitHub copilot extension and a GitHub code spaces extension and now work in a code space is very similar to working on a lab container in a virtual machine on the cloud you can commit to your GitHub repository a few configuration files to set up your development environment with the settings and prerequisites required for your data science experiments so I have here my two CPU cores for a giga memory code spaces built upon one of my GitHub repository with a few requirements installed like python3.a and some common python data science libraries we're going to import in the notebook going to the repo let me create a new Jupiter notebook that I will rename Titanic data analysis whereas copilot one key element of a notebook is the kernel the kernel is a programming language specific process in this case python that executes the code cells in the notebook the first cell we want to add to this notebook will be a markdown cell containing the title of the notebook along with a description of what we are going to do to Showcase GitHub copilot capabilities with jupyter notebooks I'm going to load here and explore the Titanic data set one popular data set among data scientists collecting information about a few hundred passengers who are bored the Titanic at the time of the fatal accident so the title I'll be giving to this notebook will be exploring Titanic data who is co-pilot you can notice how as you start typing copilot starts giving me text completions the great suggestions that appear based on the most probable text that you follow my prompt to give some context to the name I'm going to build I start also writing a description of the Titanic history and see if copilot can help me in this task so let me write the Titanic is and see what co-pilot suggests so is a famous ship that sank in 1912 the data set contains information about the passengers on the ship and the goal of this notebook is to explore the data set and find out what factors made people more likely to survive since it's a good fit for my notebook I'm going to accept the whole suggestion by clicking on Tab as a Next Step let's start writing some python code with the help of our AI pay programmer first of all let's import the pandas library to load and handle data in our notebook and let's specify the URL of the Titanic data set we'd like to explore by just clicking on the enter button here I get suggested code from copilot which is the code to upload the data into a pandas data frame from the specified URL this is one way copilot uses to help us writing our code simply suggesting our next line starting from what we wrote In this case The Prompt is written in Python however copilot can also help us use English as programming language by converting instruction written in natural language as a python comment for example into a line of code now we might want to have a quick overview of the first few rows of our data set so let's write our request in English like a pattern comment so let's have an overview of the data by printing the first five rows and then let's click on enter the result of the code suggested by copilot shows all the columns and the first five rows of our data so our data set contains the binary indicator if the passenger survived the passenger class the name sex and the age of the passenger the ticket number and the ticket fare the cabin and port of departure there are also two other columns whose titles are not so clear cite SP and parts we can rely on the Q a feature to clarify let's create a new cell and let's ask our question to copilot what is the meaning of type SP site SP is the number of siblings and spouses aboard the Titanic wonderful next question what is the meaning of parts let's see GitHub copilot answer perch is the number of parents and children aboard the Titanic now that's very much clearer thanks copilot let's conclude this quick data overview by looking at how many people from the ones trapped in our data set survive the Shipwreck and how many didn't let's again create a new python comment let's compute how many passengers have survived and that's print the value so it is now elaborating the answer yes so we have the the command and we were looking for to compute the number of survived and the print command let's now compute how many passengers did not survive and let's print the value copilot is taking some time to give us an answer so in this case we can start typing the answers to see if we get a suggestion for example not survived which is the name of our variable and then equal and we await for the suggestion and then we print the result create GitHub copilot helped us learn from the data that 342 passengers were lucky enough to survive to the tragedy and 549 lost their lives in the accident now that we have explored the beat our data the last piece I wish to show you is how copilot can help us perform data visualization in our jupyter notebook data visualization is a significant step of the analysis enabling us to retrieve insights from the data we might not simply extract otherwise something we can do for example is exploring the correlation between the number of passengers survived in their class to check if the class is a significant factor in passengers likelihood to survive the Hollywood narration of the Titanic shipwreck told us that there's a huge correlation between the two let's see if it is true to do so let's create a new card cell in which we write our instruction which is let's look at the correlation between the column survive which is our Banner label and the column p-class which is the passenger class let's add that we want to visualize the number of people per each class survive or not with a categorical kind of plot and let's click enter GitHub copilot convert our comment into a few lines of code first of all it Imports the Seabourn library and then it builds the cash plot so let's execute the code suggested by copilot and let's look at the resulting graph we can see that the first class is the only one for which the number of people survived is higher than the number of people who didn't if we look at the third class number of people who didn't survive is very much higher than people survived even if the total number of passengers in the third class is the highest confirming our fast guess we have seen how GitHub copilot can help us with Jupiter notebook's development by suggesting the description of our project in the markdown cells generating code from our comments or answering our questions GitHub copilot is a great tool that makes our work easier and more efficient enabling us to focus on more complex and creative tasks but let's always remember that a code generated by copilot is not perfect and us as developers are the actual Pilots responsible for our code written with the help of an AI assistant or not thanks for watching this video hope you enjoyed it and if you got some value out of these make sure to like And subscribe to the channel if you are interested also in learning more about using GitHub copilot with other programming languages and Frameworks check out the other videos of this series [Music]
Info
Channel: Visual Studio Code
Views: 30,507
Rating: undefined out of 5
Keywords: vscode, visual studio code, vs code
Id: QS_bh-3qKdw
Channel Id: undefined
Length: 10min 2sec (602 seconds)
Published: Mon May 01 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.