Multi-Feature Regression
Intermediate · Write the code · from Build Your First ML Model: Linear Regression with scikit-learn
From the lesson: Build Your First ML Model: Linear Regression with scikit-learn
Imagine you're a real estate agent. A client asks, "How much is my house worth?" You look at the square footage, the number of bedrooms, and the neighborhood - then you give an estimate. You just did regression in your head.
Read the lessonBuild a regression model with 5 features. Generate data with make_regression(n_samples=200, n_features=5, noise=15, random_state=42). Split 80/20, train a LinearRegression, and print all 5 coefficients rounded to 2 decimal places as a list. Use model.coef_.round(2).tolist().
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from sklearn.datasets import make_regression
# Generate data and build the model
More Linear Regression exercises
- Train Your First ModelIntermediate
- Read the CoefficientsIntermediate
- Fix the Scaling BugIntermediate
- Polynomial vs LinearIntermediate
- Complete Regression PipelineIntermediate
All Python exercises · 50 practice problems · Data Science & Machine Learning quiz