nerdexam
Amazon

MLS-C01 · Question #142

A Machine Learning Specialist is developing a regression model to predict rental rates from rental listings. A variable named Wall_Color represents the most prominent exterior wall color of the…

The correct answer is B. Add new columns that store one-hot representation of colors. D. Create three columns to encode the color in RGB format. To enable a regression model to use categorical wall color data, the specialist should convert the nominal string values into a numerical format that does not imply an artificial ordinal relationship.

Modeling

Question

A Machine Learning Specialist is developing a regression model to predict rental rates from rental listings. A variable named Wall_Color represents the most prominent exterior wall color of the property. The following is the sample data, excluding all other variables:

Property_ID Wall_Color 1000 Red 1001 White 1002 Green The specialist chose a model that needs numerical input data. Which feature engineering approaches should the Specialist use to allow the regression model to learn from the Wall_Color data? (Select TWO)

Options

  • AApply integer transformation and set Red = 1, White = 5, and Green = 10.
  • BAdd new columns that store one-hot representation of colors.
  • CReplace the color name string by its length.
  • DCreate three columns to encode the color in RGB format.
  • EReplace each color name by its training set frequency.

How the community answered

(22 responses)
  • A
    9% (2)
  • B
    77% (17)
  • C
    5% (1)
  • E
    9% (2)

Why each option

To enable a regression model to use categorical wall color data, the specialist should convert the nominal string values into a numerical format that does not imply an artificial ordinal relationship.

AApply integer transformation and set Red = 1, White = 5, and Green = 10.

Applying an arbitrary integer transformation assigns a false ordinal relationship to the colors, which can mislead a regression model.

BAdd new columns that store one-hot representation of colors.Correct

One-hot encoding creates a binary column for each unique color, representing each category as a distinct vector without implying any arbitrary order or magnitude.

CReplace the color name string by its length.

Replacing color names with their string lengths discards the actual color information, resulting in meaningless numerical features for predicting rental rates.

DCreate three columns to encode the color in RGB format.Correct

Encoding colors in RGB format converts each color into a numerical tuple (Red, Green, Blue components), providing a quantitative representation of the color's properties that a regression model can interpret.

EReplace each color name by its training set frequency.

Replacing color names with their training set frequencies might introduce bias if certain colors are more frequent and does not capture the inherent characteristics of the color itself.

Concept tested: Categorical feature encoding for regression models

Source: https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.OneHotEncoder.html

Topics

#Feature Engineering#Categorical Data Encoding#Regression Models#Data Preprocessing

Community Discussion

No community discussion yet for this question.

Full MLS-C01 Practice