Intro to Machine Learning (ML), Matrices & NumPy
Installation: conda install numpy
import numpy as np
my_matrix = [[1,2,3],[4,5,6],[7,8,9]]
np.array(my_list) OR np.array(my_matrix)
======================================
np.arange(0,10) // Creating an array from 0 to 9
np.arange(0,11,2) / with step size of 2
Generate Zeros and Ones: np.zeros(3) // 1 D
np.ones((3,3)) // 2D
Return evenly line spaced: np.linspace(0,10,3) // last number represents the number / how many
Create identity matrix: np.eye(4) // 2D square matrix; diagonal is 0 the rest is 0
======================================
Create a random matrix: np.random.rand(5,5) // create an array uniformly distributed.
Create a standard normal distribution: np.random.randn(5,5) // from standard / normal distribution
Create a random integer from low to high: np.random.randint(1,100,10) / random integer from low to
high number.
np.random.rantint(5,100) // create a random value from 5 to 100
arr = np.arange(25)
ranarr = np.random.mandint(0,50,10)
arr.reshape() // reshape value
arr.shape // call the shape of data
ranarr.min()
ranarr.max()
ranarr.arnmax()
ranarr.argmin()
arr.dtype
Vector - 1D array
Matrices - 2D array