Model Soccer Shot Conversion
GoogleData Scientist · Technical ScreenLast updated
This problem tests the ability to design an end-to-end predictive model for sports events, focusing on feature engineering, handling spatial data sparsity, and evaluating probabilistic outputs.
Scenario
You are a Data Scientist at a sports analytics firm. You have been tasked with building an 'Expected Goals' (xG) model for soccer. An xG model calculates the probability that a specific shot will result in a goal based on the circumstances under which the shot was taken.
The Dataset
You are provided with a dataset of 500,000 recorded shots from professional leagues. Each record includes:
shot_coordinates: (x, y) coordinates on a 105x68 meter field.angle_to_goal: The shooting angle relative to the center of the goal.distance_to_goal: Euclidean distance from the center of the goal.defender_proximity: Distance to the nearest defender.is_header: Boolean flag.goal_scored: Binary outcome (Target).game_minute: Time in the game.
Your Task
- Propose a modeling strategy to estimate the probability
P(goal=1 | features). Explain how you would transform the rawshot_coordinatesinto meaningful features that account for the non-linear relationship between location and scoring probability. - How would you address the 'sparsity' problem, where shots taken from extreme angles or very far distances have very few historical examples?
- Define a proper loss function for this model. Why is Accuracy or Mean Squared Error (MSE) potentially insufficient for this specific use case?
- How would you calibrate the model to ensure that if the model predicts a 0.20 probability of a goal across 1,000 shots, approximately 200 goals are actually scored?
Hints
Hint 1
Consider creating features like the log-distance or interaction terms between angle and distance to better capture the 'danger' zones on the pitch.
Hint 2
For calibration, look into isotonic regression or Platt scaling to map raw model scores to true probabilities.
Hint 3
Brier Score or Log-Loss are preferred here as they reward confidence and penalize divergence from the actual probability distribution of outcomes.
Follow-up questions
- How would you handle 'data leakage' if you accidentally included the 'goalkeeper_save' variable in your training set?
- If the team wants to use this model to evaluate player performance, how do you distinguish between 'luck' (a player scoring a low-xG shot) and 'skill'?
- How would you adjust the model if the team wants to account for the 'game state' (e.g., if a team is losing, they might take more low-probability shots out of desperation)?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.