Define a Distance That Makes Sense
Two deliveries have equal mileage but different road conditions.
Read the full lesson and open its transcript below. A narrated video will be added after production.
What you will learn
Two deliveries have equal mileage but different road conditions.
A practical question
Two planned trips have equal mileage, but one takes a city road in rain and the other a clear highway. If distance means only a difference in kilometers, they look identical to a nearest-neighbor method. We need a representation that reflects what matters for delay.
The useful idea
Choose features known before departure and define how their differences combine. Numeric scales and category encoding affect the resulting distance. A large temperature number can outweigh a binary rain indicator even when rain matters more to the dispatcher.
Work through the example
List the nearest past trips under two candidate distance rules. Do the neighbors share conditions relevant to lateness, or merely similar raw numbers? Check held-out performance before deciding that a hand-designed metric is useful. Two trips can be equally long and still face very different conditions. A nearest-neighbor model only sees the inputs and distance rule we give it. Compare a rainy city delivery with a dry highway run under distance-only matching, then include the route and weather information known before departure. Inspect which historical trips move into the nearest group. A mathematically small distance is not automatically a useful operational comparison. Keep the feature definitions visible so the dispatcher can challenge a surprising neighbor. Now check the idea on a concrete example: Compare raw mileage distance with a representation including weather and route type. A possible trap is worth naming: A mathematically near record may not be operationally comparable. The answer follows from that evidence: A distance measure encodes which features count as similar and at what scale. Ask the dispatcher which of the two equal-mileage trips resembles the new route. If the model chooses the rainy city trip solely because of distance, the neighbor list reveals a flaw in the similarity rule before any summary score does.
Limits and next step
Next, we'll standardize some features so their units don't control the neighbor search by accident.
Worked example
Compare raw mileage distance with a representation including weather and route type.
Quick check: test your understanding
Try it yourself: Consider this case: Compare raw mileage distance with a representation including weather and route type. Explain how you would check the result. In your answer, address this limitation: A mathematically near record may not be operationally comparable.
Check the reasoning
A distance measure encodes which features count as similar and at what scale. A mathematically near record may not be operationally comparable.
What is the main idea behind define a distance that makes sense?
A distance measure encodes which features count as similar and at what scale.
How is it used in the example?
Compare raw mileage distance with a representation including weather and route type.
What limitation should be checked?
A mathematically near record may not be operationally comparable.
Further reading
Machine Learning — Tom M. Mitchell.
Original ToolsInVision teaching examples. Editorial approach · Suggest a correction
Accessible referenceLesson 41 transcript307 words · Narration ready for the upcoming videoOpen transcript
Two planned trips have equal mileage, but one takes a city road in rain and the other a clear highway. If distance means only a difference in kilometers, they look identical to a nearest-neighbor method. We need a representation that reflects what matters for delay.
Choose features known before departure and define how their differences combine. Numeric scales and category encoding affect the resulting distance. A large temperature number can outweigh a binary rain indicator even when rain matters more to the dispatcher.
List the nearest past trips under two candidate distance rules. Do the neighbors share conditions relevant to lateness, or merely similar raw numbers? Check held-out performance before deciding that a hand-designed metric is useful. Two trips can be equally long and still face very different conditions. A nearest-neighbor model only sees the inputs and distance rule we give it. Compare a rainy city delivery with a dry highway run under distance-only matching, then include the route and weather information known before departure. Inspect which historical trips move into the nearest group. A mathematically small distance is not automatically a useful operational comparison. Keep the feature definitions visible so the dispatcher can challenge a surprising neighbor. Now check the idea on a concrete example: Compare raw mileage distance with a representation including weather and route type. A possible trap is worth naming: A mathematically near record may not be operationally comparable. The answer follows from that evidence: A distance measure encodes which features count as similar and at what scale. Ask the dispatcher which of the two equal-mileage trips resembles the new route. If the model chooses the rainy city trip solely because of distance, the neighbor list reveals a flaw in the similarity rule before any summary score does.
Next, we'll standardize some features so their units don't control the neighbor search by accident.