Python Libraries and Frameworks
Learn to use Python libraries for data processing, machine learning, and deep learning.
Python libraries are a collection of related functions and modules that allow us to reuse the code in our projects. This lesson gives details of the following Python libraries:
NumPy for mathematical functions.
pandas for data processing.
scikit-learn (
sklearn
) for machine learning.The TensorFlow framework and its application programming interface (API) Keras for deep learning.
NumPy for mathematical functions
NumPy or Numerical Python provides a sizable collection of fast numeric functions to perform linear algebra operations using multidimensional arrays and matrices. Remember, an array is a variable to hold several values. In standard Python, lists are arrays; however, lists are slow to process. NumPy’s array object, ndarray, is significantly faster than a list. Furthermore, the availability of arithmetic, trigonometric, and array processing functions makes NumPy a better choice than Python lists.
To create and use ndarrays, use the following code.
import numpy as np# 0-d array or a scalarnp_arr0 = np.array(20)# 1-d arraynp_arr1 = np.array([10, 20, 30, 40, 50])# 2-d arraynp_arr2 = np.array([[10, 20, 30, 40], [90, 80, 70, 60]])# 3-d arraynp_arr3 = np.array([[[10, 20, 30], [40, 50, 60]], [[70, 80, 90], [100, 110, 120]]])print('A 0-d array (scalar):\n', np_arr0,'\n\nA 1-d array:\n', np_arr1,'\n\nA 2-d array:\n', np_arr2,'\n\nA 3-d array:\n', np_arr3)