ML Class Presentation Notes
ML Class Presentation Notes
Vector: An array of numbers(data) is a Each element can be reached via its row and column and is denoted by
vector. You can assume a column in a dataset a subscript. For example, A₁,₁ returns the element at 1st row and 1st
to be a feature vector. column.
A matrix is denoted by uppercase, italics, and bold variable name. For
example: A
Addition is just another simple operation that you would want to perform among many others.
We can add matrices of the same shape:
A+B=C
Each cell in matrix A gets added to the corresponding element in matrix B and the sum is stored at the
corresponding position in the resulting matrix C as shown in the figure on the left.
Now, you’d ask what if we have to add 2 matrices of different shape or add a scalar to a matrix, well
NumPy has got us covered for that with broadcasting:
Broadcasting
Broadcasting is a technique that adds a scalar or a different shaped vector to a matrix by extending itself to all the
elements of the matrix. The scalar is added to each and every element of the matrix which is the reason it is called
“broadcasting”.
Let’s say we have 2 matrices of different shapes like in the
image below:
Important Rule: You can only multiply two matrices if the number of columns of the first matrix is equal to the number of
rows of the second matrix.
If the shape of one matrix is (m×n) and the shape of the other one should be (n×t)(t ≥ 1), then the resulting product
matrix would have the shape (m×t) is shown below
Here’s a more comprehensive and notational form of a dot product between a matrix and a vector, Suppose we are
multiplying matrix A (3×2) with a vector B(2×1):
which you’d pass the matrix and the vector. It will return
Here’s a task for you: You can create the matrices(A, B, or C) as per your imagination and then check for each rule by first
calculating the L.H.S. and then evaluate the R.H.S. with it. See, if they hold true.
We will check for transposition rule for dot
product here
then
Now, we can use matrices to describe a system of linear equations which are of the form Ax = b. Consider this system of
linear equations:
The intuition is that if we apply a linear transformation to the space with a matrix A, we can
Now, all we need to do is create these matrices and vectors in code using NumPy and then find out x = A⁻¹b