Welcome to Data Design!
Before we dive into complex algorithms or colorful charts, we have to talk about the "foundation" of your predictive model: Data Design. Think of data design like choosing the right ingredients for a meal. Even the best chef in the world (that’s you!) can't make a five-star dinner with the wrong ingredients.
In this chapter, we focus on three big decisions you must make before you start modeling: Time Frame (When did this happen?), Granularity (How much detail do we have?), and Sampling (Which specific records are we using?). Understanding these will help you ensure your model is both accurate and useful for the real world. Don’t worry if these sound like technical terms; we’re going to break them down into simple, everyday concepts.
1. The Time Frame: Timing is Everything
In predictive analytics, we are usually trying to use the past to predict the future. To do this, we have to divide our data into specific windows of time.
Observation vs. Performance Periods
Imagine you are trying to predict if a driver will have a car accident next year. To do this, you look at their driving records from the previous two years.
• Observation Period: This is the window of time where we gather our "features" or predictors (e.g., how many speeding tickets did the driver get in 2022 and 2023?).
• Performance Period: This is the window where we look for the outcome or "target" (e.g., did they have an accident in 2024?).
The Problem of Lag Time
In the insurance world, data isn't always available instantly. This is called Lag Time. For example, a doctor might see a patient today, but the insurance company might not receive the bill for three weeks. If your model doesn't account for this delay, your "current" data might be missing important information, leading to poor predictions.
Quick Review: Always ensure there is no overlap between your predictors and your target. If you accidentally include information from the "future" (the performance period) in your "past" (the observation period), you are committing Data Leakage—a very common mistake that makes your model look much better than it actually is!
Key Takeaway: Setting a clear time frame ensures your model learns from the past to predict a distinct future window, while accounting for real-world delays in data reporting.
2. Granularity: Finding the "Zoom Level"
Granularity refers to the level of detail represented by a single row in your dataset. Are you looking at a single person, a single transaction, or a whole city?
High vs. Low Granularity
• High Granularity (Fine-Grained): This means a lot of detail. Example: Every individual purchase a customer makes at a grocery store.
• Low Granularity (Coarse-Grained): This means the data is aggregated. Example: The total amount a customer spent at the grocery store in a whole year.
Which one should you choose?
Choosing the right granularity is like choosing the right lens on a camera. If you zoom in too far (High Granularity), you might see too much "noise" (random variations). If you zoom out too far (Low Granularity), you might lose important patterns.
Example: If you want to predict if a specific policyholder will cancel their insurance, you need data at the Individual Level. If you use data at the State Level, you’ll know if people in New York are canceling, but you won't know if John Smith is likely to cancel.
Did you know? Changing granularity often involves aggregation. For example, taking 365 daily temperature readings and averaging them into one "Annual Average Temperature" reduces granularity but makes the data easier to manage.
Key Takeaway: Your data's granularity must match your business goal. If you want to predict individual behavior, your data rows must represent individuals!
3. Sampling: Choosing the Right Group
Sometimes we have too much data to process, or we need to set some aside to test our model. This is where Sampling comes in. A sample is a smaller subset of the total population.
Simple Random Sampling
This is like pulling names out of a hat. Every record has an equal chance of being chosen. It’s easy, but it has a weakness: if you have a very rare event (like a rare disease or a massive insurance claim), a random sample might miss those cases entirely!
Stratified Sampling
This is a "smarter" way to sample. You divide the data into groups (called Strata) first—like Age or Gender—and then sample from each group. This ensures that every group is fairly represented in your final dataset.
Analogy: If you are tasting a layered cake, a "simple random sample" might just give you a spoonful of frosting. A "stratified sample" ensures you get a bit of every layer in one bite.
Training, Validation, and Test Sets
In Exam PA, you will almost always split your data into these three buckets:
1. Training Set: This is the data the model "studies" to learn patterns.
2. Validation Set: This is used to "tune" the model (like a practice quiz) to see which settings work best.
3. Test Set: This is the final exam. We only look at this once the model is finished to see how it performs on totally new data.
Common Mistake: Using your Test Set to make decisions about which variables to include. This is "cheating"! The Test Set should remain a secret until the very end.
Key Takeaway: Sampling helps us manage data and ensures our models are tested fairly. Stratified sampling is especially useful when we want to make sure rare but important groups are included.
Chapter Summary & Quick Tips
• Time Frame: Keep your "past" (Observation) and "future" (Performance) separate. Watch out for Lag Time!
• Granularity: Match your "zoom level" to your goal. Don't hide important details by aggregating too much.
• Sampling: Use Random Sampling for general needs and Stratified Sampling to ensure small groups are represented. Always split your data into Training and Testing sets.
• Mnemonic for Data Design: Just remember G.T.S. (Granularity, Time frame, Sampling) — or "Get The Scope" before you start your project!
Don't worry if this seems like a lot of preparation. In Predictive Analytics, 80% of the work is often getting the data design right. Once your design is solid, the actual modeling becomes much smoother! You’ve got this!