Bifalgorithm post
You just experienced data leakage. They sneak as bug in machine learning. Data leakage is when information from the future sneaks into your training data. Your model learns to cheat instead of learning real patterns. It's like studying for a test by memorizing the exact question that will be on the exam. Great score in practice, but you learn nothing. Imagine building a fraud detection model and you included a column that is "is refunded" whether the transaction was refunded or not. In that case, your model gets like 95% or 98% accuracy. You ship it, but wait, you only know if something was refunded after it was flagged as fraud. That information doesn't exist at prediction time, so your model learned to cheat by picking at the future. In production, this column is empty and your model is useless. There are three types of data leakage. The first one is target leakage. Your features contain information that only exist because of the target. Let's say using hospital stay lens column to predict if someone will be hospitalized. The lens only exists if they are already hospitalized. Type 2 is train test and termination. You process your entire dataset together before splitting train and test. Your test data influenced your training data. You are testing on data the model has already seen indirectly. and accuracy it is very suspicious. Real world is my say perfect accuracy means something is wrong. Red flag number two, performance crashes in production. Your model worked great on testing and terrible in the real world that can be data leakage. And red flag number three, one feature has extreme importance. If one column predicts everything perfectly, it's probably leaking information from the target. How to fix it? Think about time. Ask yourself, "Would I have this information at my prediction time?" For every feature imagine you are making a prediction right now. Do you actually know this value yet? If the answer is no or if you only know it because of what you're trying to predict, that's leakage. The golden rule, only use information that existed before the event you are predicting.
You just experienced data leakage. They sneak as bug in machine learning. Data leakage is when information from the future sneaks into your training data. Your…
Ideas in this flowchart
- Data Leakage
- Definition
- Information from the future in training data
- Model cheats instead of learning
- Example: Fraud detection model
- Column 'is refunded' included
- High accuracy but impractical
- Types of Data Leakage
- Target Leakage
- Features contain target-dependent info
- Example: Hospital stay length
- Train-Test Contamination
- Dataset processed before splitting
- Red Flags
- Suspiciously high accuracy
- Performance crashes in production
- One feature has extreme importance
- Fixing Data Leakage
- Think about time
- Golden Rule
- Use only pre-event information