Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the main limitation of simple linear regression?
Simple linear regression can only model straight-line relationships between input and output. It cannot capture curves or complex patterns in data.
Click to reveal answer
beginner
How do polynomial regression models handle non-linearity?
Polynomial regression adds powers of input features (like x², x³) to the model, allowing it to fit curved lines instead of just straight lines.
Click to reveal answer
intermediate
What role do basis functions play in advanced regression?
Basis functions transform input data into new features that can capture complex patterns, helping the regression model fit non-linear relationships.
Click to reveal answer
advanced
Why can kernel methods help regression models handle non-linearity?
Kernel methods implicitly map data into higher-dimensional spaces where linear regression can fit complex, non-linear patterns without explicitly computing new features.
Click to reveal answer
intermediate
How does regularization affect advanced regression models that handle non-linearity?
Regularization helps prevent overfitting when models become complex by adding a penalty for large coefficients, keeping the model simpler and more generalizable.
Click to reveal answer
Which method allows regression to fit curved relationships?
APolynomial regression
BSimple linear regression
CLogistic regression
DK-means clustering
✗ Incorrect
Polynomial regression adds powers of features to model curves, unlike simple linear regression which fits straight lines.
What is the purpose of basis functions in regression?
ATo transform inputs for capturing non-linear patterns
BTo reduce the number of features
CTo normalize the output
DTo split data into clusters
✗ Incorrect
Basis functions create new features that help the model learn complex, non-linear relationships.
Kernel methods help regression models by:
AReducing data size
BConverting regression to classification
CMapping data to higher dimensions implicitly
DRemoving noise from data
✗ Incorrect
Kernel methods allow models to fit non-linear patterns by working in higher-dimensional spaces without explicit feature calculation.
Regularization in advanced regression is used to:
ASplit data into training and testing
BIncrease model complexity
CRemove non-linear features
DPrevent overfitting by penalizing complexity
✗ Incorrect
Regularization adds a penalty to large coefficients, helping keep the model simpler and avoid fitting noise.
Which of these is NOT a way to handle non-linearity in regression?
AUsing polynomial features
BUsing simple linear regression without transformation
CEmploying basis functions
DApplying kernel tricks
✗ Incorrect
Simple linear regression without feature transformation cannot capture non-linear relationships.
Explain why simple linear regression struggles with non-linear data and how advanced regression techniques overcome this.
Think about how adding new features or changing the data space helps the model fit curves.
You got /5 concepts.
Describe the role of basis functions and kernel methods in handling non-linearity in regression models.
Focus on how these techniques transform or represent data differently.
You got /5 concepts.
Practice
(1/5)
1. Why do advanced regression models handle non-linearity better than simple linear regression?
easy
A. Because they only use one feature at a time
B. Because they ignore data points that don't fit a line
C. Because they can model complex curved relationships in data
D. Because they always use fewer data points
Solution
Step 1: Understand simple linear regression limits
Simple linear regression fits a straight line, so it cannot capture curves or bends in data.
Advanced regression models like decision trees or polynomial regression can fit curves and complex patterns.
Final Answer:
Because they can model complex curved relationships in data -> Option C
Quick Check:
Advanced regression models handle curves [OK]
Hint: Advanced regression fits curves, not just straight lines [OK]
Common Mistakes:
Thinking advanced regression ignores data points
Believing advanced regression uses fewer data points
Assuming advanced regression only uses one feature
2. Which of the following is the correct way to create a polynomial regression model in Python using scikit-learn?
easy
A. from sklearn.preprocessing import PolynomialFeatures; poly = PolynomialFeatures(degree=2); X_poly = poly.fit_transform(X)
B. from sklearn.tree import DecisionTreeRegressor; model = DecisionTreeRegressor(); model.fit(X, y)
C. from sklearn.cluster import KMeans; model = KMeans(); model.fit(X)
D. from sklearn.linear_model import LinearRegression; model = LinearRegression(); model.fit(X_poly, y)
Solution
Step 1: Identify polynomial feature creation
Polynomial regression requires transforming features using PolynomialFeatures to add powers of features.
Step 2: Recognize correct syntax for polynomial transformation
from sklearn.preprocessing import PolynomialFeatures; poly = PolynomialFeatures(degree=2); X_poly = poly.fit_transform(X) correctly imports PolynomialFeatures and transforms X to X_poly for regression.
Final Answer:
from sklearn.preprocessing import PolynomialFeatures; poly = PolynomialFeatures(degree=2); X_poly = poly.fit_transform(X) -> Option A
Quick Check:
PolynomialFeatures creates polynomial features [OK]
Hint: Polynomial regression needs PolynomialFeatures to transform data [OK]
Common Mistakes:
Confusing decision tree with polynomial regression
Using clustering models for regression tasks
Not transforming features before fitting polynomial regression
3. Given the code below, what will be the output of print(predictions)?
from sklearn.tree import DecisionTreeRegressor
X = [[1], [2], [3], [4], [5]]
y = [1, 4, 9, 16, 25]
model = DecisionTreeRegressor()
model.fit(X, y)
predictions = model.predict([[6]])
print(predictions)
medium
A. [16]
B. [36]
C. [9]
D. [25]
Solution
Step 1: Understand decision tree prediction behavior
Decision trees predict by assigning the output of the closest training leaf node, not extrapolating beyond training data.
Step 2: Check training data and prediction input
Input 6 is beyond training max 5, so prediction will be the leaf value for closest known input, which is 5 with output 25.
Final Answer:
[25] -> Option D
Quick Check:
Decision tree predicts closest leaf value = 25 [OK]
Hint: Decision trees do not extrapolate; predict closest known value [OK]
Common Mistakes:
Assuming decision tree extrapolates like polynomial regression
Expecting exact square of 6 (36) as output
Confusing prediction with training labels
4. The following code tries to fit a polynomial regression but gives an error. What is the mistake?
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import PolynomialFeatures
X = [[1], [2], [3], [4]]
y = [1, 4, 9, 16]
model = LinearRegression()
X_poly = PolynomialFeatures(degree=2)
model.fit(X_poly, y)
medium
A. LinearRegression cannot fit polynomial data
B. X_poly is a class, not transformed data; need to call fit_transform on X
C. y should be a 2D array, not 1D
D. Degree should be 1 for polynomial features
Solution
Step 1: Identify how PolynomialFeatures is used
PolynomialFeatures is a transformer class; it needs to be applied to X using fit_transform to create polynomial features.
Step 2: Spot the error in code
Code assigns X_poly to the class instance, not the transformed data. The model.fit expects numeric array, not a class object.
Final Answer:
X_poly is a class, not transformed data; need to call fit_transform on X -> Option B
Quick Check:
Call fit_transform on X before fitting model [OK]
Hint: Call fit_transform on X before fitting model [OK]
Common Mistakes:
Passing transformer class instead of transformed data
Thinking LinearRegression can't fit polynomial features
Misunderstanding y shape requirements
5. You have a dataset where the target variable changes in a complex curve with two features. Which approach best handles this non-linearity and why?
hard
A. Polynomial regression of degree 3 can model complex curves with multiple features
B. Simple linear regression will miss the curve
C. Decision tree with max depth 2 is too shallow to capture complexity
D. Dropping features reduces information and won't help non-linearity
Solution
Step 1: Analyze model capabilities for non-linearity
Simple linear regression cannot model curves; decision tree with low depth may underfit; dropping features loses info.
Step 2: Evaluate polynomial regression for multiple features
Polynomial regression with degree 3 creates interaction and power terms, capturing complex curves in multiple features.
Final Answer:
Polynomial regression of degree 3 can model complex curves with multiple features -> Option A