0
0
Data Analysis Pythondata~20 mins

Polynomial features in Data Analysis Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Polynomial Features Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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)
A[[1. 2. 3. 4. 6. 9.]]
B[[2. 3. 4. 9. 6.]]
C[[2. 3. 4. 6. 9.]]
D[[2. 3. 5. 6. 9.]]
Attempts:
2 left
💡 Hint
Remember polynomial features include original features and their combinations up to the given degree.
data_output
intermediate
1: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?
A19
B20
C15
D10
Attempts:
2 left
💡 Hint
Use the formula for combinations with repetition: (n + d)! / (d! * n!) where n=features, d=degree.
🔧 Debug
advanced
2: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)
AValueError: Found array with inconsistent numbers of features (2 vs 3)
BTypeError: 'list' object is not callable
CIndexError: list index out of range
DNo error, outputs transformed array
Attempts:
2 left
💡 Hint
Check if all rows have the same number of features.
🚀 Application
advanced
1: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?
ADegree 20
BDegree 1 (linear)
CDegree 10
DDegree 2 or 3
Attempts:
2 left
💡 Hint
Higher degrees can fit noise, lower degrees may miss patterns.
🧠 Conceptual
expert
1:30remaining
Effect of include_bias parameter in PolynomialFeatures
What is the effect of setting include_bias=False in PolynomialFeatures on the transformed data?
AThe output excludes the constant term (all ones column).
BThe output excludes all original features.
CThe output includes only the constant term.
DThe output includes only interaction terms, no powers.
Attempts:
2 left
💡 Hint
Bias means the constant feature of ones.