Notebooks are a very interesting coding technique that have risen to prominence recently. Basically, they allow us to write code in a particular language, Python in this case, in an environment where we can see the code, results and comments in a single view. This is extremely useful in scenarios where we want to showcase our techniques and results to our colleagues. Let's take a look at the Notebook within AML Workbench.
We also notice is that the top-right corner now says "EDIT MODE" instead of "PREVIEW MODE". This means that we now have the ability to interact with the Notebook. However, we first need to instantiate a "kernel". For clarity, the term "kernel" here refers to the computer science term. You can read more about the other types of kernels here. Basically, without a kernel, we don't have any way of actually running our code. So, let's spin one up.
The creators of this notebook were nice enough to provide some additional information in the notebook. This formatted text is known as "Markdown". Basically, it's a very easy way to add cleanly formatted text to the notebook. You can read more about it here.
Depending on your setup, you may need to run these two commands from the "Command Prompt". We looked at how to use the Command Prompt in the first post in this series. If you run into any issues, try running the commands in the first post and restarting the kernel. Let's look at the first segment of code.
We also see one of the major advantages of utilizing notebooks. The "%azureml history off" command creates an output in the console. The notebook captures this and displays it just below the code segment. We'll see this in a much more useful manner later in this post. Let's check out the next code segment.
pickle: Serializes and Deserializes Python Objects
sys: Contains System-Specific Python Parameters and Functions
os: Allows Interaction with the Operating System
numpy: Allows Array-based Processing of Python Objects
matplotlib: Allows 2-Dimensional Plotting
sklearn (aka scikit-learn): Contains Common Machine Learning Capabilities
azureml: Contains Azure Machine Learning-specific Functions
Let's move on to the next segment.
Finally, this code prints the current version of Python we are utilizing. Again, we see the advantage of using notebooks, as we get to see the code and the output in a single block. Let's move on the final code segment for this post.
Hopefully, this post opened your minds to the possibilities of using Python Notebooks within AML Workbench. Notebooks are quickly becoming the industry standard technique for sharing data science experiments, and will no doubt play a major role in the day-to-day tasks of most Data Scientists. Stay tuned for the next post where we'll walk through the data science code within the "iris" notebook. Thanks for reaching. We hope you found this informative.
Senior Analytics Associate - Data Science