Numpy is the core library for scientific computing in Python. It provides a high-performance multidimensional array object, and tools for working with these arrays.

## Why learn Numpy?

In the Introductory Course on Machine learning, we will be using numpy to build the models introduced in Andrew Ng’s Machine Learning course and solve the excercises. Note that octave is used in that course instead. Since most of the existing machine learning frameworks today are based on python (Tensorflow, Theano, etc), I figured it would be practical to use numpy to understand these basic machine learning models. Numpy is also easy to learn and experiment with and it plays well with the Tensorflow and Theano.

## Lets start

We will be working with arrays. Arrays are numpy objects of type ndarray. They contain elements of type dtype and have a particular shape.

## Summary

Convert a list to numpy array np.array() np.array([1,2,3,4])
Create a null vector of size 10 np.zeros() np.zeros(10)
Create a vector with values ranging from 10 to 49 np.arange() np.arange(10,50)
Create a 3x3 matrix with values ranging from 0 to 8 np.reshape() np.arange(9).reshape(3,3)
Create a 3x3 identity matrix np.eye() np.eye(3)
Create a 3x2x2 array with random values np.random.random() np.random.random([3,2,2])
Create a 4x4 array (x) with random integers from 0-99 np.random.randint() x = np.random.randint(0,100,[4,4])
Find the index of maximum of x np.argmax(), np.unravel_index np.unravel_index(x.argmax(),x.shape)
Find the index of minimum of x np.argmin(), np.unravel_index np.unravel_index(x.argmin(),x.shape)
Find mean of x np.mean() x.mean()
Find sum of all elements in x np.sum() x.sum()
Find the datatype of x np.dtype x.dtype
Set datatype of x as float32 np.astype() x.astype(‘float32’)