A blog for computer science passionates.

Wednesday 30 October 2019

How to start ML & DL? NumPy Module Part - 2.3

Hello Friends!!!

In this article, we are going to discuss NumPy methods. In the previous article, we have learned NumPy attributes. (If you did not know different attributes of NumPy, please refer first) Now we are going to start different methods of the NumPy module.

  • numpy.arange - it returns numbers. it returns number in a sequence and defines an array of those numbers. it is equivalent to range (python in-built function).
    • Syntax: numpy.arange([start],stop,[step],dtype=None)
      • Here, start - is an optional argument. it defines start interval, the default start is 0.
      • stop - is compulsory, it is ending interval.
      • step - is also an optional parameter, it defines that with which value adjacent value is generated or increased.
      • dtype - is compulsory, but it also has the default value i.e. None. it represents data type of an array.
    • It returns ndarray object. i.e. array with type ndarray
  • Example, 
  • numpy.array - it returns an array.  
    • Syntax: numpy.array(object,dtype=None,copy=True,order='K',subok=False,ndmin=0)
      • Here, object - is a compulsory argument. in this argument, we need to pass any object that exposes an array interface.
      • dtype - is optional. it represents any desired type of array elements.
      • copy - is optional. if it is set as True, the object is copied.
      • order -is an optional argument. order maybe 'K', 'A', 'C', 'F' etc. is used to specify memory order. i.e. how elements are stored in memory. Here, K and A are unchanged and based on C and F order. C order means row-wise and F order means column-wise elements storing. default order is 'K'.
      • subok - is an optional argument. if this argument is set as True, it generates subclass array. otherwise it forced to be a base - class array. by default, it creates the base - class array.
      • ndmin - is an optional argument, describes the minimum number of dimensions of a resulting array. 
    • It returns ndarray object. 
  • Example, 
We will learn more methods in the next part of the article, through this article you can learn these two methods to create an array by using numpy.

Happy Coding...!!!☺

No comments:

Post a Comment