Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Mastering Numerical Computing with NumPy

You're reading from  Mastering Numerical Computing with NumPy

Product type Book
Published in Jun 2018
Publisher Packt
ISBN-13 9781788993357
Pages 248 pages
Edition 1st Edition
Languages
Authors (3):
Umit Mert Cakmak Umit Mert Cakmak
Profile icon Umit Mert Cakmak
Tiago Antao Tiago Antao
Profile icon Tiago Antao
Mert Cuhadaroglu Mert Cuhadaroglu
Profile icon Mert Cuhadaroglu
View More author details

Table of Contents (11) Chapters

Preface Working with NumPy Arrays Linear Algebra with NumPy Exploratory Data Analysis of Boston Housing Data with NumPy Statistics Predicting Housing Prices Using Linear Regression Clustering Clients of a Wholesale Distributor Using NumPy NumPy, SciPy, Pandas, and Scikit-Learn Advanced Numpy Overview of High-Performance Numerical Computing Libraries Performance Benchmarks Other Books You May Enjoy

Why do we need NumPy?

Python has become a rockstar programming language recently, not only because it has friendly syntax and readability, but because it can be used for a variety of purposes. Python's ecosystem of various libraries makes various computations relatively easy for programmers. Stack Overflow is one the most popular websites for programmers. Users can ask questions by tagging which programming language they relate to. The following figure shows the growth of major programming languages by calculating these tags and plot the popularity of major programming languages over the years. The research conducted by Stack Overflow can be further analyzed via this link to their official blog: https://stackoverflow.blog/2017/09/06/incredible-growth-python/:

Growth of major programming languages

NumPy is the most fundamental package for scientific computing in Python and is the base for many other packages. Since Python was not initially designed for numerical computing, this need has arised in the late 90's when Python started to become popular among engineers and programmers who needed faster vector operations. As you can see from the following figure, many popular machine learning and computational packages use some of NumPy's features, and the most important thing is that they use NumPy arrays heavily in their methods, which makes NumPy an essential library for scientific projects.

The figure shows some well-known libraries which use NumPy features:

NumPy stack

For numerical computing, you mainly work with vectors and matrices. You can manipulate them in different ways by using a range of mathematical functions. NumPy is a perfect fit for these kinds of situations since it allows users to have their computations completed efficiently. Even though Python lists are very easy to create and manipulate, they don't support vectorized operations. Python doesn't have fixed type elements in lists and for example, for loop is not very efficient because, at every iteration, data type needs to be checked. In NumPy arrays, however, the data type is fixed and also supports vectorized operations. NumPy is not just more efficient in multidimensional array operations comparing to Python lists; it also provides many mathematical methods that you can apply as soon as it's imported. NumPy is a core library for the scientific Python data science stack.

SciPy has strong relationship with NumPy as it's using NumPy multidimensional arrays as a base data structure for its scientific functions for linear algebra, optimization. interpolation, integration, FFT, signal and image processing and others. SciPy was built on top of the NumPy array framework and uplifted scientific programming with its advanced mathematical functions. Therefore some parts of the NumPy API have been moved to SciPy. This relationship with NumPy makes SciPy more convenient for advanced scientific computing in many cases.

To sum this up, we can summarize NumPy's advantages as follows:

  • It's open source and zero-cost
  • It's a high-level programming language with user-friendly syntax
  • It's more efficient than Python lists
  • It has more advanced built-in functions and is well-integrated with other libraries
You have been reading a chapter from
Mastering Numerical Computing with NumPy
Published in: Jun 2018 Publisher: Packt ISBN-13: 9781788993357
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}