Description
Today, we will address two topics:
1. Dot product computation
2. Matrix averaging
•
•
•
𝑎 = 𝑎𝑥 𝑎𝑦 𝑎𝑧
𝑏 = 𝑏𝑥 𝑏𝑦 𝑏𝑧
𝑎. 𝑏 cos 𝜃 = 𝑎 𝑏
Let’s solve it in three steps
1. Compute the magnitude 𝑎 and 𝑏 of both vectors 𝑎 = 𝑎𝑥2 + 𝑎𝑦2 + 𝑎𝑧2 In magnitude(a, b)
2. Compute the dot product between the vectors 𝑎. 𝑏 In dot(a, b)
3. Compute the cosine distance (angle 𝜃) with θ = 𝑎𝑐𝑜𝑠 𝑎𝑎.𝑏𝑏 In cos_distance(a, b)
Use acos from the module math!
Task 2: Matrix averaging
1. Numerical stability: Normalizing matrices can prevent numerical errors when performing operations such as inversion, eigenvalue calculation, and matrix decomposition.
2. Comparability: Normalizing matrices can make it easier to compare them.
3. Regularization: Normalizing matrices can help prevent overfitting in machine learning models.
4. Preprocessing: Normalizing matrices is often an important preprocessing step in machine learning to improve performance.