zekeLabs
Essential NumPy
Learning made Simpler !
www.zekeLabs.com
Agenda
● Introduction to NumPy
● Initialization & Creation of NumPy
● Accessing
● Concatenation
● Splitting
● Shape,Size & ndim
● Reshaping
● Changing Dimension
● NumPy Utility Functions
● Broadcasting
Introduction to NumPy
● N-dim array for fast mathematical calculation
● Homogeneous data structure
● Written in C/C++
● Scikit-learn is implemented using this
● Python List is generalized & thus slow
Initialization
● Size is important parameter for all of them
● Zeros - initialized with zero values
● Ones - initialized with one values
● Empty - uninitialized array ( contains garbage value )
● Full - initialized with value passed
● Random - different methods to initialize random values
● Lin_space - generate equally spaced numbers between start & stop values
● Ones_like - based on passed numpy object, size is allocated with all one
Initialization
Initialization
Initialization
Access
● Very similar to that of accessing list
Concatenation
● Axis = 0 means vertical
● Axis = 1 means horizontal
● Concatenate - join numpy array along provided axis
● Hstack - joining numpy array horizontally
● Vstack - joining numpy array vertically
● For any of these operations to happen, the joining edge should be of shape
size. 3 X 2 matrix hstacks with 3 X 5
Concatenation
Splitting
● Splits array into subarrays
● Split - Splits the array as per axis mentioned
● Hsplit - This splits the horizontal axis
● Vsplit - This splits the vertical axis
Splitting
Shape, Size, ndim
Reshaping
● Learning algorithms expects data in certain shape & dimension
● Using reshaping utility we can convert data into desired shape.
● But, the desired transformation will also be of same size
● Adding 1 dimensions will not alter data size
Reshaping
Adding Dimension
● Learning algorithms consumes data in
two dimension
● Below, we are converting 1-D array to 2-D
Adding Dimension
Utility Functions
● NumPy has a huge list of mathematical functions to make implementing
machine learning algorithms very easy
● A few of them are
● Max
● Min
● Mean
● Std
● Cov
● Cumprod
● all
● any
● Mean
● dot
● multiply
● sqrt
Broadcasting
● Single row matrix are known as vectors
● Broadcasting is a technique using which NumPy does mathematical
computation on data of different shapes & dimension
● We might need to reshape the data sometimes to enable broadcasting
Broadcasting
Thank You !!!
Visit : www.zekeLabs.com for more details
THANK YOU
Let us know how can we help your organization to Upskill the
employees to stay updated in the ever-evolving IT Industry.
Get in touch:
www.zekeLabs.com | +91-8095465880 | info@zekeLabs.com

Essential NumPy By ZekeLabs

  • 1.
    zekeLabs Essential NumPy Learning madeSimpler ! www.zekeLabs.com
  • 2.
    Agenda ● Introduction toNumPy ● Initialization & Creation of NumPy ● Accessing ● Concatenation ● Splitting ● Shape,Size & ndim ● Reshaping ● Changing Dimension ● NumPy Utility Functions ● Broadcasting
  • 3.
    Introduction to NumPy ●N-dim array for fast mathematical calculation ● Homogeneous data structure ● Written in C/C++ ● Scikit-learn is implemented using this ● Python List is generalized & thus slow
  • 4.
    Initialization ● Size isimportant parameter for all of them ● Zeros - initialized with zero values ● Ones - initialized with one values ● Empty - uninitialized array ( contains garbage value ) ● Full - initialized with value passed ● Random - different methods to initialize random values ● Lin_space - generate equally spaced numbers between start & stop values ● Ones_like - based on passed numpy object, size is allocated with all one
  • 5.
  • 6.
  • 7.
  • 8.
    Access ● Very similarto that of accessing list
  • 9.
    Concatenation ● Axis =0 means vertical ● Axis = 1 means horizontal ● Concatenate - join numpy array along provided axis ● Hstack - joining numpy array horizontally ● Vstack - joining numpy array vertically ● For any of these operations to happen, the joining edge should be of shape size. 3 X 2 matrix hstacks with 3 X 5
  • 10.
  • 11.
    Splitting ● Splits arrayinto subarrays ● Split - Splits the array as per axis mentioned ● Hsplit - This splits the horizontal axis ● Vsplit - This splits the vertical axis
  • 12.
  • 13.
  • 14.
    Reshaping ● Learning algorithmsexpects data in certain shape & dimension ● Using reshaping utility we can convert data into desired shape. ● But, the desired transformation will also be of same size ● Adding 1 dimensions will not alter data size
  • 15.
  • 16.
    Adding Dimension ● Learningalgorithms consumes data in two dimension ● Below, we are converting 1-D array to 2-D
  • 17.
  • 18.
    Utility Functions ● NumPyhas a huge list of mathematical functions to make implementing machine learning algorithms very easy ● A few of them are ● Max ● Min ● Mean ● Std ● Cov ● Cumprod ● all ● any ● Mean ● dot ● multiply ● sqrt
  • 19.
    Broadcasting ● Single rowmatrix are known as vectors ● Broadcasting is a technique using which NumPy does mathematical computation on data of different shapes & dimension ● We might need to reshape the data sometimes to enable broadcasting
  • 20.
  • 21.
  • 22.
    Visit : www.zekeLabs.comfor more details THANK YOU Let us know how can we help your organization to Upskill the employees to stay updated in the ever-evolving IT Industry. Get in touch: www.zekeLabs.com | +91-8095465880 | info@zekeLabs.com