0
0
ML Pythonprogramming~20 mins

Linear regression with scikit-learn in ML Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Linear Regression Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output 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))
A1.0 0.0
B1.0 1.0
C2.0 1.0
D2.0 0.0
Attempts:
2 left
Model Choice
intermediate
1:30remaining
Choosing the Correct Model for Linear Regression
Which scikit-learn class should you use to perform a simple linear regression on a dataset?
Asklearn.cluster.KMeans
Bsklearn.tree.DecisionTreeClassifier
Csklearn.linear_model.LinearRegression
Dsklearn.neural_network.MLPClassifier
Attempts:
2 left
Hyperparameter
advanced
2:00remaining
Effect of fit_intercept Parameter in LinearRegression
What is the effect of setting fit_intercept=False when creating a LinearRegression model in scikit-learn?
AThe model will not calculate an intercept term and will force the line through the origin.
BThe model will use L1 regularization to reduce overfitting.
CThe model will automatically normalize the input features before fitting.
DThe model will fit a polynomial regression instead of linear.
Attempts:
2 left
Metrics
advanced
1:30remaining
Interpreting 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?
AThe model explains 85% of the variance in the target variable on the test data.
BThe model has 85% accuracy in classifying the test samples.
CThe model's predictions are 85% similar to the training data.
DThe model has an 85% chance of making a correct prediction.
Attempts:
2 left
🔧 Debug
expert
2:30remaining
Debugging 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?
AThe target variable contains categorical data instead of numeric values.
BThe input features were not scaled or normalized, causing instability in coefficient values.
CThe LinearRegression class does not support multiple features.
DThe model was trained with fit_intercept=True, which always causes large coefficients.
Attempts:
2 left