3.2 Feature selection and transformation
Column transformers, scaling and encoding, feature importance and SHAP.
Key points
A transformer changes features, for example by scaling or encoding. ColumnTransformer runs a chosen transformer on each column group and concatenates the outputs. PCA means principal component analysis.
What NVIDIA says (1)
“This estimator allows different columns or column subsets of the input to be transformed separately and the features generated by each transformer will be concatenated to form a single feature space.”
Feature transformation reshapes inputs so a model can use them. Normalizing fixes scale differences; extracting the hour exposes a daily pattern.
What NVIDIA says (2)
“Next, numeric features must be normalized to prevent the model from being biased by the variable scales.”
“Then transform the ‘date’ column into an ‘hour’ feature, as weather patterns often correlate with the time of day.”
Feature selection keeps the inputs that help and drops the rest. Impurity-based importances from a forest are a common first guide.
What NVIDIA says (1)
“feature_importances_ ndarray of shape (n_features,) The impurity-based feature importances.”
SHAP values assign each feature a share of a prediction. They help select features and explain models. SHAP means SHapley Additive exPlanations.
What NVIDIA says (1)
“cuML’s SHAP based explainers accelerate the algorithmic part of SHAP.”
Key terms
- Feature: An input column a model learns from.
- Feature engineering: Creating or reshaping input columns so a model can learn better.
- Standard scaling: Rescaling a numeric feature to mean 0 and standard deviation 1.
- Feature importance: A score for how much each feature contributes to a model.
- SHAP: A method that explains a single prediction by how much each feature pushed it.
Try it
Sample question
Your table has numeric columns that need scaling and categorical columns that need one-hot encoding. Which cuML tool applies different transformers to different columns and joins the results?
Show the answer
Answer: ColumnTransformer
A transformer changes features, for example by scaling or encoding. ColumnTransformer runs a chosen transformer on each column group and concatenates the outputs. PCA means principal component analysis.
What NVIDIA says (1)
“This estimator allows different columns or column subsets of the input to be transformed separately and the features generated by each transformer will be concatenated to form a single feature space.”
Practice 3.2 (4 questions) Full Data Science Pipelines and Workflow Automation guide
← 3.1 Designing an end-to-end pipeline · 3.3 Fixing underfitting and overfitting →