Home Data Hands-On Data Science with Anaconda

Hands-On Data Science with Anaconda

By Yuxing Yan , James Yan
books-svg-icon Book
eBook $29.99 $20.98
Print $38.99
Subscription $15.99 $10 p/m for three months
$10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
eBook $29.99 $20.98
Print $38.99
Subscription $15.99 $10 p/m for three months
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
  1. Free Chapter
    Ecosystem of Anaconda
About 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.
Publication date:
May 2018
Publisher
Packt
Pages
364
ISBN
9781788831192

 

Ecosystem of Anaconda

In the preface, we mentioned that this book is designed for readers who are looking for tools in the area of data science. Existing data analysts and data science professionals who wish to improve the efficiency of their data science applications by using the best libraries with multiple languages will find this book quite useful. The platform discussed in detail across various chapters is Anaconda and the computational tools could be Python, R, Julia, or Octave. The beauty of using these programming languages is that they are all open source, as in free to download. In this chapter, we start from the very beginning: a simple introduction. For this book, we assume that readers have some basic knowledge related to several programming languages, such as R and Python. There are many books available, such as Python for Data Analysis by McKinney (2013) and Python for Finance by Yan (2017).

In this chapter, the following topics will be covered:

  • Introduction
  • Miniconda
  • Anaconda Cloud
  • Finding help
 

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.

 

Miniconda

Anaconda is a full distribution of Python and comes with over 1,000 open source packages after installation. Because of this, the total size is over 3 GB. Anaconda is good if we intend to have many packages downloaded and pre-installed. On the other hand, Miniconda contains only Python and other necessary libraries needed to run conda itself. The size for the Miniconda is about 400 MB, much smaller than the full version of Anaconda, so extra packages have to be downloaded and installed as requested.

There are many reasons why a new user might prefer a watered-down version of Anaconda. For example, they might not need so many packages. Another reason is that users might not have enough space. Those users could download Miniconda at https://conda.io/miniconda.html. Again, in Chapter 2, Anaconda Installation, we will discuss in detail how to install Anaconda and run programs written in different languages, such as Python, R, Julia, and Octave.

 

Anaconda Cloud

In Chapter 2, Anaconda Installation, we'll explain this in more detail. This function is used to collaborate with different users or group members. For example, we have a small group of ten developers working on the same project. For this reason, we have to share our programs, command datasets, and working environments, and we could use Anaconda Cloud to do so. After going to https://anaconda.org/, we will be directed to the Anaconda home page.

Note that users have to register with Anaconda before they can use this function. For example, one of the authors has the link https://anaconda.org/paulyan/dashboard. After we register, we can see the following:

Later in the book, we devote a whole chapter to this.

 

Finding help

There are many websites we can visit to get help. The first allows us to find the user guide, shown at the following link: https://docs.anaconda.com/anaconda/user-guide/. After we click the link, we will see four entries:

We can find lots of information by choosing one of the previous four entries. For example, after clicking Getting started with Anaconda, we will see the following information:

From the Navigator bar in the left-hand side, we could go to Tasks, and then we have the following entries:

For example, after clicking on Installing conda packages, we can see the following information (only the first part of the document is shown to save space):

For developers, we have the following links:

 

Summary

In this chapter, we have introduced some basic concepts, such as the reasons why we use Anaconda, and the advantages of using full-fledged Anaconda and/or its baby version, Miniconda. Then, it was shown that without installing Anaconda, we could still use it by visiting a designated website. We could also test a few simple programs there, writing in R, Python, Julia, or Octave.

In Chapter 2, Anaconda Installation, we will show you how to install Anaconda and test if the installation is successful. We will look at how to launch Jupyter, how to launch Python, Spyder, and R, and how to find related help. Most of those concepts or procedures are quite basic, so readers who are confident with those basic concepts can skip this chapter, Chapter 2, Anaconda Installation, and go to Chapter 3, Data Basics, directly.

 

Review questions and exercises

  1. What is Anaconda and how do we use its platform?
  2. How many open source packages are accompanied with Anaconda?
  3. What is the home page for Anaconda?
  4. How do we install Anaconda? After Anaconda is installed, should we install Python separately? What about R?
  5. What is the size of a full Anaconda installation?
  6. Why should we care about Miniconda?
  7. What is Jupyter? How do we launch it without installation?
  8. What are the advantages and disadvantages of using https://jupyter.org/try?
  9. Where could a new learner find more useful information about Anaconda?
  10. Get more information about the Julia programming language.

  1. How do we write a simple program in Julia via Jupyter?
  2. How do we write a simple program in R via Jupyter?
  3. How do we find help for Jupyter?
  4. What is the conda Cheat Sheet and where can we download it?
  5. Could we run a simple R program without installing Anaconda?
  6. Could we run Anaconda without pre-installing it?
  7. Try the following two lines of Python code:
import numpy as np
print(np.sqrt(2))
  1. Try the following simple code for R:
x<-1:500
mean(x)
sd(x)
  1. Try the following code for Julia:
x=1:500
mean(x)
  1. Try the following code for R:
dd<-Sys.Date()
dd+40

About the Authors
  • Yuxing Yan

    Yuxing Yan graduated from McGill University with a PhD in finance. Over the years, he has been teaching various finance courses at eight universities: McGill University and Wilfrid Laurier University (in Canada), Nanyang Technological University (in Singapore), Loyola University of Maryland, UMUC, Hofstra University, University at Buffalo, and Canisius College (in the US). His research and teaching areas include: market microstructure, open-source finance and financial data analytics. He has 22 publications including papers published in the Journal of Accounting and Finance, Journal of Banking and Finance, Journal of Empirical Finance, Real Estate Review, Pacific Basin Finance Journal, Applied Financial Economics, and Annals of Operations Research. He is good at several computer languages, such as SAS, R, Python, Matlab, and C. His four books are related to applying two pieces of open-source software to finance: Python for Finance (2014), Python for Finance (2nd ed., expected 2017), Python for Finance (Chinese version, expected 2017), and Financial Modeling Using R (2016). In addition, he is an expert on data, especially on financial databases. From 2003 to 2010, he worked at Wharton School as a consultant, helping researchers with their programs and data issues. In 2007, he published a book titled Financial Databases (with S.W. Zhu). This book is written in Chinese. Currently, he is writing a new book called Financial Modeling Using Excel — in an R-Assisted Learning Environment. The phrase "R-Assisted" distinguishes it from other similar books related to Excel and financial modeling. New features include using a huge amount of public data related to economics, finance, and accounting; an efficient way to retrieve data: 3 seconds for each time series; a free financial calculator, showing 50 financial formulas instantly, 300 websites, 100 YouTube videos, 80 references, paperless for homework, midterms, and final exams; easy to extend for instructors; and especially, no need to learn R.

    Browse publications by this author
  • James Yan

    James Yan is an undergraduate student at the University of Toronto (UofT), currently double-majoring in computer science and statistics. He has hands-on knowledge of Python, R, Java, MATLAB, and SQL. During his study at UofT, he has taken many related courses, such as Methods of Data Analysis I and II, Methods of Applied Statistics, Introduction to Databases, Introduction to Artificial Intelligence, and Numerical Methods, including a capstone course on AI in clinical medicine.

    Browse publications by this author
Latest Reviews (2 reviews total)
as wrote above ...........................
Plutôt bien fait et actuel
Hands-On Data Science with Anaconda
Unlock this book and the full library FREE for 7 days
Start now