Feature Crosses for City-Specific ML Models

PMLE By islever Editorial Last updated

Short answer

C Use a single feature obtained as an element-wise product between binned latitude, binned longitude, and one-hot encoded car type to capture city-specific interactions.

Question

You are an ML engineer at a global car manufacture. 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?
  1. Thee individual features: binned latitude, binned longitude, and one-hot encoded car type.
  2. One feature obtained as an element-wise product between latitude, longitude, and car type.
  3. One feature obtained as an element-wise product between binned latitude, binned longitude, and one-hot encoded car type. Correct Answer
  4. Two feature crosses as an 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.

Key Takeaways

Geographic variables like latitude and longitude must be crossed together to define a location; separating them fails to capture city-level interactions.

Learn how to build city-specific car sales prediction models using Google Cloud AI APIs by crossing binned geographic coordinates with categorical vehicle types.

Common mistake: Choosing Option D is a common trap. It separates latitude and longitude into different crosses, which prevents the model from understanding that a 'city' is the conjunction of both coordinates rather than two independent factors.

Expert Analysis

The core challenge is modeling city-specific relationships between car type and sales. A city is defined by the intersection of geographic coordinates, meaning latitude and longitude are not independent predictors of location identity; they must be combined to form a unique spatial identifier (a grid cell). If you cross them separately with car type (Option D), the model learns that 'latitude bin + sedan' affects sales and 'longitude bin + sedan' affects sales, but it cannot capture the specific interaction of 'this specific city block + sedan'. Therefore, the features must be crossed together first to create a granular location feature.

Binning is essential here because raw continuous coordinates would lead to sparse data (overfitting) since each coordinate pair might be unique. Bucketizing creates discrete regions. The correct approach is to perform a feature cross on the binned latitude and binned longitude to define the city area, and then incorporate the one-hot encoded car type. Option C describes creating a feature via the element-wise product of these three components, effectively creating a unique identifier for every combination of city-block and car type. This allows the linear model to assign a distinct weight to each specific relationship. As noted in community discussions, separating the dimensions (Option D) prevents the model from learning the true city-level context.

Official Reference

Exam Strategy

When asked about feature crosses for spatial or contextual dependencies, look for options that combine dependent variables (like lat/lon) into a single cross. Do not select options that treat highly correlated or conjunctive features as independent inputs, as this loses the joint information necessary for the target variable.

Frequently Asked Questions

Why can't I just use individual features for latitude, longitude, and car type?

Individual features assume independence. To learn that 'Sedans sell well in New York but poorly in London,' the model needs a feature that represents 'New York + Sedan,' not just 'New York' and 'Sedan' separately.

Why is binning necessary for latitude and longitude?

Raw coordinates are continuous and likely unique per record. Binning groups nearby points into discrete cells, preventing overfitting and allowing the model to generalize patterns across similar geographic areas.

More PMLE FAQ →

Community Votes

C
88%
D
12%

88% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.

Discussion 21 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 21

  1. Paul_Dirac 👍 22
    C https://developers.google.com/machine-learning/crash-course/feature-crosses/check-your-understanding
  2. jk73 👍 13
    Cannot be D, Despite Binning is a good idea because it enables the model to learn nonlinear relationships within a single feature; separate latitude and longitude in different feature crosses is not a good one, this separation will prevent the model from learning city-specific sales. A city is the conjunction of latitude and longitude. In that order of Ideas Crossing binned latitude with binned longitude enables the model to learn city-specific effects of car type. I will go for C, https://developers.google.com/machine-learning/crash-course/feature-crosses/check-your-understanding
  3. ebinv2 👍 8
    C should be the answer
  4. Mohamed_Mossad 👍 6 Answered C
    https://developers.google.com/machine-learning/crash-course/feature-crosses/video-lecture
  5. ralf_cc 👍 4
    D - https://developers.google.com/machine-learning/crash-course/feature-crosses/video-lecture
Show 16 more comments
  1. A4M 👍 4
    C - Answer when doing feature cross the features need to be binned
  2. MK_Ahsan 👍 3 Answered C
    https://developers.google.com/machine-learning/crash-course/feature-crosses/check-your-understanding Answer C: It needs a feature cross to obtain one feature.
  3. NamitSehgal 👍 3
    I got with C
  4. mayankblitzster 👍 2 Answered C
    Captures City-Specific Relationships: Crossing binned latitude and longitude creates a unique identifier for a specific geographic area or "city block". Crossing this with the one-hot encoded car type allows the model to learn sales patterns that are specific to each car type within those defined city areas. Binning Handles Continuous Data: Binning (bucketizing) latitude and longitude converts these continuous values into discrete, categorical features, which are then suitable for feature crosses. Binning also enables the model to learn non-linear relationships within a single feature. Handles Non-Linearities and Interactions: Feature crosses, like this element-wise product, allow linear models to capture non-linear relationships and interactions between features, providing more predictive power than individual features alone
  5. baimus 👍 2
    While i acknowledge the answer is C, It seems wrong to elementwise combine binned lat/lon, as it means there are at least 2 places with the same number in the world, probably more. Not only but by multiplying the binned a values it implies they are ordinal, but they are not ordinal in the same direction, so the relationship on price will be lost (a good example is northern countries tend to be richer, but the east/west relationship isn't defined)
  6. george_ognyanov 👍 2
    Damn that was a good explanation. Thank you for writing it out.
  7. Sum_Sum 👍 2
    C - everything else is madness
  8. mayankblitzster 👍 1 Answered D
    Two feature crosses as an 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. 🔍 Why? This approach allows the model to learn city-specific relationships between car types and sales by: Binning latitude and longitude: Groups nearby locations into discrete regions (e.g., cities or metro areas). One-hot encoding car types: Makes each car type a distinct feature. Crossing location bins with car types: Captures how preferences for car types vary by geographic region. By creating two separate feature crosses (latitude × car type and longitude × car type), the model can learn nuanced patterns without overcomplicating the feature space.
  9. taylz876 👍 1 Answered C
    C- You need relationships that are specific to each city, meaning the effect of car type on sales depends on the city. Binning latitude and longitude turns locations into grid cells (roughly "cities"). Crossing the latitude bin, longitude bin and car type together creates one feature for each combination, like "this grid cell + this car type". The model can then learn a separate sales relationship for every city and car type pair.
  10. ramen_lover 👍 1
    "element-wise product" sounds like we are not using a feature cross but artificially creating a new column whose values is the "element-wise product" of other column values...; i.e., (1, 2, 3) => 1 2 3 = 6. I am not a native English speaker; thus, I might misunderstand the sentence.
  11. b7ad1d9 👍 1 Answered C
    C is the closest here. The REAL answer would be feature cross only Binned Latitude and Binned Longitude to get a feature that represents a city/location/sales area. There is no real need to also add the model in the feature cross. But given the choices C is the best fit.
  12. rigori 👍 1
    creating this cross feature is madness from explainability standpoint
  13. desertlotus1211 👍 1
    Would C be moe complex than D?
  14. desertlotus1211 👍 1
    Why not Answer D?
  15. PhilipKoku 👍 1 Answered C
    C) one feature
  16. M25 👍 1 Answered C
    Went with C

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Practice All PMLE Questions

Access 65 questions with complete answers and detailed explanations.

View Full PMLE Practice Test →

← Back to PMLE Study Guide