Please type answer Please DONOT hand write. Applied Machine Learning by: AML stu
ID: 3726614 • Letter: P
Question
Please type answer Please DONOT hand write.
Applied Machine Learning by: AML student In this assignment you will be getting familiar with Python and practicing some of the concepts discussed in class. Make sure to upload both the .html and.ipynb files to Canvas. Problem 1 Consider the following two matrices 1 -3 A=10 4 and -1 2 31 2 .Use Python to compute the matrix product AB .Can you compute BA in this case? Hint: import the numpy library, define the matrices as shown in class, and use the numpy.dot function. Documentation can be found here Solutions to Problem 1 Include comments to your solution hereExplanation / Answer
#Code start
import numpy as np #This will import numpy library as np
a = np.array([[ 1 , -3 ], [ 0 , 4 ], [ 2 , 1 ]]) # we have taken the first matrix A
b= b = np.array([[ 1, 1, -1, 2], [ 2 , 3 , 1 , -2 ]]) # we have taken the second matrix B
print (a.dot(b)) # we have calculated the matrix multiplication using dot
#End Of code
No the Reverse, that is BA , is not possible as Matrix A is of order 3x2 and Matrix B is of order 2x4
So AB is possible
as "if A is an m x n matrix and B is an r x s matrix, n = r"
so this condition is satisfied for AB but not satisfied for BA hence BA is not possible.