Vectors
Definition
A vector is a mathematical object that has both magnitude and direction. In machine learning, vectors represent data points in n-dimensional space.
Key Formulas
Vector addition: $\\mathbf{u} + \\mathbf{v} = (u_1 + v_1, u_2 + v_2, ..., u_n + v_n)$
Dot product: $\\mathbf{u} \\cdot \\mathbf{v} = \\sum_{i=1}^{n} u_i v_i$
Magnitude: $\\|\\mathbf{v}\\| = \\sqrt{\\sum_{i=1}^{n} v_i^2}$
Example
Given vectors $\\mathbf{a} = [3, 4]$ and $\\mathbf{b} = [1, 2]$:
- Addition: $\\mathbf{a} + \\mathbf{b} = [4, 6]$
- Dot product: $\\mathbf{a} \\cdot \\mathbf{b} = 3(1) + 4(2) = 11$
- Magnitude of a: $\\|\\mathbf{a}\\| = \\sqrt{9 + 16} = 5$
Interview Questions
Q: Why are vectors important in ML?
A: Vectors allow us to represent data points, features, and weights mathematically. Operations like dot products form the basis of similarity measures, neural network computations, and geometric interpretations of data.