0
0
ML Pythonprogramming~20 mins

First ML prediction (linear regression) in ML Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Linear Regression Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
Output of simple linear regression prediction
What is the predicted value of y for x = 4 using the model y = 2x + 1?
ML Python
def predict(x):
    return 2 * x + 1

result = predict(4)
print(result)
A8
B7
C9
D10
Attempts:
2 left
Model Choice
intermediate
1:30remaining
Choosing the right model for linear data
You have data points that form a straight line. Which model is best to predict new points?
ANeural network with many layers
BDecision tree
CK-means clustering
DLinear regression
Attempts:
2 left
Metrics
advanced
2:00remaining
Interpreting mean squared error (MSE)
If a linear regression model has an MSE of 0.01 on test data, what does this mean?
AThe average squared difference between predicted and actual values is 0.01
BThe model predicts perfectly with no errors
CThe model's predictions are off by 1 on average
DThe model's accuracy is 1%
Attempts:
2 left
🔧 Debug
advanced
2:00remaining
Why does this linear regression code fail?
What error will this code produce? from sklearn.linear_model import LinearRegression model = LinearRegression() X = [1, 2, 3, 4] y = [2, 4, 6, 8] model.fit(X, y)
ML Python
from sklearn.linear_model import LinearRegression
model = LinearRegression()
X = [1, 2, 3, 4]
y = [2, 4, 6, 8]
model.fit(X, y)
ANo error, code runs fine
BValueError because X must be 2D array
CTypeError because y is not a numpy array
DNameError because LinearRegression is not imported
Attempts:
2 left
🧠 Conceptual
expert
2:00remaining
Effect of learning rate in linear regression training
What happens if the learning rate in gradient descent for linear regression is set too high?
AThe model may fail to converge and loss can increase or oscillate
BThe model will converge faster without any issues
CThe model will ignore the learning rate and converge normally
DThe model will always find the global minimum immediately
Attempts:
2 left