0
0
ML Pythonml~20 mins

Polynomial features in ML Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Polynomial Features Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding Polynomial Feature Expansion
Which of the following best describes what polynomial features do to the original input data in machine learning?
AThey normalize the features to have zero mean and unit variance.
BThey create new features by multiplying existing features up to a specified degree, allowing models to learn nonlinear relationships.
CThey reduce the number of features by selecting only the most important ones.
DThey convert categorical features into numerical codes.
Attempts:
2 left
💡 Hint
Think about how polynomial features help linear models capture curves.
Predict Output
intermediate
2:00remaining
Output of Polynomial Feature Transformation
What is the output of the following Python code using sklearn's PolynomialFeatures with degree=2 on input [[2, 3]]?
ML Python
from sklearn.preprocessing import PolynomialFeatures
import numpy as np
poly = PolynomialFeatures(degree=2, include_bias=False)
X = np.array([[2, 3]])
X_poly = poly.fit_transform(X)
print(X_poly)
A[[2. 3. 5. 6. 9.]]
B[[1. 2. 3. 4. 6. 9.]]
C[[2. 3. 4. 6. 9.]]
D[[2. 3. 4. 5. 6.]]
Attempts:
2 left
💡 Hint
Remember include_bias=False means no constant 1 column.
Model Choice
advanced
2:00remaining
Choosing a Model for Polynomial Features
You have expanded your dataset with polynomial features of degree 3. Which model below is most suitable to avoid overfitting and handle the increased feature space?
ARidge Regression (linear regression with L2 regularization)
BLinear Regression without regularization
CDecision Tree with no depth limit
DK-Nearest Neighbors with k=1
Attempts:
2 left
💡 Hint
Think about how to control complexity when features increase.
Hyperparameter
advanced
1:30remaining
Effect of Degree Parameter in Polynomial Features
What is the main effect of increasing the degree parameter in PolynomialFeatures on the dataset?
AIt increases the number of features exponentially, which can lead to overfitting.
BIt decreases the number of features, simplifying the model.
CIt normalizes the features to a smaller range.
DIt converts continuous features into categorical bins.
Attempts:
2 left
💡 Hint
Think about how many new features are created as degree grows.
Metrics
expert
2:30remaining
Evaluating Model Performance with Polynomial Features
You trained a polynomial regression model with degree 4 and got training R² = 0.95 but test R² = 0.60. What does this indicate and which metric would best help diagnose the problem?
AThe model underfits; use Mean Absolute Error (MAE) to check errors.
BThe model is underfitting; use confusion matrix to analyze.
CThe model is perfect; use accuracy score to confirm.
DThe model overfits; use cross-validation score to assess generalization.
Attempts:
2 left
💡 Hint
High train score but low test score usually means overfitting.