By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Feature engineering & selection is the art & science of turning raw data into predictive variables that actually help a model learn. It blends domain knowledge (e.g., “days since last purchase”) with algorithmic tricks (Recursive Feature Elimination, Mutual Information, SHAP) to prune noisy or redundant columns, boost accuracy, and keep models interpretable. Real‑world example: A telecom company wants to predict customer churn. Raw logs contain timestamps, call‑duration, plan codes, and network events. By engineering “average call length per week”, “ratio of prepaid vs postpaid minutes”, and then discarding features that add no information, the churn model becomes both more accurate and explainable to business stakeholders.
tenure_months = (today - signup_date).days/30
python rfe = RFE(estimator=LogisticRegression(), n_features_to_select=10) rfe.fit(X_train, y_train)
price * discount
df = pd.read_csv(...)
df.info()
df.describe()
df['days_since_last_login'] = (today - df['last_login']).dt.days
SimpleImputer(strategy='median')
OneHotEncoder
TargetEncoder
StandardScaler
MinMaxScaler
mutual_info_classif
k=30
LogisticRegression
Mistake: “Engineer every possible interaction and feed them all to the model.” Correction: Start with a small, plausible set; high‑order interactions explode dimensionality and often overfit.
Mistake: “Rely solely on a filter method and ignore multicollinearity.” Correction: After filtering, compute VIF; drop one of any pair with VIF > 10 to keep coefficients stable.
Mistake: “Scale categorical one‑hot columns with StandardScaler.” Correction: Scaling is unnecessary (and can harm) for binary 0/1 columns; only scale continuous numeric features.
Mistake: “Use SHAP values to rank features globally without checking distribution.” Correction: SHAP is local by design; aggregate (e.g., mean absolute SHAP) across many rows before ranking.
Mistake: “Treat missing values as a separate category in one‑hot encoding.” Correction: Impute or flag missingness explicitly; mixing missing with a legitimate category confuses the model.
Q: Your churn model shows high variance after adding dozens of engineered features. What should you try first? A: Apply a filter method (e.g., Mutual Information) to cut down to the most informative features, then re‑run RFE. Reducing dimensionality lowers variance.
Q: You compute SHAP values and see that feature_A has near‑zero contribution for 95 % of rows but huge spikes for a few outliers. What does this indicate? A: feature_A is only important for a minority of cases; consider segmenting the data or using a model that can capture rare‑event patterns rather than discarding it outright.
feature_A
Q: After one‑hot encoding a high‑cardinality column (10 000 categories), training slows dramatically. What alternative encoding can you use? A: Switch to target encoding with smoothing (or hashing trick) to keep the feature space compact.
estimator
coef_
feature_importances_
RFECV
mutual_info_regression
smooth = 1 / (1 + np.exp(-(count - k) / f))
PowerTransformer
RobustScaler
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.