Challenge - 5 Problems
Linear Regression Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediateUnderstanding the purpose of linear regression
What is the main goal of linear regression in machine learning?
Attempts:
2 left
💡 Hint
Think about what linear regression predicts: numbers or categories?
✗ Incorrect
Linear regression fits a straight line to data to predict continuous values, unlike classification or clustering.
❓ Predict Output
intermediateOutput of simple linear regression prediction
What is the predicted value y when x=3 using the model y = 2x + 1?
ML Python
def predict(x): return 2 * x + 1 result = predict(3) print(result)
Attempts:
2 left
💡 Hint
Plug x=3 into the formula y=2x+1.
✗ Incorrect
For x=3, y=2*3+1=7.
❓ Hyperparameter
advancedEffect of learning rate in linear regression training
What happens if the learning rate is set too high during linear regression training with gradient descent?
Attempts:
2 left
💡 Hint
Think about how big steps affect finding the lowest point in a valley.
✗ Incorrect
A too high learning rate causes the training to jump over the minimum loss repeatedly, preventing convergence.
❓ Metrics
advancedChoosing the right metric for linear regression
Which metric is commonly used to measure the error of a linear regression model's predictions?
Attempts:
2 left
💡 Hint
This metric calculates the average squared difference between predicted and actual values.
✗ Incorrect
MSE measures how close predictions are to actual values by averaging squared errors, suitable for regression.
🔧 Debug
expertIdentifying the error in linear regression code
What error will this code raise when fitting a linear regression model using scikit-learn?
from sklearn.linear_model import LinearRegression
X = [[1], [2], [3]]
y = [2, 4, 6]
model = LinearRegression()
model.fit(X, y)
print(model.predict([4]))
Attempts:
2 left
💡 Hint
Check the shape of the input passed to predict method.
✗ Incorrect
scikit-learn expects a 2D array for inputs; [4] is 1D, causing ValueError.
