Member-only story
Math Refresher for Data Scientists
Matrix in Data Science interviews
Essential math for Data Scientists explained from scratch
Matrices are commonly used in many areas, such as physics, graphics, risk modeling, and statistics. Getting familiar with matrices and their transformations is relatively easy but crucial to understanding data science concepts, including linear regression. So let’s dive into it!
The article is divided into two parts:
I. Math Refresher
II. Related questions from data science interviews
I. Math Refresher
1. Matrix notation
The simple definition of a matrix is a rectangular array of numbers. It is arranged in rows and columns, e.g.:
A is 2 x 3 matrix (mxn matrix, m = 2 rows and n = 3 columns). Bold upper-case letters, such as A or B are used to denote matrices. As shown above, square brackets [ ] or parenthesis ( ) are used to define matrix and there is no difference between those two.
If m = n, the matrix is called square matrix, e.g.:
The individual element is denoted as aᵢ,ⱼ where i refers to the number of row and j to the column number:
2. Matrix transpose
Matrix transpose (A’ or Aᵀ) simply interchanges the columns and rows, so for matrix A above:
If a matrix is square and B = B’:
Then matrix B is a symmetric matrix.
3. Dot product
To calculate the dot product of two non-zero vectors (one column of matrix) having the same dimension, we sum the element-by-element products:
4. Addition and subtraction
The first thing to notice is that the dimensions of matrices we want to add or subtract must be the same. If this condition is true, then we add the values at the same position of both matrices:
The same procedure is applied for substracting.