3.2 Feature selection and transformation

NCA-ADS · Data Science Pipelines and Workflow Automation (13% of the exam) · Official objective: “Feature engineering, selection, and transformation for model improvement”

Column transformers, scaling and encoding, feature importance and SHAP.

Key points

  1. 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.”

    — cuML API: ColumnTransformer

  2. 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.”

    — Accelerated Data Analytics: Machine Learning with GPU-Accelerated pandas and scikit-learn

    “Then transform the ‘date’ column into an ‘hour’ feature, as weather patterns often correlate with the time of day.”

    — Accelerated Data Analytics: Machine Learning with GPU-Accelerated pandas and scikit-learn

  3. 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.”

    — cuML API: RandomForestClassifier

  4. 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.”

    — cuML API: KernelExplainer

Key terms

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.”

— cuML API: ColumnTransformer

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 →