60-second card
Linear regression
Linear regression fits a straight line: prediction = weight × feature + bias.
- The weight (slope) says how much the prediction changes per unit of the feature.
- The bias (intercept) is the prediction when the feature is 0.
- Training picks the line with the smallest squared errors.
w, b = 5.0, 40.0 # marks = 5 × hours + 40
hours = 6
print(w * hours + b)Prints
70.0Remember: One feature: y = m·x + c. More features: one weight each.
Common mistake: Trusting the line far outside the data you trained on.