Challenge - 5 Problems
Polynomial Features Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of polynomial feature transformation
What is the output of this code that creates polynomial features of degree 2 for a simple dataset?
Data Analysis Python
from sklearn.preprocessing import PolynomialFeatures import numpy as np X = np.array([[2, 3]]) poly = PolynomialFeatures(degree=2, include_bias=False) result = poly.fit_transform(X) print(result)
Attempts:
2 left
💡 Hint
Remember polynomial features include original features and their combinations up to the given degree.
✗ Incorrect
PolynomialFeatures with degree=2 and include_bias=False outputs original features, their squares, and their pairwise products in order: x1, x2, x1^2, x1*x2, x2^2.
❓ data_output
intermediate1:30remaining
Number of features after polynomial expansion
If you have 3 original features and apply PolynomialFeatures with degree=3 and include_bias=True, how many features will the transformed data have?
Attempts:
2 left
💡 Hint
Use the formula for combinations with repetition: (n + d)! / (d! * n!) where n=features, d=degree.
✗ Incorrect
With 3 features and degree 3, total features = C(3+3,3) = C(6,3) = 20 including bias.
🔧 Debug
advanced2:00remaining
Identify the error in polynomial feature usage
What error will this code raise when trying to transform data with PolynomialFeatures?
Data Analysis Python
from sklearn.preprocessing import PolynomialFeatures poly = PolynomialFeatures(degree=2) X = [[1, 2], [3, 4, 5]] poly.fit_transform(X)
Attempts:
2 left
💡 Hint
Check if all rows have the same number of features.
✗ Incorrect
The input list has rows with different lengths, causing ValueError about inconsistent feature numbers.
🚀 Application
advanced1:30remaining
Choosing polynomial degree for regression
You have a dataset with one feature and want to fit a polynomial regression model. Which degree choice is best to avoid overfitting while capturing non-linearity?
Attempts:
2 left
💡 Hint
Higher degrees can fit noise, lower degrees may miss patterns.
✗ Incorrect
Degree 2 or 3 balances capturing curves without too much overfitting common in very high degrees.
🧠 Conceptual
expert1:30remaining
Effect of include_bias parameter in PolynomialFeatures
What is the effect of setting include_bias=False in PolynomialFeatures on the transformed data?
Attempts:
2 left
💡 Hint
Bias means the constant feature of ones.
✗ Incorrect
include_bias=False removes the constant column of ones from the output features.