Challenge - 5 Problems
Polynomial Regression Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of polynomial regression prediction
Given the following code that fits a polynomial regression model and predicts a value, what is the output?
ML Python
from sklearn.preprocessing import PolynomialFeatures from sklearn.linear_model import LinearRegression import numpy as np X = np.array([[1], [2], [3], [4], [5]]) y = np.array([1, 4, 9, 16, 25]) # y = x^2 poly = PolynomialFeatures(degree=2) X_poly = poly.fit_transform(X) model = LinearRegression() model.fit(X_poly, y) pred = model.predict(poly.transform([[6]])) print(round(pred[0], 2))
Attempts:
2 left
💡 Hint
Remember that the model fits y = x^2, so predicting for x=6 should be close to 36.
✗ Incorrect
The model fits a polynomial of degree 2 to the data y = x^2. Predicting for x=6 gives approximately 36.
❓ Model Choice
intermediate1:30remaining
Best model choice for polynomial regression pipeline
You want to build a pipeline that fits a polynomial regression model to data. Which of the following pipeline components is the correct choice to transform the input features before fitting a linear regression?
Attempts:
2 left
💡 Hint
Polynomial regression requires creating polynomial features before fitting a linear model.
✗ Incorrect
PolynomialFeatures generates polynomial terms needed for polynomial regression. The other options do not create polynomial features.
❓ Hyperparameter
advanced1:30remaining
Choosing the polynomial degree hyperparameter
In a polynomial regression pipeline, which effect does increasing the degree hyperparameter have on the model?
Attempts:
2 left
💡 Hint
Higher degree polynomials can fit data more closely but risk fitting noise.
✗ Incorrect
Increasing degree adds more polynomial terms, making the model more flexible and prone to overfitting.
❓ Metrics
advanced1:30remaining
Evaluating polynomial regression with R² score
After fitting a polynomial regression model, you compute the R² score on test data and get 0.95. What does this value indicate?
Attempts:
2 left
💡 Hint
R² score measures how well the model explains variance in continuous data.
✗ Incorrect
R² of 0.95 means the model explains 95% of the variance in the target variable on test data.
🔧 Debug
expert2:30remaining
Debugging pipeline with incorrect feature transformation
You build a pipeline with PolynomialFeatures(degree=3) and LinearRegression. After training, predictions are constant and do not change with input. What is the most likely cause?
Attempts:
2 left
💡 Hint
PolynomialFeatures expects 2D input; wrong shape can cause incorrect transformations.
✗ Incorrect
If input is 1D array, PolynomialFeatures treats it incorrectly, leading to constant predictions.