0
0
ML Pythonml~10 mins

Why advanced regression handles non-linearity in ML Python - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a polynomial feature transformer.

ML Python
from sklearn.preprocessing import [1]
poly = PolynomialFeatures(degree=2)
Drag options to blanks, or click blank then click option'
APolynomialFeatures
BStandardScaler
CMinMaxScaler
DOneHotEncoder
Attempts:
3 left
💡 Hint
Common Mistakes
Using scalers or encoders instead of polynomial feature transformer.
2fill in blank
medium

Complete the code to fit a linear regression model on polynomial features.

ML Python
from sklearn.linear_model import LinearRegression
model = LinearRegression()
X_poly = poly.fit_transform(X)
model.[1](X_poly, y)
Drag options to blanks, or click blank then click option'
Afit
Btransform
Cscore
Dpredict
Attempts:
3 left
💡 Hint
Common Mistakes
Using predict instead of fit to train the model.
3fill in blank
hard

Fix the error in the code to predict using the polynomial regression model.

ML Python
X_new_poly = poly.transform(X_new)
predictions = model.[1](X_new_poly)
Drag options to blanks, or click blank then click option'
Atransform
Bpredict
Cfit
Dscore
Attempts:
3 left
💡 Hint
Common Mistakes
Using fit or transform instead of predict for predictions.
4fill in blank
hard

Fill both blanks to create a dictionary of feature names and their coefficients from the model.

ML Python
feature_names = poly.get_feature_names_out(input_features)
coef_dict = [1](zip(feature_names, model.[2]_))
Drag options to blanks, or click blank then click option'
Adict
Bcoef
Ccoef_
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using coef without underscore or wrong function to create dictionary.
5fill in blank
hard

Fill both blanks to compute the mean squared error of the polynomial regression model predictions.

ML Python
from sklearn.metrics import [1]
y_pred = model.predict(X_poly)
mse = [2](y, y_pred)
print('Mean Squared Error:', mse)
Drag options to blanks, or click blank then click option'
Amean_squared_error
Baccuracy_score
Cr2_score
Dconfusion_matrix
Attempts:
3 left
💡 Hint
Common Mistakes
Using classification metrics like accuracy or confusion matrix for regression.