0
0
ML Pythonml~20 mins

Feature selection methods in ML Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Feature Selection Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Which feature selection method uses model coefficients to select important features?

Imagine you have a dataset with many features. You want to pick the most important ones by looking at the model's learned weights. Which feature selection method does this?

AFilter method using correlation coefficients
BWrapper method using recursive feature elimination
CDimensionality reduction using PCA
DEmbedded method using Lasso regression coefficients
Attempts:
2 left
💡 Hint

Think about methods that select features during model training by shrinking some coefficients to zero.

Predict Output
intermediate
2:00remaining
What is the number of features selected by this code snippet?

Consider the following Python code using sklearn to select features based on univariate statistical tests.

ML Python
from sklearn.datasets import load_iris
from sklearn.feature_selection import SelectKBest, f_classif

X, y = load_iris(return_X_y=True)
selector = SelectKBest(score_func=f_classif, k=2)
X_new = selector.fit_transform(X, y)
num_features = X_new.shape[1]
A3
B4
C2
D1
Attempts:
2 left
💡 Hint

Look at the parameter k in SelectKBest.

Model Choice
advanced
2:00remaining
Which model is best suited for embedded feature selection in high-dimensional sparse data?

You have a dataset with thousands of features but only a few samples. You want a model that can select important features while training. Which model is best?

ALasso Regression
BRandom Forest Classifier
CK-Nearest Neighbors
DSupport Vector Machine with RBF kernel
Attempts:
2 left
💡 Hint

Think about models that add penalties to reduce coefficients to zero.

Hyperparameter
advanced
2:00remaining
What effect does increasing the 'k' parameter in SelectKBest have?

In the SelectKBest feature selection method, what happens if you increase the value of k?

AMore features are selected, possibly including less relevant ones
BFewer features are selected, focusing only on the top ones
CThe model automatically tunes <code>k</code> during training
DThe method switches from filter to wrapper approach
Attempts:
2 left
💡 Hint

Think about what k controls in feature selection.

Metrics
expert
2:00remaining
Which metric best evaluates feature selection effectiveness in classification?

You want to measure how well your feature selection improved your classification model. Which metric is most appropriate to compare before and after feature selection?

AMean squared error on training data
BModel accuracy on a validation set
CNumber of features selected
DTraining time of the model
Attempts:
2 left
💡 Hint

Think about what shows if the model predicts better with selected features.