Book Image

Learning Jupyter

By : Dan Toomey
Book Image

Learning Jupyter

By: Dan Toomey

Overview of this book

Jupyter Notebook is a web-based environment that enables interactive computing in notebook documents. It allows you to create and share documents that contain live code, equations, visualizations, and explanatory text. The Jupyter Notebook system is extensively used in domains such as data cleaning and transformation, numerical simulation, statistical modeling, machine learning, and much more. This book starts with a detailed overview of the Jupyter Notebook system and its installation in different environments. Next we’ll help you will learn to integrate Jupyter system with different programming languages such as R, Python, JavaScript, and Julia and explore the various versions and packages that are compatible with the Notebook system. Moving ahead, you master interactive widgets, namespaces, and working with Jupyter in a multiuser mode. Towards the end, you will use Jupyter with a big data set and will apply all the functionalities learned throughout the book.
Table of Contents (16 chapters)
Learning Jupyter
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface

Preface

Learning Jupyter discusses using Jupyter to record your scripts and results for a data analysis project. Jupyter allows the data scientist to record their complete analysis process, much in the same way other scientists use a lab notebook for recording tests, progress, results and conclusions. Jupyter works in a variety of operating systems and the book covers the use of Jupyter in Windows and Mac OS X along with the various steps necessary to enable your specific needs. Jupyter supports a variety of scripting languages by the addition of language engines so the user can portray their script natively in it.

What this book covers

Chapter 1, Introduction to Jupyter, takes a first look at the Jupyter user interface, walks through installing Jupyter on Windows and Mac OS X, examines the basic operations of Jupyter Notebook available through the user interface for all engines, and gives an overview of the security features available and configuration options.

Chapter 2, Jupyter Python Scripting, walks through a simple Python notebook and the underlying structure. This chapter also shows an example of using pandas, graphics, and using random numbers in a Python script.

Chapter 3, Jupyter R Scripting, adds the ability to use R scripts in your Jupyter Notebook, adds an R library not included in the standard R installation, makes a Hello World script in R, and shows R data access against built-in libraries and some of the simpler graphics and statistics that are automatically generated. We use an R script to generate 3D graphics in a couple of different ways, perform a cluster analysis, and use one of the forecasting tools available in R.

Chapter 4, Jupyter Julia Scripting, adds the ability to use Julia scripts in your Jupyter Notebook, adds a Julia library not included in the standard Julia installation, and shows the basic features of Julia. We outline some of the limitations encountered with using Julia in Jupyter and display graphics using some of the graphics packages available, including Gadfly, Winston, Vega, and Pyplot. We show parallel processing in action, a small control flow example, and how to add unit testing to your Julia script.

Chapter 5, Jupyter JavaScript Coding, shows how to add JavaScript to a Jupyter Notebook, some of the limitations of using Javascript in Jupyter and examples of several packages that are exemplary of Node.js coding, including d3 for graphics, stats-analysis for statistics, built-in JSON handling, Canvas for creating graphics files and Plotly used for generating graphics with a third-party tool. You learn how multi-threaded applications can be developed using Node.js under Jupyter and use machine learning to develop a decision tree.

Chapter 6, Interactive Widgets, adds widgets to our Jupyter installation, uses interact and interactive widgets to produce a variety of user input controls. We explain the widgets package in depth to investigate the user controls available, properties available in the containers, and events that are available emitting from the controls. You will see how to build containers of controls.

Chapter 7 , Sharing and Converting Jupyter Notebooks, shares notebooks on a notebook server, adds a notebook to a web server, distributes at notebook using GitHub, and looks into converting our notebooks into different formats, such as HTML and PDF.

Chapter 8 , Multiuser Jupyter Notebooks, exposes a notebook so that multiple users can use a notebook at the same time, and shows an example of the multiuser error occurring. We will install a Jupyter server that overcomes the multiuser issue and use Docker to alleviate the issue as well.

Chapter 9, Jupyter Scala, installs Scala for Jupyter, uses Scala coding to access larger datasets, shows how Scala can manipulate arrays, and generates random numbers in Scala. There are examples of higher-order functions and pattern matching, uses case classes, and immutability in Scala. We build collections using Scala packages and show the use of Scala traits.

Chapter 10 , Jupyter and Big Data, uses Spark functionality via Python coding for Jupyter, installs the Spark additions to Jupyter on a Windows machine and a Mac machine, and displays an initial script that just reads lines from a text file. We also determine the word counts in that file, sort the results, use a script to estimate pi, evaluate web log files for anomalies, determine a set of prime numbers, and evaluate a text stream for some characteristics.

What you need for this book

The steps in this book assume you have a modern Windows or Macintosh machine with Internet access. There are several points where you will need to install software, so you need administrative privileges to the machine to do so.

Who this book is for

This book is written for the user who wants to portray software to others in a natural programming context. Jupyter provides the mechanism to execute a number of different languages and stores the results for display as if the user ran those scripts on their machine.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Interestingly, the max function does not work as expected."

A block of code is set as follows:

{ 
  "cells": [ 
    <<same format as seen earlier for the cells>> 
  ], 
  "metadata": { 
    "kernelspec": { 
      "display_name": "Javascript (Node.js)", 
      "language": "javascript", 
      "name": "javascript" 
    }, 
    "language_info": { 
      "file_extension": ".js", 
      "mimetype": "application/javascript", 
      "name": "javascript", 
      "version": "4.2.4" 
    } 
  }, 
  "nbformat": 4, 
  "nbformat_minor": 0 
}

Any command-line input or output is written as follows:

Pkg.add("DataFrames")
Pkg.add("RDatasets")
Pkg.add("Gadfly")
quit();

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "The Upload button is used to add files to the notebook space."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.

  2. Hover the mouse pointer on the SUPPORT tab at the top.

  3. Click on Code Downloads & Errata.

  4. Enter the name of the book in the Search box.

  5. Select the book for which you're looking to download the code files.

  6. Choose from the drop-down menu where you purchased this book from.

  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows

  • Zipeg / iZip / UnRarX for Mac

  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Learning-Jupyter. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/LearningJupyter_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.