Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the correct model for linear regression.
ML Python
from sklearn.linear_model import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
2fill in blank
mediumComplete the code to fit the linear regression model on features X and target y.
ML Python
model = LinearRegression()
model.[1](X, y) Drag options to blanks, or click blank then click option'
Attempts:
3 left
3fill in blank
hardFix the error in accessing the feature importance from a linear regression model.
ML Python
importance = model.[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
4fill in blank
hardFill both blanks to create a dictionary mapping feature names to their importance values.
ML Python
feature_importance = { [1]: [2] for [1], [2] in zip(feature_names, importance) } Drag options to blanks, or click blank then click option'
Attempts:
3 left
5fill in blank
hardFill all three blanks to print the feature importance sorted by absolute value descending.
ML Python
sorted_features = sorted(feature_importance.items(), key=lambda x: abs(x[1]), reverse=[2]) for feature, importance in sorted_features: print(f"Feature: {feature}, Importance: {importance:.2f}")
Drag options to blanks, or click blank then click option'
Attempts:
3 left