Challenge - 5 Problems
Linear Regression Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of Linear Regression Model Training
What is the printed output of the following code snippet after training a linear regression model?
ML Python
from sklearn.linear_model import LinearRegression import numpy as np X = np.array([[1], [2], [3], [4], [5]]) y = np.array([2, 4, 6, 8, 10]) model = LinearRegression() model.fit(X, y) print(round(model.coef_[0], 2), round(model.intercept_, 2))
Attempts:
2 left
💡 Hint
Think about the relationship between X and y in the data.
✗ Incorrect
The target y is exactly twice the input X, so the slope (coefficient) is 2.0 and the intercept is 0.0.
❓ Model Choice
intermediateChoosing the Correct Model for Linear Regression
Which scikit-learn class should you use to perform a simple linear regression on a dataset?
Attempts:
2 left
💡 Hint
Linear regression predicts continuous values, not categories.
✗ Incorrect
LinearRegression is the correct class for fitting a linear model to predict continuous targets.
❓ Hyperparameter
advancedEffect of fit_intercept Parameter in LinearRegression
What is the effect of setting fit_intercept=False when creating a LinearRegression model in scikit-learn?
Attempts:
2 left
💡 Hint
Consider what happens if the intercept is not included in a line equation.
✗ Incorrect
Setting fit_intercept=False forces the regression line to pass through the origin (0,0), so no intercept is learned.
❓ Metrics
advancedInterpreting R² Score for Linear Regression
After training a linear regression model, you calculate the R² score on test data and get 0.85. What does this value mean?
Attempts:
2 left
💡 Hint
R² measures how well the model fits the data, not classification accuracy.
✗ Incorrect
R² score indicates the proportion of variance in the target explained by the model; 0.85 means 85%.
🔧 Debug
expertDebugging Unexpected Model Coefficients
You train a LinearRegression model on a dataset but get very large coefficient values that don't make sense. Which of the following is the most likely cause?
Attempts:
2 left
💡 Hint
Think about how feature scale affects linear regression coefficients.
✗ Incorrect
When features have very different scales, coefficients can become large and unstable; scaling helps prevent this.
