Multiplication of Two Matrices Using Single Line in NumPy:

Matrix multiplication takes two matrices as input and returns a single matrix by performing multiplication operation of rows of first matrix with columns of second matrix. We should see to that the rows of the first matrix are equal to columns of the second matrix. This feature in python is very useful in the field of Data Science.

Now we will see an example where we will multiply two matrices of size 3×3 with each other.

Multiplication of Two Matrices Using NumPy Python for Data Science

Methods of multiplication of two matrices in Python:

  1. Using explicit for loops: It is a simple technique, but it is expansive in case of larger data sets. Nested for loops are there in this for iterating each row and column.Multiplication of Two Matrices Using NumPy Python for Data Science
  2. Using NumPy: Vectorization is another name to multiplication by numpy. Its main motive is to reduce or even remove explicit use of for loops which can make computation much faster.

NumPy package in Python deals with array processing and manipulation. In case of large matrix operations numpy is there as it is 1000 times faster than iterative one method.

The dot product is there in the above example. The dot product is an algebraic operation which takes two equal sized vectors and returns a single number. Computation of result is done by multiplication of corresponding entries and then adding those products.

So, to learn more about matrices in python for data science, you can check this and this as well. Thsee blogs will help you in gettting better insights of what a core data scientist profile demands.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.