top of page
Search

Linear Algebra & Data Science Topic 1: Matrix Multiplication

Sep 2
2 min read

Matrix multiplication, though simpler than most processes carried out in linear algebra, is foundational to data science. It allows us to perform calculations with datasets containing multiple variables efficiently.


Imagine a dataset for a group of students. There are four students, each with different heights (in), and weights (lbs). This can be represented by a 4 X 2 matrix, where each column represents a different variable, and each row represents a different student:

Let's call this matrix A.

Now, say you want to predict how far each student can jump in inches. You assign height to be worth 1 point, and weight to be worth 0.7 points. This requires multiplication with the matrix:

Let's call this matrix B.

The variables between these two matrices align––each row of matrix A is multiplied by each column of matrix B, and the resulting products are added together. A general rule emerges: the number of columns in the first matrix must equal the number of rows in the second. Otherwise, the dimensions are incompatible.


Now, for the multiplication. As mentioned above, the second matrix will be applied to the first. This will occur in the form of a dot product.


First, the first column of matrix B ([1; 0.7] is applied to the first row of matrix A ([60; 110]) and the two products are added. That process is repeated for the second, third, and fourth rows. Here is what that looks like:


Which means your final predicted long-jump distances are 137in, 183in, 159in, and 161in based on your students' heights and weights.


As shown above, matrix multiplication is useful for combining variables and scaling them according to any criteria. In data science, this means you can form predictions, transform data, and even power neural networks. One real-life example of matrix multiplication is Spotify recommendations. To create the best playlist for you, Spotify uses a series of matrix multiplications to produce scores on how much you will enjoy a certain song.


Key takeaways from this lesson:

  • Multiplying matrices is the process of combining values from different datasets with dot products

  • To multiple matrices, the number columns in the first must equal the number of rows in the second

  • Matrix multiplication is useful for many predictive algorithms in data science


Practice problems:


 
 

Drop Me a Line, Let Me Know What You Think

© 2035 by Train of Thoughts. Powered and secured by Wix

bottom of page