PROFESSIONAL-MACHINE-LEARNING-ENGINEER practice question 23 of 35

You are an ML engineer at a global car manufacturer. You need to build an ML model to predict car sales in different cities around the world. Which features or feature crosses should you use to train city-specific relationships between car type and number of sales?

Full set: 283 questions
Answer options
A: Three individual features binned latitude, binned longitude, and one-hot encoded car type
B: One feature obtained as an element-wise product between latitude, longitude, and car type
C: One feature obtained as an element-wise product between binned latitude, binned longitude, and one-hot encoded car type Correct answer
D: Two feature crosses as a element-wise product the first between binned latitude and one-hot encoded car type, and the second between binned longitude and one-hot encoded car type
Correct Answer:
C. One feature obtained as an element-wise product between binned latitude, binned longitude, and one-hot encoded car type
Explanation

To capture "city-specific relationships," the model needs to learn the interaction between a geographical location and the car type. A feature cross is the ideal technique for this. Location is represented by latitude and longitude, which should be binned (discretized) to represent geographical regions. The car type is a categorical feature that should be one-hot encoded. By creating a single feature cross from all three (binned latitude, binned longitude, and one-hot encoded car type), you create a new feature that is active only for a specific car type within a specific geographical grid. This allows the model to learn a unique predictive weight for that exact combination, directly modeling the required relationship.

Why Incorrect

A: Using individual features does not explicitly model the interaction. The model must learn the complex relationship implicitly, which is less effective and requires more data. B: Crossing raw, continuous latitude and longitude values is mathematically unsound and does not create a meaningful, interpretable feature for specific regions. D: Creating two separate crosses (latitude x cartype and longitude x cartype) fails to capture the crucial three-way interaction that defines a specific grid cell and car type.

References

1. Google Developers, Machine Learning Crash Course, "Feature Crosses": This official Google courseware explains the concept. It states, "Crossing one-hot encoded feature vectors can create a very large feature space." It provides a direct analogy: "Let's suppose we bin latitude and longitude... We can then form a feature cross of these two features... [binnedlatitude X binnedlongitude]... Now suppose we also want to factor the type of home... We could cross this feature with other features. For example, if you cross the location feature with a housetype feature..." This directly supports crossing binned location features with a categorical type feature, as described in option C.

Source: Google Developers. (n.d.). Feature Crosses. Machine Learning Crash Course. Retrieved from https://developers.google.com/machine-learning/crash-course/feature-crosses/encoding-feature-crosses

2. TensorFlow Core Documentation, tf.featurecolumn.crossedcolumn: This official documentation describes the function used to implement feature crosses. The function takes a list of keys, which can be "categoricalcolumnwith... or a BucketizedColumn." This confirms that the correct methodology is to cross bucketized (binned) continuous features like latitude/longitude with categorical features.

Source: TensorFlow Authors. (n.d.). tf.featurecolumn.crossedcolumn. TensorFlow Core v2.15.0. Retrieved from https://www.tensorflow.org/apidocs/python/tf/featurecolumn/crossedcolumn

3. Google Cloud Documentation, "Feature engineering overview": This documentation for Google's Vertex AI platform describes feature crossing as a key technique. It notes, "Crossing two or more features... can provide predictive abilities beyond what the individual features can provide. When you cross features, you are essentially creating a new feature for every combination of values of the contributing features." This validates the principle of combining multiple features (binned latitude, binned longitude, car type) to create a more predictive composite feature.

Source: Google Cloud. (n.d.). Feature engineering overview. Vertex AI Documentation. Retrieved from https://cloud.google.com/vertex-ai/docs/feature-engineering/overview

Scroll to Top