Topics / 🤖 AI & Machine Learning / 🧮 Level 20: NumPy & Maths for ML

Python exercise · about 5 minutes · free

Dot Products: Weighted Scores

A linear model is just features times weights, added up. That is a dot product.

X @ w multiplies each row of X by the weights w and sums: one score per row. This is exactly what linear and logistic regression compute inside.

Table. X (score, emi_ratio, salaried): score, emi, sal; 700 | 0.3 | 1; 650 | 0.5 | 0; 800 | 0.2 | 1. Operation: @ w = [0.01, -5, 1]. Result scores: result; 6.5; 4; 8. 700×0.01 + 0.3×(−5) + 1×1 = 6.5X (score, emi_ratio, salaried)scoreemisal7000.316500.508000.21scoresresult6.548@ w = [0.01, -5, 1]700×0.01 + 0.3×(−5) + 1×1 = 6.5
Your quest: Set scores to X @ w (one score per applicant).
Try it now Runs in your browser. No sign-in needed. Ctrl+Enter to run.
Hintscores = X @ w
Output appears here.

Open it in the full course → Free with Google: saves your progress and unlocks 627 lessons.

In this level you'll learn:
More in Level 20: NumPy & Maths for ML

Share on LinkedIn