MITB Banner

Beginner’s Guide to NumPy: A Must Have Python Library in Data Scientist Toolkit

Share

NumPy, which stands for Numerical Python, is a fundamental library for mathematical computations. This library can be used for different functions in Linear algebra, Matrix computations, Fourier Transforms etc. In Python, array.array function is limited to only one dimension which can be substituted with NumPy for multi dimensional operations. One can compute the multidimensional array functions like the figure below,

In this article we will go through some of the important built-in function of NumPy to understand the logic and mathematics behind it. By using NumPy, you can speed up your workflow, and interface with other packages in the Python ecosystem, like scikit-learn, that use NumPy under the hood. Let us dive into computing the math behind these.

1. Arrays

An array is a set of elements of a data type. The shape of the NumPy array can be defined with an enclosed tuple of positive integers. The order of a NumPy array is given by the dimensions. We can index and slice a particular element from the array, and initialize an array with square brackets like below,

2. Indexing

Like Python lists, the Numpy array can be indexed and sliced with the right number of parameters. It can be done as described below,

3. Slicing

Index slicing is as it sounds, slicing one or multi dimensional array into different subsets like below example,

With the use of negative numbers, we can compute the functions in the reverse order like the example below,

Let us consider a multi-dimensional array and try to slice it.

We can implement the following code to slice it,

4. Matrix Algebra

After these steps, matrix multiplication is important, which can be done in two ways. We can either use the dot function, which applies a matrix-matrix, matrix-vector, or inner vector multiplication to its two arguments:

5. Matrix Computations

Functions such as finding the inverse of a matrix and determinant of a matrix can also be done with NumPy like below,

6. Statistical Computations

Most of the times it is useful to store datasets in NumPy arrays. It provides a number of functions to calculate statistics of datasets in arrays. Let us calculate some properties of the matrix B,

PS: The story was written using a keyboard.
Share
Picture of Kishan Maladkar

Kishan Maladkar

Kishan Maladkar holds a degree in Electronics and Communication Engineering, exploring the field of Machine Learning and Artificial Intelligence. A Data Science Enthusiast who loves to read about the computational engineering and contribute towards the technology shaping our world. He is a Data Scientist by day and Gamer by night.
Related Posts

CORPORATE TRAINING PROGRAMS ON GENERATIVE AI

Generative AI Skilling for Enterprises

Our customized corporate training program on Generative AI provides a unique opportunity to empower, retain, and advance your talent.

Upcoming Large format Conference

May 30 and 31, 2024 | 📍 Bangalore, India

Download the easiest way to
stay informed

Subscribe to The Belamy: Our Weekly Newsletter

Biggest AI stories, delivered to your inbox every week.

AI Courses & Careers

Become a Certified Generative AI Engineer

AI Forum for India

Our Discord Community for AI Ecosystem, In collaboration with NVIDIA. 

Flagship Events

Rising 2024 | DE&I in Tech Summit

April 4 and 5, 2024 | 📍 Hilton Convention Center, Manyata Tech Park, Bangalore

MachineCon GCC Summit 2024

June 28 2024 | 📍Bangalore, India

MachineCon USA 2024

26 July 2024 | 583 Park Avenue, New York

Cypher India 2024

September 25-27, 2024 | 📍Bangalore, India

Cypher USA 2024

Nov 21-22 2024 | 📍Santa Clara Convention Center, California, USA

Data Engineering Summit 2024

May 30 and 31, 2024 | 📍 Bangalore, India