Book Image

Hands-On Data Science with Anaconda

By : Yuxing Yan, James Yan
Book Image

Hands-On Data Science with Anaconda

By: Yuxing Yan, James Yan

Overview of this book

Anaconda is an open source platform that brings together the best tools for data science professionals with more than 100 popular packages supporting Python, Scala, and R languages. Hands-On Data Science with Anaconda gets you started with Anaconda and demonstrates how you can use it to perform data science operations in the real world. The book begins with setting up the environment for Anaconda platform in order to make it accessible for tools and frameworks such as Jupyter, pandas, matplotlib, Python, R, Julia, and more. You’ll walk through package manager Conda, through which you can automatically manage all packages including cross-language dependencies, and work across Linux, macOS, and Windows. You’ll explore all the essentials of data science and linear algebra to perform data science tasks using packages such as SciPy, contrastive, scikit-learn, Rattle, and Rmixmod. Once you’re accustomed to all this, you’ll start with operations in data science such as cleaning, sorting, and data classification. You’ll move on to learning how to perform tasks such as clustering, regression, prediction, and building machine learning models and optimizing them. In addition to this, you’ll learn how to visualize data using the packages available for Julia, Python, and R.
Table of Contents (15 chapters)

Introduction

Nowadays, we are overwhelmed by large amounts of information—see Shi, Zhang, and Khan (2017), or Fang and Zhang (2016)—the catchphrase being big data. However, defining it is still controversial, since many explanations are available. Davenport and Patil (2012) suggest that if your organization stores multiple petabytes of data, if the information most critical to your business resides in forms other than rows and columns of numbers, or if answering your biggest question would involve a mashup of several analytical efforts, you've got a big data opportunity.

Many users of data science or data analytics are learning several programming languages such as R and Python, but how can they use both of them at the same time? If John is using R while his teammate is using Python, how do they communicate with each other? How do team members share their packages, programs, and even their working environments? In this book, we try our best to offer a solution to all of these challenging tasks by introducing Anaconda, since it possesses several wonderful properties.

Generally speaking, R is a programming language for statistical computing and graphics that is supported by the R Foundation for statistical computing. Python is an interpreted, object-oriented programming language similar to Perl that has gained popularity because of its clear syntax and readability. Julia is for numerical computing and extensive mathematical function and is designed for parallelism and cloud computing, while Octave is for numerical computation and mathematics-oriented and batch-oriented language. All those four languages, R, Python, Julia, and Octave, are free.

Reasons for using Jupyter via Anaconda

In data science or data analytics, we usually work in a team. This means that each developer, researcher, or team member, might have his/her favorite programming language, such as Python, R, Octave, or Julia. If we could have a platform to run all of those languages, it would be great. Fortunately, Jupyter is such a platform, since this platform can accommodate over 40 languages, including Python, R, Julia, Octave, and Scala.

In Chapter 2, Anaconda Installation, we will show you how to run those four languages via Jupyter. Of course, there are other benefits of using Anaconda: we might worry less about the dependency of installed packages, manage packages more efficiently, and share our programs, projects, and working environments. In addition, Jupyter Notebooks can be shared with others using email, Dropbox, GitHub, and the Jupyter Notebook Viewer.

Using Jupyter without pre-installation

In Chapter 2, Anaconda Installation, we will discuss how to install Jupyter via Anaconda installation. However, we could launch Jupyter occasionally without pre-installation by going to the web page at https://jupyter.org/try:

  1. The welcome screen will be presented with various options for trying out different languages.
  2. For example, by clicking the Try Jupyter with Julia image, we would see the following screen:
  1. To save space, the screenshot shows only the first part of the demo. Any readers could try the previous two steps to view the whole demo. In addition, if we click the Try Jupyter with R image, the following screen would show:
  1. After selecting Try Jupyter with Python, you will be presented with the welcome screen for the same.
  1. Next, we will show you how to execute a few simple commands in R, Python, and Julia. For example, we could use R to use the platform to run a few simple command lines. In the following example, we enter pv=100, r=0.1,and n=5:
  1. After clicking the Run button on the menu bar, we assign those values to the three variables. Then we can estimate the future value of this present value, as illustrated here:
  1. Similarly, we could try to use Python, as shown here:

In the preceding example, we import the Python package called scipy and give it a short name, sp. Although other short names could be used to represent the scipy package, it is a convention to use sp. Then, we use the sqrt() function included in the Python package.

For Julia, we could try the following code (shown in the following screenshot). Again, after going to File|New on the menu, we choose Julia 0.6.0. As of May 09, 2018, 0.6.0 is the current version for Julia. Note that your current version for Julia could be different:

In the code, we define a function called sphere_vol with just one input value of r (in radians). The answer is 64.45 for an input value of 2.5.