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 polynomial regression?
Polynomial regression is a type of regression analysis where the relationship between the input variable and the output variable is modeled as an nth degree polynomial. It helps capture curved patterns in data.
Click to reveal answer
beginner
Why do we use a pipeline in polynomial regression?
A pipeline helps combine multiple steps like transforming features into polynomial features and fitting a regression model into one sequence. This makes the process cleaner, easier to manage, and reduces errors.
Click to reveal answer
intermediate
What does the PolynomialFeatures transformer do in a pipeline?
PolynomialFeatures creates new features by raising the original features to different powers up to the specified degree. This allows the model to learn nonlinear relationships.
Click to reveal answer
beginner
How do you evaluate the performance of a polynomial regression model?
You can evaluate it using metrics like Mean Squared Error (MSE) or R-squared (R²). MSE measures average squared errors, while R² shows how well the model explains the data variance.
Click to reveal answer
intermediate
What is the risk of using a very high degree polynomial in regression?
Using a very high degree polynomial can cause overfitting, where the model fits the training data too closely and performs poorly on new data. It captures noise instead of the true pattern.
Click to reveal answer
What is the main purpose of PolynomialFeatures in a regression pipeline?
ATo normalize the data
BTo create new features by raising inputs to powers
CTo reduce the number of features
DTo split data into training and testing sets
✗ Incorrect
PolynomialFeatures generates new features by raising the original features to different powers, enabling the model to learn nonlinear relationships.
Which metric is commonly used to measure the error of a polynomial regression model?
AMean Squared Error (MSE)
BAccuracy
CPrecision
DRecall
✗ Incorrect
Mean Squared Error (MSE) measures the average squared difference between predicted and actual values, making it suitable for regression error measurement.
What happens if you choose a polynomial degree that is too high?
AThe model becomes a linear regression
BThe model will always perform better
CThe model ignores nonlinear patterns
DThe model may overfit the training data
✗ Incorrect
A very high polynomial degree can cause overfitting, where the model fits noise in the training data and performs poorly on new data.
Why is using a pipeline helpful in polynomial regression?
AIt visualizes the data
BIt automatically tunes hyperparameters
CIt combines feature transformation and model fitting steps
DIt splits data into batches
✗ Incorrect
A pipeline combines steps like polynomial feature creation and regression fitting into one process, making the workflow simpler and less error-prone.
Which of these is NOT a step in a polynomial regression pipeline?
AData encryption
BLinear regression fitting
CPolynomial feature transformation
DModel evaluation
✗ Incorrect
Data encryption is unrelated to polynomial regression pipelines, which focus on feature transformation, model fitting, and evaluation.
Explain how a polynomial regression pipeline works from raw data to predictions.
Think about the steps you take to prepare data, train the model, and check results.
You got /5 concepts.
Describe the risks and benefits of increasing the polynomial degree in regression.
Consider what happens when the model becomes too simple or too complex.
You got /4 concepts.
Practice
(1/5)
1.
What is the main purpose of using polynomial regression instead of simple linear regression?
easy
A. To fit curved relationships between variables
B. To reduce the number of features
C. To speed up training time
D. To handle missing data automatically
Solution
Step 1: Understand linear regression limitation
Linear regression fits straight lines, which cannot capture curves in data.
Step 2: Role of polynomial regression
Polynomial regression fits curved lines by adding powers of features, capturing non-linear patterns.
Final Answer:
To fit curved relationships between variables -> Option A
Quick Check:
Polynomial regression = curved fit [OK]
Hint: Polynomial regression fits curves, not just straight lines [OK]
Common Mistakes:
Thinking polynomial regression reduces features
Assuming it speeds up training
Believing it handles missing data automatically
2.
Which of the following is the correct way to create a polynomial regression pipeline in Python using sklearn?
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import LinearRegression
pipeline = Pipeline([
('poly', PolynomialFeatures(degree=2)),
('linear', LinearRegression())
])
easy
A. pipeline = Pipeline([('poly', PolynomialFeatures(degree=2)), ('linear', LinearRegression())])
B. pipeline = Pipeline([('linear', LinearRegression()), ('poly', PolynomialFeatures(degree=2))])
C. pipeline = Pipeline([('poly', LinearRegression()), ('linear', PolynomialFeatures(degree=2))])
D. pipeline = Pipeline([('poly', PolynomialFeatures()), ('linear', LinearRegression(degree=2))])
Solution
Step 1: Order of pipeline steps
PolynomialFeatures must come before LinearRegression to transform data first.
Step 2: Correct usage of classes and parameters
PolynomialFeatures takes degree parameter; LinearRegression does not take degree.
Final Answer:
pipeline = Pipeline([('poly', PolynomialFeatures(degree=2)), ('linear', LinearRegression())]) -> Option A
Quick Check:
PolynomialFeatures before LinearRegression [OK]
Hint: Put PolynomialFeatures before LinearRegression in pipeline [OK]
Common Mistakes:
Swapping order of pipeline steps
Passing degree to LinearRegression
Omitting degree in PolynomialFeatures
3.
Given the following code, what will print(y_pred) output?
import numpy as np
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import LinearRegression
X = np.array([[1], [2], [3]])
y = np.array([1, 4, 9])
pipeline = Pipeline([
('poly', PolynomialFeatures(degree=2)),
('linear', LinearRegression())
])
pipeline.fit(X, y)
y_pred = pipeline.predict(np.array([[4]]))
print(np.round(y_pred, 2))
medium
A. [10.0]
B. [8.0]
C. [4.0]
D. [16.0]
Solution
Step 1: Understand data and model
X = [[1],[2],[3]] with y = [1,4,9] fits y = x^2 perfectly.
Step 2: Predict for X=4 using polynomial degree 2
Model learns y = x^2, so prediction at 4 is 4^2 = 16.