S02 · code review simulation
Review a nightly no-show scoring script before it ships
People, data and outputs in this scenario are simulated. Each stage is recorded when you commit; the reveal comes after.
- 4stages
- 35 minabout
- 0stages committed
The brief
A synthetic airline (simulated company) scores every booking departing in the next three days for no-show risk. A colleague (simulated) opens a pull request: "Nightly no-show scoring v2: faster feature handling, adds risk bands for the call team. Output goes to the reconfirmation queue." The data are synthetic.
import pickle
import pandas as pd
FEATURES = ["days_to_departure", "fare_paid", "party_size", "is_member"]
def score_batch(model_path, bookings: pd.DataFrame) -> pd.DataFrame:
model = pickle.load(open(model_path, "rb")) # model_path comes from the job config
bookings = bookings.fillna(0)
risks = []
for _, row in bookings.iterrows():
x = row[FEATURES].to_frame().T
risks.append(model.predict_proba(x)[0][1])
bookings["noshow_risk"] = risks
bookings["risk_band"] = (bookings["noshow_risk"] * 10).astype(int) # 0..9, 9 = highest
bookings["fare_usd"] = bookings["fare_paid"].astype("int32")
return bookings[bookings["risk_band"] >= 8]
The job runs on about 400,000 bookings a night. model_path is a string in a YAML config that a deploy script
writes from a pull request to the config repository.
Stage 1 of 4
Review the code above before reading any hint. Assume the table has the columns named in FEATURES and that
a missing value is possible in any of them.
Which issues would you block the merge on? Select all that apply.