Join Our 5-Week ML/AI Engineer Interview Bootcamp 🚀 led by ML Tech Leads at FAANGs
Compute the dot product between two vectors, a core linear algebra operation used in ML for measuring similarity and building linear models. In this task, you’ll implement it effectively using NumPy.
Implement the function:
Rules:
np.dot, @ operator, or sum(x * y)).Output:
| Argument | Type |
|---|---|
| x | np.ndarray |
| y | np.ndarray |
| Return Name | Type |
|---|---|
| value | float |
Inputs are NumPy arrays; output float
Single function; O(n) time
Use np.dot(x, y) for a direct calculation.
Alternatively, x @ y or np.sum(x * y) achieves the same result.
Ensure the inputs are NumPy arrays for these operators to work efficiently.