Multiple Features
Goal
By the end of this lesson, you can fit a regression model with multiple features, read the feature-matrix shape, and interpret a coefficient as one part of a fitted prediction rule rather than automatic causation.
One prediction can use several pieces of information
A house price may depend on floor area, number of rooms, age, location, and other information.
With one numeric feature, a linear model can look like:
prediction = weight × feature + intercept
With three features, the same idea becomes:
prediction = w1*x1 + w2*x2 + w3*x3 + intercept
Each feature value contributes through a learned coefficient, and the contributions are added together.
Read the matrix before reading the coefficients
Suppose X has shape (8, 3).
That means:
- 8 rows = 8 examples;
- 3 columns = 3 features per example.
A linear regression model fitted to those three columns learns three feature coefficients plus an intercept.
This gives you an immediate debugging check: if you expected three features but the model receives shape (8, 2), something is missing before you even inspect predictions.
Coefficients are conditional model contributions
Imagine this toy fitted rule:
prediction = 2*size - 1*age + 10
If size stays fixed and age increases by 1, the model output falls by 1 according to this rule.
That does not prove that making a real house one year older causes its price to fall by exactly one unit. A coefficient describes the fitted model while the other included features are held fixed.
Interpretation becomes especially tricky when features are correlated or measured in very different units.
A coefficient of 500 on a feature measured in kilometers is not automatically “more important” than a coefficient of 0.8 on a feature measured in meters. The units change the numerical size of the weight.
Trace one feature change in the Lab
The Lab fits a model using size_m2, rooms, and age_years. The new example starts as:
new_example = np.array([[90.0, 3.0, 10.0]])
- Click Run and inspect
X shape:,coefficients:, andprediction:. - In the printed coefficient dictionary, find the coefficient for
size_m2and note its sign. - In
new_example, change only the first value from90.0to100.0. Keeprooms = 3.0andage_years = 10.0fixed. - Before running, use the sign of the
size_m2coefficient to predict whether the output should move up or down. - Click Run and compare
prediction:with the first run. - Restore
new_exampleto[[90.0, 3.0, 10.0]].
Loading lab…
After this guided pass, choose either rooms or age_years, change only that one value, and predict the direction from its coefficient before running.
This controlled change lets you connect a coefficient to actual model behavior without pretending that the coefficient proves a real-world causal relationship.
More features are not automatically better
Adding a feature can help when it contains useful information that the existing features lack.
But extra columns can also:
- add noise;
- duplicate information already present;
- increase variance;
- make interpretation harder;
- introduce leakage if their timing is wrong.
The question is not “How many features can I add?” It is “Which information is valid, available, and useful for the prediction task?”
Quick Check
Key Takeaways
- Multiple-feature models use a matrix of examples by features.
- Linear regression learns one coefficient per feature plus an intercept.
- Feature order and units matter when interpreting weights.
- Coefficients describe the fitted prediction rule, not automatic causation.
- Extra features should earn their place through valid, fair evidence.
Next Lesson
You have reached the Level 1 mini checkpoint. After it, the level switches from predicting numbers to predicting categories.
References
- scikit-learn, Linear Models.
Completion is stored locally on this device.