{
  "source_file": "0930",
  "source_platform": "Medium",
  "author": "Ivo Bernardo",
  "title_listed": "Common Causes of Data Leakage and how to Spot Them",
  "keywords": "",
  "domain": "机器学习",
  "content_type": "深度技术解析",
  "is_paid_flag": "否",
  "url": "https://towardsdatascience.com/common-causes-of-data-leakage-and-how-to-spot-them-17113406f9f8/",
  "publish_date": "2024-05-17",
  "corpus_stage": "",
  "notes": "",
  "id": "9e240e96b7df",
  "collected_at": "2026-10-02T05:42:26",
  "title": "Common Causes of Data Leakage and how to Spot Them | Towards Data Science",
  "body_markdown": "![Revisit consent button](../images/body-df29beacd7496220cc94.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](../images/body-2159bb67f3de8ad870eb.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\n# Common Causes of Data Leakage and how to Spot Them\nLet's learn how to identify and deal with the common causes of data leakage in ML models\n[Ivo Bernardo](https://towardsdatascience.com/author/ivopbernardo/)\nMay 17, 20248 min read\n![Image by realaxer @Unsplash.com](../images/000.jpg)\nImage by [realaxer](https://unsplash.com/pt-br/@realaxer) @Unsplash.com\nOne of a Data Scientist's worst nightmares is data leakage. And why is data leakage so harmful? **Because the ways your models may suffer from it are designed to convince you that your model is excellent and that you should be expecting awesome results in the future.**\nAs you may know, the primary goal of every machine learning model is to generalize the patterns it learns for the future data. As we can't really access future data (without making a time machine first), the best way to simulate this during model development is to set aside a test and a validation set to be used to assess model performance.\nDuring development, data scientists aim to improve the model's test and validation performance. If results are satisfactory, then data scientists assume that their models are ready for production. And that's why data leakage is so dangerous. As it's able to hide itself in seemingly innocent behaviors, it can lurk in the background, waiting for you to put that model into production and just find out that the performance in real life is way worse than the one on the test set.\nNormally, data leakage involves the process of polluting our train set with things that will end up violating one or more parameters of \"future dataset\" rule. And it's one of the most major causes of unsuccessful model deployments.\nLearn this step by step with the interactive [AI Engineer](https://roadmap.sh/ai-engineer), [AI and Data Scientist](https://roadmap.sh/ai-data-scientist) and [Machine Learning](https://roadmap.sh/machine-learning) roadmaps.\nIn this blog post, we'll discuss some of the most common data leakage sources and some tips on how to spot them!\nLet's dive in!\n* * *\n## Feature Leakage\nProbably the most famous data leakage source (and the easiest to spot, as well).\nFeature leakage happens when we have features that are directly related to the target often being a result of the target event. Normally, feature leakage happens because the feature value is updated in a point in time after the target event.\nLet's see some examples:\n  * 1) You are trying to predict loan default of a certain customer and one of your features is the number of outbound calls that the customer had in past 30 days. What you don't know is that in this fictional bank the customer only receives outbound calls if it has already entered into a default scenario.\n  * 2) You are trying to predict a certain disease of a patient and are using the number of times the patient went through a specific diagnostic test. However, you later find that this test is only prescribed to people that have a high likelihood of having the disease.\n  * 3) You are using a feature with the name days_finish_contract* as a feature to predict if a customer will churn or not.\n\n\n> *days after the last contract of the customer with a specific company finished (for example, in a telco business). If the customer does not renew, this is, indeed, the churn event.\nThese three examples also show different levels of feature leakage. For example, in 1) and 3), there is a direct correlation between target and features and it's very likely that 100% of the target will have these variables as non-null values. However, 2) is harder to spot, because other patients may have gone through the diagnostic test and didn't have the disease making this leakage source less obvious.\nOne way to spot feature leakage is via _feature importance_ data obtained in different models. **For me, what works very well is fitting an extremely shallow decision tree and checking if one of the features has an enormous difference, in terms of importance, compared to others.** When I find that a feature is overly indexed, those features are normally related to leakage problems.\nTo solve these problems, it's recommended that you look into how these features that have leakage were generated so that you can:\n  * Remove the feature if there's no other way to generate it.\n  * Change the feature so that no information from the future leaks into the target.\n\n\n* * *\n## Time Correlated Data using Random-Test Split\nFunny story - I've learned this the hard way. In the past, I've developed machine learning models to predict soccer games' results and ended up having a betting system that was completely flawed.\nProbably you've felt something along these lines before - have you ever trained a time-series model and had spectacular results on the test set?\nThat's quite common when you perform a **random train-test** split on your dataset when rows have a time-dependence. Even if you are not training a time series model, but your rows are time-dependent, you should always perform a continuous train-test split based on time and not a random train-test split.\nTime-dependent data is a tricky thing to model, particularly because covariates and data distribution shifts as time goes by. If you hint any portion of the new distributions to the train set, your model will be flawed.\nThe recommendation for time-dependent data is to perform assessments on a continuous cross-validation (CV) mechanism, similar to the one below:\n![Appropriate Train and Test for Time-Dependent Data - Image by Author](../images/001.png)\nAppropriate Train and Test for Time-Dependent Data - Image by Author\nSo, yeah.. never use random train-test split on time-dependent data!\n* * *\n## Hinting Something to the Test Set via Scaling and Preprocessing\nThis is a trickier one has even sometimes even experienced data scientists end up falling for it. When performing outlier analysis, scaling, missing value imputation, always make sure that you perform those analysis on the train set and after train-test splitting.\nSometimes people confuse this sentence with **applying** the same transformations to the test set - while that is completely true (your test set needs to mimic your training set's scale and not contain missing values), you shouldn't give any hint of the distribution of the test set to the train one.\nFor example, imagine you are applying a Standard Scaler (that uses a Z-Score with mean and standard deviation). You want this standard scaler to memorize the average and standard deviation of the **train set. After that set you will apply the same scaler with the fixed statistics from the training set to the test set.**\nTake another famous preprocessing step: removing outliers. Does it make sense to remove outliers from the test set? Well, if you know what will be an outlier in the future (remember that test sets are just really poor simulations of a future dataset where the model will be used on) then tell me please, because you have just invented a time machine!\nAs it's not possible to remove outliers in the future (of course, **you can remove obvious outliers from being scored by your model)** , you generally lack information about what a \"future\" outlier will look like. If you do remove outliers in the test set, you should expect a larger drift between the test set performance and real world deployment.\nTo avoid this type of leakage, perform train-test split before you do anything on the data.\n![A Data Scientist finding out their model is wrong in Production - Image by AI generated by Microsoft Design](../images/002.jpg)\nA Data Scientist finding out their model is wrong in Production - Image by AI generated by Microsoft Design\n* * *\n## Leakage from Data Generation and Sources\nThis one is trickier to spot. Feature leakage from data generation and/or data sources is normally tied with how data is collected. You probably won't have full control of it as a data scientist.\nLet's take the customer default example that we pointed out in the **Feature Leakage -** imagine you are building a predictive model that wants to find out if a customer will default in the next installment and you find out that the number of outbound calls to the customer is a great feature to predict this.\nYou speak with people who are actively doing these phone calls and you find out that the process is fair. They actually call riskier customers and it may make sense that you include this feature in the model. But, after sitting down with them, you find out that there are certain calls that happen after they are certain that the customer will default.\nWhat happens is that your IT systems only log defaults one day after they actually happened so some of these calls are actually calls to ask customer why they defaulted. If you use this feature (call is done on day _x_ , default is logged on day _x_ +1), you'll actually be adding leakage to your model's prediction as a feature is leaking information into the target.\nThis is the hardest leakage to spot as it requires that you deeply know how your features were generated and good data governance models. Nevertheless, using the technique we spoke about in the **Feature Leakage** section can be a quick and raw way to understand if you have obvious leakage from the generation and sourcing of your data.\n* * *\n## Feature Engineering\nAnother common way to generate data leakage is during the feature engineering process. Although this is just a subset of **Feature Leakage,** it's so common that I needed to point it out.\nOne common example is when creating moving averages in time-series. Often, people may confuse time intervals and add periods that you are supposed to predict on the average value. When overlooked, this will create an enormous distortion on the time series model.\nAnother example is when using features that were themselves generated by other machine learning models. Using these features is always risky as these models have uncertainty (and may have leakage) inside them. Building these features based on other models can have a high impact and \"seemingly\" create a much better model that loses its generalization power.\n## Conclusion\nAnd that's it! These are the most common data leakage problems that I've found in my career as a data scientist.\nIn a nutshell, data leakage is the silent killer of machine learning models. It's designed to make you feel that you have a great model but whose performance is highly influenced by leakage problems. Data leakage issues can be so bad that they can impact your model as soon as you get it into production. Identifying leakage as soon as possible will not only make your model more stable but also more accurate in the real world.\nDo you know any other data leakage causes that I didn't mention here? Point them out in the comments!\nAlso, feel free to check me out on my Youtube Channel:\n![](../images/body-12553483658cd4fc0345.jpeg)\nYou can subscribe to my channel \"[_The Data Journey_](https://www.youtube.com/channel/UCq-1TNG9csV4AVa0i6AU5rw)\" here. Or my [Udemy ](https://www.udemy.com/user/ivo-bernardo/)page here.\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](../images/body-6f351be10c9e83aa9f9d.jpeg)\nWritten By\n## [Ivo Bernardo](https://towardsdatascience.com/author/ivopbernardo/)\n[See all from Ivo Bernardo](https://towardsdatascience.com/author/ivopbernardo/)\n[Artificial Intelligence](https://towardsdatascience.com/tag/artificial-intelligence/)[Data Leakage](https://towardsdatascience.com/tag/data-leakage/)[Data Science](https://towardsdatascience.com/tag/data-science/)[Machine Learning](https://towardsdatascience.com/tag/machine-learning/)[Mlops](https://towardsdatascience.com/tag/mlops/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fcommon-causes-of-data-leakage-and-how-to-spot-them-17113406f9f8%2F&title=Common%20Causes%20of%20Data%20Leakage%20and%20how%20to%20Spot%20Them)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fcommon-causes-of-data-leakage-and-how-to-spot-them-17113406f9f8%2F&title=Common%20Causes%20of%20Data%20Leakage%20and%20how%20to%20Spot%20Them)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fcommon-causes-of-data-leakage-and-how-to-spot-them-17113406f9f8%2F&text=Common%20Causes%20of%20Data%20Leakage%20and%20how%20to%20Spot%20Them)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](../images/003.jpg)](https://towardsdatascience.com/ive-done-80-data-science-interviews-here-s-what-works-ae8053f79a6d/)\n## [I’ve Done 80+ Data Science Interviews – Here’s What Works](https://towardsdatascience.com/ive-done-80-data-science-interviews-here-s-what-works-ae8053f79a6d/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\n3 years of data science interview experience\n[Egor Howell](https://towardsdatascience.com/author/egorhowell/)\nDecember 24, 20246 min read\n  * [![](../images/004.png)](https://towardsdatascience.com/rethinking-data-science-interviews-in-the-age-of-ai/)\n## [Rethinking Data Science Interviews in the Age of AI](https://towardsdatascience.com/rethinking-data-science-interviews-in-the-age-of-ai/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nHow AI is transforming data science interviews—and what hiring managers and candidates should do to adapt\n[Yu Dong](https://towardsdatascience.com/author/ydong029/)\nJuly 4, 202510 min read\n  * [![](../images/005.jpeg)](https://towardsdatascience.com/im-a-self-taught-data-scientist-here-are-my-3-suggestions-for-newcomers-5f5d54e597a8/)\n## [I'm a Self-Taught Data Scientist. Here Are My 3 Suggestions for Newcomers](https://towardsdatascience.com/im-a-self-taught-data-scientist-here-are-my-3-suggestions-for-newcomers-5f5d54e597a8/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nMake your learning journey more efficient.\n[Soner Yıldırım](https://towardsdatascience.com/author/sonery/)\nApril 13, 20225 min read\n  * [![](../images/006.png)](https://towardsdatascience.com/dont-miss-out-on-pub-sub-5dbfa15cf3d0/)\n## [Don't Miss Out on Pub/Sub](https://towardsdatascience.com/dont-miss-out-on-pub-sub-5dbfa15cf3d0/)\n[Programming](https://towardsdatascience.com/category/programming/)\nA high-level overview of the Pub/Sub pattern and why you should be incorporating it into your projects.\n[Andrew Didinchuk](https://towardsdatascience.com/author/appliedarchitect/)\nFebruary 15, 20213 min read\n  * [![](../images/007.png)](https://towardsdatascience.com/understanding-morphological-image-processing-and-its-operations-7bcf1ed11756/)\n## [Understanding Morphological Image Processing and Its Operations](https://towardsdatascience.com/understanding-morphological-image-processing-and-its-operations-7bcf1ed11756/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nThis article illustrates Morphological Image Processing in more straightforward terms; readers can understand how Morphology works in...\n[Prateek Chhikara](https://towardsdatascience.com/author/prateekchhikara/)\nMarch 30, 20225 min read\n  * [![](../images/008.png)](https://towardsdatascience.com/kickstart-your-data-science-journey-a-guide-for-aspiring-data-scientists-96e5072bd19a/)\n## [Kickstart Your Data Science Journey - A Guide for Aspiring Data Scientists](https://towardsdatascience.com/kickstart-your-data-science-journey-a-guide-for-aspiring-data-scientists-96e5072bd19a/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nKey Technical Skills You Need to Kick-start Your Career in Data Science\n[Saankhya Mondal](https://towardsdatascience.com/author/saankhya/)\nNovember 6, 202416 min read\n  * [![](../images/009.jpg)](https://towardsdatascience.com/data-science-for-the-heart-c654135ceee5/)\n## [Data Science for the Heart](https://towardsdatascience.com/data-science-for-the-heart-c654135ceee5/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nCardiovascular Disease Data Analysis and Predictive Modeling\n[Suleman Bazai](https://towardsdatascience.com/author/sulemanbazai/)\nMay 17, 202112 min read\n  * [![](../images/010.jpeg)](https://towardsdatascience.com/why-do-you-need-to-use-sql-grouping-sets-for-aggregating-data-3d172ff5c088/)\n## [Why Do You Need to Use SQL Grouping Sets for Aggregating Data?](https://towardsdatascience.com/why-do-you-need-to-use-sql-grouping-sets-for-aggregating-data-3d172ff5c088/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nEfficiency, readability, and scalability\n[Soner Yıldırım](https://towardsdatascience.com/author/sonery/)\nApril 20, 20233 min read\n  * [![](../images/011.jpg)](https://towardsdatascience.com/artificial-intelligence-is-transforming-modern-education-d95bf8d19acd/)\n## [Artificial Intelligence is Transforming Modern Education](https://towardsdatascience.com/artificial-intelligence-is-transforming-modern-education-d95bf8d19acd/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nA commentary piece on how AI is being used in today's classrooms as well as discussion on the path forward.\n[Sanjay Adhikesaven](https://towardsdatascience.com/author/sanjay.adhikesaven/)\nSeptember 11, 202210 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500) How Relevance Models Foreshadowed Transformers for NLP ](https://towardsdatascience.com/how-relevance-models-foreshadowed-transformers-for-nlp/ \"How Relevance Models Foreshadowed Transformers for NLP\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500) Does Your Company Have a Data Strategy? ](https://towardsdatascience.com/does-your-company-have-a-data-strategy-e8944dbec4ae/ \"Does Your Company Have a Data Strategy?\")\n\n\n",
  "metadata": {
    "title": "Common Causes of Data Leakage and how to Spot Them | Towards Data Science",
    "description": "Let's learn how to identify and deal with the common causes of data leakage in ML models",
    "keywords": null,
    "author": "Ivo Bernardo",
    "og:locale": "en_US",
    "og:type": "article",
    "og:title": "Common Causes of Data Leakage and how to Spot Them",
    "og:description": "Let's learn how to identify and deal with the common causes of data leakage in ML models",
    "og:url": "https://towardsdatascience.com/common-causes-of-data-leakage-and-how-to-spot-them-17113406f9f8/",
    "og:site_name": "Towards Data Science",
    "og:image": "https://assets.insightmediagroup.io/media/wp-content/uploads/2024/05/0Oq_OdOVeEcDLA98V.jpg",
    "og:image:width": "1000",
    "og:image:height": "795",
    "og:image:type": "image/jpeg",
    "twitter:card": "summary_large_image",
    "twitter:site": "@TDataScience",
    "twitter:creator": "@TDataScience",
    "twitter:label1": "Written by",
    "twitter:data1": "Ivo Bernardo",
    "twitter:label2": "Est. reading time",
    "twitter:data2": "8 min read",
    "article:published_time": "2024-05-17T11:54:12.000Z",
    "article:modified_time": "2024-05-17T11:54:12.000Z",
    "article:author": "https://towardsdatascience.com/author/ivopbernardo/"
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 202,
    "error": ""
  },
  "code_blocks": [],
  "images": [
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:45:45Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:45:45Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:45:45Z"
    },
    {
      "status": "http_404",
      "url": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500",
      "src": "https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500",
      "alt": "",
      "downloaded": false,
      "discovery": "saved_markdown",
      "retried_at": "2026-10-20T17:45:45Z"
    }
  ],
  "audio": [],
  "videos": [
    {
      "url": "https://www.youtube.com/channel/UCq-1TNG9csV4AVa0i6AU5rw",
      "kind": "channel_reference",
      "status": "reference_only"
    },
    {
      "url": "https://www.youtube.com/c/TowardsDataScience",
      "kind": "channel_reference",
      "status": "reference_only"
    }
  ],
  "links": [
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/latest/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/editors-pick/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/the-variable/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/shipai/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/submissions/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/artificial-intelligence/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/ivopbernardo/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/artificial-intelligence/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/data-leakage/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/machine-learning/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/mlops/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/ive-done-80-data-science-interviews-here-s-what-works-ae8053f79a6d/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/data-science/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/egorhowell/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/rethinking-data-science-interviews-in-the-age-of-ai/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/author/ydong029/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/im-a-self-taught-data-scientist-here-are-my-3-suggestions-for-newcomers-5f5d54e597a8/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/category/artificial-intelligence/machine-learning/"
    },
    {
      "type": "external",
      "href": "https://write.insightmediagroup.io"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/company/towards-data-science/"
    },
    {
      "type": "external",
      "href": "https://x.com/TDataScience"
    },
    {
      "type": "external",
      "href": "https://unsplash.com/pt-br/@realaxer"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/ai-engineer"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/ai-data-scientist"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/machine-learning"
    },
    {
      "type": "external",
      "href": "https://www.youtube.com/channel/UCq-1TNG9csV4AVa0i6AU5rw"
    },
    {
      "type": "external",
      "href": "https://www.udemy.com/user/ivo-bernardo/"
    },
    {
      "type": "external",
      "href": "https://www.facebook.com/sharer/sharer.php?title=Common+Causes+of+Data+Leakage+and+how+to+Spot+Them&u=https%3A%2F%2Ftowardsdatascience.com%2Fcommon-causes-of-data-leakage-and-how-to-spot-them-17113406f9f8%2F"
    },
    {
      "type": "external",
      "href": "https://www.linkedin.com/shareArticle?mini=true&title=Common+Causes+of+Data+Leakage+and+how+to+Spot+Them&url=https%3A%2F%2Ftowardsdatascience.com%2Fcommon-causes-of-data-leakage-and-how-to-spot-them-17113406f9f8%2F"
    },
    {
      "type": "external",
      "href": "https://x.com/share?text=Common+Causes+of+Data+Leakage+and+how+to+Spot+Them&url=https%3A%2F%2Ftowardsdatascience.com%2Fcommon-causes-of-data-leakage-and-how-to-spot-them-17113406f9f8%2F"
    },
    {
      "type": "external",
      "href": "https://www.youtube.com/c/TowardsDataScience"
    },
    {
      "type": "external",
      "href": "https://www.threads.net/@towardsdatascience"
    },
    {
      "type": "external",
      "href": "https://bsky.app/profile/towardsdatascience.com"
    },
    {
      "type": "external",
      "href": "https://thenewstack.io"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh"
    },
    {
      "type": "external",
      "href": "https://insightmediagroup.io/creator-network"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-20T17:26:12Z",
  "source_url": "https://towardsdatascience.com/common-causes-of-data-leakage-and-how-to-spot-them-17113406f9f8/",
  "delivery_status": "unverified",
  "discovery_status": "http_403",
  "missing_reason": "源页面未重新核验:http_403；已按保留正文补采图片",
  "repair_error": "",
  "actual_video_files": [
    {
      "local_path": "attachments/9e240e96b7df/videos/-3nLivEM2aM.mp4",
      "bytes": 39100389,
      "valid": true,
      "height": 1080,
      "width": 1720,
      "duration": "630.281000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/-zz_Bt4pFoE.mp4",
      "bytes": 11412069,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "310.261000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/0RZqDquD7h8.mp4",
      "bytes": 23834950,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "613.021000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/0nhyYTmk0RI.mp4",
      "bytes": 44524637,
      "valid": true,
      "height": 1080,
      "width": 1740,
      "duration": "762.941000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/2ODeQ8agDOc.mp4",
      "bytes": 11871782,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "292.861000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/4z3J9_zpD4E.mp4",
      "bytes": 18331514,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "453.681000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/54W8clywbIk.mp4",
      "bytes": 12867494,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "355.081000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/5ZU9A7PjTB8.mp4",
      "bytes": 17175766,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "356.521000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/65UkZm2-22k.mp4",
      "bytes": 29360792,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "624.361000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/7mFPWBuPj8g.mp4",
      "bytes": 10540072,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "269.781000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/8AmeYHBGlV4.mp4",
      "bytes": 15995996,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "407.821000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/AolplfjU7gs.mp4",
      "bytes": 10441562,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "273.921000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/B92QcIlSDpo.mp4",
      "bytes": 13526498,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "338.361000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/D6GluNbMicw.mp4",
      "bytes": 133074174,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "1832.161000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/GUTlaLM42Z8.mp4",
      "bytes": 15645453,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "366.121000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/ILJAlIngCdk.mp4",
      "bytes": 6645405,
      "valid": true,
      "height": 720,
      "width": 1280,
      "duration": "191.101000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/J-P6QFjKYLI.mp4",
      "bytes": 108867827,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "564.801000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/KCCudEVYNbs.mp4",
      "bytes": 15706111,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "399.121000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/KSXhVT-Eq1w.mp4",
      "bytes": 4809904,
      "valid": true,
      "height": 720,
      "width": 1280,
      "duration": "144.261000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/LllhxHYlVSM.mp4",
      "bytes": 19632317,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "490.321000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/MIaCO8djddc.mp4",
      "bytes": 11987418,
      "valid": true,
      "height": 720,
      "width": 1280,
      "duration": "386.861000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/P-qn2ipBgZs.mp4",
      "bytes": 17359321,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "437.661000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/QDz4H8ufS9U.mp4",
      "bytes": 20611205,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "511.661000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/QhFV_4_d5ZY.mp4",
      "bytes": 54591313,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "601.861000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/SLrBWOO0DiE.mp4",
      "bytes": 8638711,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "207.061000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/T9CR_sEhN8M.mp4",
      "bytes": 12409609,
      "valid": true,
      "height": 720,
      "width": 1280,
      "duration": "289.561000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/TXTVqE2BwvY.mp4",
      "bytes": 42262072,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "639.721000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/UT8EmHoQqEI.mp4",
      "bytes": 21535793,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "569.421000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/VkBKmK_qQWo.mp4",
      "bytes": 4190471,
      "valid": true,
      "height": 1080,
      "width": 608,
      "duration": "54.661000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/W1CzNLUV7dA.mp4",
      "bytes": 8747780,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "243.861000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/X67jcO6Pajs.mp4",
      "bytes": 24953594,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "629.521000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/XStsnbfAJKQ.mp4",
      "bytes": 13325751,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "341.221000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/ZemoWHB3_bA.mp4",
      "bytes": 45294584,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "710.161000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/d25yQsvImME.mp4",
      "bytes": 56208066,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "781.201000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/dcE5I14e7Jw.mp4",
      "bytes": 6878539,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "168.861000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/dgVIyhkLrvc.mp4",
      "bytes": 11729716,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "306.121000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/f3iX4_c7nsE.mp4",
      "bytes": 19138609,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "435.881000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/lC-RPwJrURE.mp4",
      "bytes": 17053776,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "460.861000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/m3bBzmx3gT4.mp4",
      "bytes": 9303249,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "217.021000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/oDJPklcq_A8.mp4",
      "bytes": 30837802,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "628.521000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/qe2L-n4C_Lo.mp4",
      "bytes": 4471516,
      "valid": true,
      "height": 720,
      "width": 1280,
      "duration": "123.461000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/r-TwM2UTWLM.mp4",
      "bytes": 16952991,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "434.521000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/r3hrkn8D1o4.mp4",
      "bytes": 18975631,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "494.941000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/seEIbwwhFGs.mp4",
      "bytes": 10790084,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "247.201000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/slq4v-9KJz0.mp4",
      "bytes": 122497299,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "619.261000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/uB6GDnyj0ss.mp4",
      "bytes": 151563491,
      "valid": true,
      "height": 1080,
      "width": 1710,
      "duration": "2023.361000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/um3_oEHBBTo.mp4",
      "bytes": 126791515,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "1522.881000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/um8JTY8-7FM.mp4",
      "bytes": 18637388,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "460.121000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/wCKellrHkUk.mp4",
      "bytes": 11937912,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "244.461000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/wX_rM_LQmWA.mp4",
      "bytes": 7929545,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "205.621000",
      "status": "ok"
    },
    {
      "local_path": "attachments/9e240e96b7df/videos/xskeHC4s3yk.mp4",
      "bytes": 13446896,
      "valid": true,
      "height": 1080,
      "width": 1920,
      "duration": "327.721000",
      "status": "ok"
    }
  ],
  "expected_saved_body_images": 4,
  "image_discovery": "saved_markdown",
  "source_body_markdown": "![Revisit consent button](https://cdn-cookieyes.com/assets/images/revisit.svg)\nWe value your privacy\nWe use cookies to enhance your browsing experience, serve personalised ads or content, and analyse our traffic. By clicking \"Accept All\", you consent to our use of cookies.\nCustomise Reject All Accept All\nCustomise Consent Preferences ![](https://cdn-cookieyes.com/assets/images/close.svg)\nWe use cookies to help you navigate efficiently and perform certain functions. You will find detailed information about all cookies under each consent category below.\nThe cookies that are categorised as \"Necessary\" are stored on your browser as they are essential for enabling the basic functionalities of the site. ... Show more\nNecessaryAlways Active\nNecessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.\n  * Cookie\nBCTempID\n  * Duration\n10 minutes\n  * Description\nNo description available.\n\n\n  * Cookie\n__cf_bm\n  * Duration\n1 hour\n  * Description\nThis cookie, set by Cloudflare, is used to support Cloudflare Bot Management. \n\n\n  * Cookie\nAWSALBCORS\n  * Duration\n7 days\n  * Description\nAmazon Web Services set this cookie for load balancing.\n\n\n  * Cookie\n_cfuvid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to track users across sessions to optimize user experience by maintaining session consistency and providing personalized services\n\n\n  * Cookie\nli_gc\n  * Duration\n6 months\n  * Description\nLinkedin set this cookie for storing visitor's consent regarding using cookies for non-essential purposes.\n\n\n  * Cookie\n__hssrc\n  * Duration\nsession\n  * Description\nThis cookie is set by Hubspot whenever it changes the session cookie. The __hssrc cookie set to 1 indicates that the user has restarted the browser, and if the cookie does not exist, it is assumed to be a new session.\n\n\n  * Cookie\n__hssc\n  * Duration\n1 hour\n  * Description\nHubSpot sets this cookie to keep track of sessions and to determine if HubSpot should increment the session number and timestamps in the __hstc cookie.\n\n\n  * Cookie\nwpEmojiSettingsSupports\n  * Duration\nsession\n  * Description\nWordPress sets this cookie when a user interacts with emojis on a WordPress site. It helps determine if the user's browser can display emojis properly.\n\n\n  * Cookie\nBCSessionID\n  * Duration\n1 year 1 month 4 days\n  * Description\nBlueconic sets this cookie as a unique identifier for the BlueConic profile.\n\n\n  * Cookie\n_octo\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nlogged_in\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\n__Secure-YEC\n  * Duration\npast\n  * Description\nYouTube sets this cookie to stores the user's video player preferences using embedded YouTube video\n\n\n  * Cookie\n__eoi\n  * Duration\n6 months\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTGCORS\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\nlogin-status-p\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nAWSALBTG\n  * Duration\n7 days\n  * Description\nNo description available.\n\n\n  * Cookie\ncsrf_token\n  * Duration\nsession\n  * Description\nNo description available.\n\n\n  * Cookie\ntoken_v2\n  * Duration\n1 day\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nD\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nPHPSESSID\n  * Duration\nsession\n  * Description\nThis cookie is native to PHP applications. The cookie stores and identifies a user's unique session ID to manage user sessions on the website. The cookie is a session cookie and will be deleted when all the browser windows are closed.\n\n\n  * Cookie\nVISITOR_PRIVACY_METADATA\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to store the user's cookie consent state for the current domain. \n\n\n  * Cookie\ncookietest\n  * Duration\nsession\n  * Description\nThe cookietest cookie is typically used to determine whether the user's browser accepts cookies, essential for website functionality and user experience.\n\n\n  * Cookie\n__Host-airtable-session\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\n__Host-airtable-session.sig\n  * Duration\n1 year\n  * Description\nThis cookie is used to enable us to integrate the services of Airtable.\n\n\n  * Cookie\nm\n  * Duration\n1 year 1 month 4 days\n  * Description\nStripe sets this cookie for fraud prevention purposes. It identifies the device used to access the website, allowing the website to be formatted accordingly.\n\n\n  * Cookie\nBIGipServer*\n  * Duration\nsession\n  * Description\nMarketo sets this cookie to collect information about the user's online activity and build a profile about their interests to provide advertisements relevant to the user. \n\n\n  * Cookie\n__cfruid\n  * Duration\nsession\n  * Description\nCloudflare sets this cookie to identify trusted web traffic.\n\n\n  * Cookie\n_GRECAPTCHA\n  * Duration\n6 months\n  * Description\nGoogle Recaptcha service sets this cookie to identify bots to protect the website against malicious spam attacks.\n\n\n  * Cookie\n__Secure-YNID\n  * Duration\n6 months\n  * Description\nGoogle cookie used to protect user security and prevent fraud, especially during the login process.\n\n\n  * Cookie\ncookieyes-consent\n  * Duration\n1 year\n  * Description\nCookieYes sets this cookie to remember users' consent preferences so that their preferences are respected on subsequent visits to this site. It does not collect or store any personal information about the site visitors.\n\n\nFunctional\nFunctional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.\n  * Cookie\nlidc\n  * Duration\n1 day\n  * Description\nLinkedIn sets the lidc cookie to facilitate data center selection.\n\n\n  * Cookie\nbrw\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nbrwConsent\n  * Duration\n5 minutes\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nWMF-Uniq\n  * Duration\n1 year\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nloom_anon_comment\n  * Duration\n1 year\n  * Description\nNo description available.\n\n\n  * Cookie\nloom_referral_video\n  * Duration\nsession\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nVISITOR_INFO1_LIVE\n  * Duration\n6 months\n  * Description\nA cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.\n\n\n  * Cookie\nyt-remote-connected-devices\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nytidb::LAST_RESULT_ENTRY_KEY\n  * Duration\nNever Expires\n  * Description\nThe cookie ytidb::LAST_RESULT_ENTRY_KEY is used by YouTube to store the last search result entry that was clicked by the user. This information is used to improve the user experience by providing more relevant search results in the future.\n\n\n  * Cookie\nyt-remote-device-id\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to store the user's video preferences using embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-name\n  * Duration\nsession\n  * Description\nThe yt-remote-session-name cookie is used by YouTube to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\nyt-remote-fast-check-period\n  * Duration\nsession\n  * Description\nThe yt-remote-fast-check-period cookie is used by YouTube to store the user's video player preferences for embedded YouTube videos.\n\n\n  * Cookie\nyt-remote-session-app\n  * Duration\nsession\n  * Description\nThe yt-remote-session-app cookie is used by YouTube to store user preferences and information about the interface of the embedded YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-available\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-available cookie is used to store the user's preferences regarding whether casting is available on their YouTube video player.\n\n\n  * Cookie\nyt-remote-cast-installed\n  * Duration\nsession\n  * Description\nThe yt-remote-cast-installed cookie is used to store the user's video player preferences using embedded YouTube video.\n\n\n  * Cookie\ncp_session\n  * Duration\n3 months\n  * Description\nCodepen sets this cookie for Help systems found in the website.\n\n\n  * Cookie\nloid\n  * Duration\n1 year 1 month 4 days\n  * Description\nThis cookie is set by the Reddit. The cookie enables the sharing of content from the website onto the social media platform.\n\n\nAnalytics\nAnalytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.\n  * Cookie\n__hstc\n  * Duration\n6 months\n  * Description\nHubspot set this main cookie for tracking visitors. It contains the domain, initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session).\n\n\n  * Cookie\nhubspotutk\n  * Duration\n6 months\n  * Description\nHubSpot sets this cookie to keep track of the visitors to the website. This cookie is passed to HubSpot on form submission and used when deduplicating contacts.\n\n\n  * Cookie\n_ga\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to calculate visitor, session and campaign data and track site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognise unique visitors.\n\n\n  * Cookie\n_ga_*\n  * Duration\n1 year 1 month 4 days\n  * Description\nGoogle Analytics sets this cookie to store and count page views.\n\n\n  * Cookie\n__Host-psifi.analyticsTrace\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n__Host-psifi.analyticsTraceV2\n  * Duration\n6 hours\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\n_gh_sess\n  * Duration\nsession\n  * Description\nGitHub sets this cookie for temporary application and framework state between pages like what step the user is on in a multiple step form.\n\n\n  * Cookie\nYSC\n  * Duration\nsession\n  * Description\nYSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.\n\n\n  * Cookie\najs_anonymous_id\n  * Duration\n1 year\n  * Description\nThis cookie is set by Segment to count the number of people who visit a certain site by tracking if they have visited before.\n\n\n  * Cookie\nvuid\n  * Duration\n1 year 1 month 4 days\n  * Description\nVimeo installs this cookie to collect tracking information by setting a unique ID to embed videos on the website. \n\n\nPerformance\nPerformance cookies are used to understand and analyse the key performance indexes of the website which helps in delivering a better user experience for the visitors.\n  * Cookie\nAWSALB\n  * Duration\n7 days\n  * Description\nAWSALB is an application load balancer cookie set by Amazon Web Services to map the session to the target.\n\n\n  * Cookie\nacq\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nacq.sig\n  * Duration\npast\n  * Description\nDescription is currently not available.\n\n\n  * Cookie\nptc\n  * Duration\n2 years\n  * Description\nNo description available.\n\n\nAdvertisement\nAdvertisement cookies are used to provide visitors with customised advertisements based on the pages you visited previously and to analyse the effectiveness of the ad campaigns.\n  * Cookie\nmuc_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to collect user behaviour and interaction data to optimize the website.\n\n\n  * Cookie\nguest_id_marketing\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\nguest_id_ads\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor.\n\n\n  * Cookie\npersonalization_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to integrate and share features for social media and also store information about how the user uses the website, for tracking and targeting.\n\n\n  * Cookie\nguest_id\n  * Duration\n1 year 1 month 4 days\n  * Description\nTwitter sets this cookie to identify and track the website visitor. It registers if a user is signed in to the Twitter platform and collects information about ad preferences.\n\n\n  * Cookie\nbcookie\n  * Duration\n1 year\n  * Description\nLinkedIn sets this cookie from LinkedIn share buttons and ad tags to recognize browser IDs.\n\n\n  * Cookie\n__Secure-ROLLOUT_TOKEN\n  * Duration\n6 months\n  * Description\nYouTube sets this cookie to manage feature rollout and experimentation. It helps Google control which new features or interface changes are shown to users as part of testing and staged rollouts, ensuring consistent experience for a given user during an experiment.\n\n\n  * Cookie\nyt.innertube::nextId\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nyt.innertube::requests\n  * Duration\nNever Expires\n  * Description\nYouTube sets this cookie to register a unique ID to store data on what videos from YouTube the user has seen.\n\n\n  * Cookie\nsession_tracker\n  * Duration\nsession\n  * Description\nThis cookie is set by the Reddit. This cookie is used to identify trusted web traffic. It also helps in adverstising on the website.\n\n\n  * Cookie\nedgebucket\n  * Duration\nsession\n  * Description\nReddit sets this cookie to save the information about a log-on Reddit user, for the purpose of advertisement recommendations and updating the content.\n\n\n  * Cookie\ndid\n  * Duration\n1 year\n  * Description\nArbor sets this cookie to show targeted ads to site visitors.This cookie expires after 2 months or 1 year.\n\n\nUncategorised\nOther uncategorised cookies are those that are being analysed and have not been classified into a category as yet.\nNo cookies to display.\nReject All Save My Preferences Accept All\nToggle Search[](https://towardsdatascience.com/)Toggle Mobile Navigation\n[](https://towardsdatascience.com/)\nPublish AI, ML & data-science insights to a global community of data professionals.\nSign in[Submit an Article](https://write.insightmediagroup.io)\n[Latest](https://towardsdatascience.com/latest/)[Editor's Picks](https://towardsdatascience.com/tag/editors-pick/)[Newsletter](https://towardsdatascience.com/tag/the-variable/)[ShipAI](https://towardsdatascience.com/shipai/)\n* * *\n[Write For TDS](https://towardsdatascience.com/submissions/)\n[LinkedIn](https://www.linkedin.com/company/towards-data-science/)[X](https://x.com/TDataScience)Toggle Search\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\n# Common Causes of Data Leakage and how to Spot Them\nLet's learn how to identify and deal with the common causes of data leakage in ML models\n[Ivo Bernardo](https://towardsdatascience.com/author/ivopbernardo/)\nMay 17, 20248 min read\n![Image by realaxer @Unsplash.com](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/05/0Oq_OdOVeEcDLA98V.jpg)\nImage by [realaxer](https://unsplash.com/pt-br/@realaxer) @Unsplash.com\nOne of a Data Scientist's worst nightmares is data leakage. And why is data leakage so harmful? **Because the ways your models may suffer from it are designed to convince you that your model is excellent and that you should be expecting awesome results in the future.**\nAs you may know, the primary goal of every machine learning model is to generalize the patterns it learns for the future data. As we can't really access future data (without making a time machine first), the best way to simulate this during model development is to set aside a test and a validation set to be used to assess model performance.\nDuring development, data scientists aim to improve the model's test and validation performance. If results are satisfactory, then data scientists assume that their models are ready for production. And that's why data leakage is so dangerous. As it's able to hide itself in seemingly innocent behaviors, it can lurk in the background, waiting for you to put that model into production and just find out that the performance in real life is way worse than the one on the test set.\nNormally, data leakage involves the process of polluting our train set with things that will end up violating one or more parameters of \"future dataset\" rule. And it's one of the most major causes of unsuccessful model deployments.\nLearn this step by step with the interactive [AI Engineer](https://roadmap.sh/ai-engineer), [AI and Data Scientist](https://roadmap.sh/ai-data-scientist) and [Machine Learning](https://roadmap.sh/machine-learning) roadmaps.\nIn this blog post, we'll discuss some of the most common data leakage sources and some tips on how to spot them!\nLet's dive in!\n* * *\n## Feature Leakage\nProbably the most famous data leakage source (and the easiest to spot, as well).\nFeature leakage happens when we have features that are directly related to the target often being a result of the target event. Normally, feature leakage happens because the feature value is updated in a point in time after the target event.\nLet's see some examples:\n  * 1) You are trying to predict loan default of a certain customer and one of your features is the number of outbound calls that the customer had in past 30 days. What you don't know is that in this fictional bank the customer only receives outbound calls if it has already entered into a default scenario.\n  * 2) You are trying to predict a certain disease of a patient and are using the number of times the patient went through a specific diagnostic test. However, you later find that this test is only prescribed to people that have a high likelihood of having the disease.\n  * 3) You are using a feature with the name days_finish_contract* as a feature to predict if a customer will churn or not.\n\n\n> *days after the last contract of the customer with a specific company finished (for example, in a telco business). If the customer does not renew, this is, indeed, the churn event.\nThese three examples also show different levels of feature leakage. For example, in 1) and 3), there is a direct correlation between target and features and it's very likely that 100% of the target will have these variables as non-null values. However, 2) is harder to spot, because other patients may have gone through the diagnostic test and didn't have the disease making this leakage source less obvious.\nOne way to spot feature leakage is via _feature importance_ data obtained in different models. **For me, what works very well is fitting an extremely shallow decision tree and checking if one of the features has an enormous difference, in terms of importance, compared to others.** When I find that a feature is overly indexed, those features are normally related to leakage problems.\nTo solve these problems, it's recommended that you look into how these features that have leakage were generated so that you can:\n  * Remove the feature if there's no other way to generate it.\n  * Change the feature so that no information from the future leaks into the target.\n\n\n* * *\n## Time Correlated Data using Random-Test Split\nFunny story - I've learned this the hard way. In the past, I've developed machine learning models to predict soccer games' results and ended up having a betting system that was completely flawed.\nProbably you've felt something along these lines before - have you ever trained a time-series model and had spectacular results on the test set?\nThat's quite common when you perform a **random train-test** split on your dataset when rows have a time-dependence. Even if you are not training a time series model, but your rows are time-dependent, you should always perform a continuous train-test split based on time and not a random train-test split.\nTime-dependent data is a tricky thing to model, particularly because covariates and data distribution shifts as time goes by. If you hint any portion of the new distributions to the train set, your model will be flawed.\nThe recommendation for time-dependent data is to perform assessments on a continuous cross-validation (CV) mechanism, similar to the one below:\n![Appropriate Train and Test for Time-Dependent Data - Image by Author](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/05/0OMpA6uChNhVl3lMp-1.png)\nAppropriate Train and Test for Time-Dependent Data - Image by Author\nSo, yeah.. never use random train-test split on time-dependent data!\n* * *\n## Hinting Something to the Test Set via Scaling and Preprocessing\nThis is a trickier one has even sometimes even experienced data scientists end up falling for it. When performing outlier analysis, scaling, missing value imputation, always make sure that you perform those analysis on the train set and after train-test splitting.\nSometimes people confuse this sentence with **applying** the same transformations to the test set - while that is completely true (your test set needs to mimic your training set's scale and not contain missing values), you shouldn't give any hint of the distribution of the test set to the train one.\nFor example, imagine you are applying a Standard Scaler (that uses a Z-Score with mean and standard deviation). You want this standard scaler to memorize the average and standard deviation of the **train set. After that set you will apply the same scaler with the fixed statistics from the training set to the test set.**\nTake another famous preprocessing step: removing outliers. Does it make sense to remove outliers from the test set? Well, if you know what will be an outlier in the future (remember that test sets are just really poor simulations of a future dataset where the model will be used on) then tell me please, because you have just invented a time machine!\nAs it's not possible to remove outliers in the future (of course, **you can remove obvious outliers from being scored by your model)** , you generally lack information about what a \"future\" outlier will look like. If you do remove outliers in the test set, you should expect a larger drift between the test set performance and real world deployment.\nTo avoid this type of leakage, perform train-test split before you do anything on the data.\n![A Data Scientist finding out their model is wrong in Production - Image by AI generated by Microsoft Design](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/05/0Hjly1RL2NEQ7f1R8-1.jpg)\nA Data Scientist finding out their model is wrong in Production - Image by AI generated by Microsoft Design\n* * *\n## Leakage from Data Generation and Sources\nThis one is trickier to spot. Feature leakage from data generation and/or data sources is normally tied with how data is collected. You probably won't have full control of it as a data scientist.\nLet's take the customer default example that we pointed out in the **Feature Leakage -** imagine you are building a predictive model that wants to find out if a customer will default in the next installment and you find out that the number of outbound calls to the customer is a great feature to predict this.\nYou speak with people who are actively doing these phone calls and you find out that the process is fair. They actually call riskier customers and it may make sense that you include this feature in the model. But, after sitting down with them, you find out that there are certain calls that happen after they are certain that the customer will default.\nWhat happens is that your IT systems only log defaults one day after they actually happened so some of these calls are actually calls to ask customer why they defaulted. If you use this feature (call is done on day _x_ , default is logged on day _x_ +1), you'll actually be adding leakage to your model's prediction as a feature is leaking information into the target.\nThis is the hardest leakage to spot as it requires that you deeply know how your features were generated and good data governance models. Nevertheless, using the technique we spoke about in the **Feature Leakage** section can be a quick and raw way to understand if you have obvious leakage from the generation and sourcing of your data.\n* * *\n## Feature Engineering\nAnother common way to generate data leakage is during the feature engineering process. Although this is just a subset of **Feature Leakage,** it's so common that I needed to point it out.\nOne common example is when creating moving averages in time-series. Often, people may confuse time intervals and add periods that you are supposed to predict on the average value. When overlooked, this will create an enormous distortion on the time series model.\nAnother example is when using features that were themselves generated by other machine learning models. Using these features is always risky as these models have uncertainty (and may have leakage) inside them. Building these features based on other models can have a high impact and \"seemingly\" create a much better model that loses its generalization power.\n## Conclusion\nAnd that's it! These are the most common data leakage problems that I've found in my career as a data scientist.\nIn a nutshell, data leakage is the silent killer of machine learning models. It's designed to make you feel that you have a great model but whose performance is highly influenced by leakage problems. Data leakage issues can be so bad that they can impact your model as soon as you get it into production. Identifying leakage as soon as possible will not only make your model more stable but also more accurate in the real world.\nDo you know any other data leakage causes that I didn't mention here? Point them out in the comments!\nAlso, feel free to check me out on my Youtube Channel:\n![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/05/0zRgw8KO3YXjxB7R5-1.jpeg)\nYou can subscribe to my channel \"[_The Data Journey_](https://www.youtube.com/channel/UCq-1TNG9csV4AVa0i6AU5rw)\" here. Or my [Udemy ](https://www.udemy.com/user/ivo-bernardo/)page here.\n## Register Now to Continue Reading\n### Unlock Towards Data Science with a Free Account\nAll articles on Towards Data Science are available to registered users. Create a free account today to access this article and thousands more.\nRegister for freeSign in to your account\n* * *\n![](https://assets.insightmediagroup.io/media/1787657081760_wqdt7l.jpeg)\nWritten By\n## [Ivo Bernardo](https://towardsdatascience.com/author/ivopbernardo/)\n[See all from Ivo Bernardo](https://towardsdatascience.com/author/ivopbernardo/)\n[Artificial Intelligence](https://towardsdatascience.com/tag/artificial-intelligence/)[Data Leakage](https://towardsdatascience.com/tag/data-leakage/)[Data Science](https://towardsdatascience.com/tag/data-science/)[Machine Learning](https://towardsdatascience.com/tag/machine-learning/)[Mlops](https://towardsdatascience.com/tag/mlops/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fcommon-causes-of-data-leakage-and-how-to-spot-them-17113406f9f8%2F&title=Common%20Causes%20of%20Data%20Leakage%20and%20how%20to%20Spot%20Them)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fcommon-causes-of-data-leakage-and-how-to-spot-them-17113406f9f8%2F&title=Common%20Causes%20of%20Data%20Leakage%20and%20how%20to%20Spot%20Them)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fcommon-causes-of-data-leakage-and-how-to-spot-them-17113406f9f8%2F&text=Common%20Causes%20of%20Data%20Leakage%20and%20how%20to%20Spot%20Them)\n\n\nTowards Data Science is a community publication. Submit your insights to reach our global audience and earn through the TDS Author Payment Program.\n[Write for TDS](https://towardsdatascience.com/submissions/)\n## Related Articles\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/12/0YS5ReQM3alWHcBtA-scaled.jpg)](https://towardsdatascience.com/ive-done-80-data-science-interviews-here-s-what-works-ae8053f79a6d/)\n## [I’ve Done 80+ Data Science Interviews – Here’s What Works](https://towardsdatascience.com/ive-done-80-data-science-interviews-here-s-what-works-ae8053f79a6d/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\n3 years of data science interview experience\n[Egor Howell](https://towardsdatascience.com/author/egorhowell/)\nDecember 24, 20246 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2025/07/AI-Interview.png)](https://towardsdatascience.com/rethinking-data-science-interviews-in-the-age-of-ai/)\n## [Rethinking Data Science Interviews in the Age of AI](https://towardsdatascience.com/rethinking-data-science-interviews-in-the-age-of-ai/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nHow AI is transforming data science interviews—and what hiring managers and candidates should do to adapt\n[Yu Dong](https://towardsdatascience.com/author/ydong029/)\nJuly 4, 202510 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/04/1kgRRf7Yk-luwF562ZeBomg-scaled.jpeg)](https://towardsdatascience.com/im-a-self-taught-data-scientist-here-are-my-3-suggestions-for-newcomers-5f5d54e597a8/)\n## [I'm a Self-Taught Data Scientist. Here Are My 3 Suggestions for Newcomers](https://towardsdatascience.com/im-a-self-taught-data-scientist-here-are-my-3-suggestions-for-newcomers-5f5d54e597a8/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nMake your learning journey more efficient.\n[Soner Yıldırım](https://towardsdatascience.com/author/sonery/)\nApril 13, 20225 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/02/1SXwc992YZAPIJ2cDjMK0cg.png)](https://towardsdatascience.com/dont-miss-out-on-pub-sub-5dbfa15cf3d0/)\n## [Don't Miss Out on Pub/Sub](https://towardsdatascience.com/dont-miss-out-on-pub-sub-5dbfa15cf3d0/)\n[Programming](https://towardsdatascience.com/category/programming/)\nA high-level overview of the Pub/Sub pattern and why you should be incorporating it into your projects.\n[Andrew Didinchuk](https://towardsdatascience.com/author/appliedarchitect/)\nFebruary 15, 20213 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/03/167CRN6X6iFmncMdzKlmGVQ.png)](https://towardsdatascience.com/understanding-morphological-image-processing-and-its-operations-7bcf1ed11756/)\n## [Understanding Morphological Image Processing and Its Operations](https://towardsdatascience.com/understanding-morphological-image-processing-and-its-operations-7bcf1ed11756/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nThis article illustrates Morphological Image Processing in more straightforward terms; readers can understand how Morphology works in...\n[Prateek Chhikara](https://towardsdatascience.com/author/prateekchhikara/)\nMarch 30, 20225 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/11/1o06jXpJ_dMBlIwnR1P7XwQ.png)](https://towardsdatascience.com/kickstart-your-data-science-journey-a-guide-for-aspiring-data-scientists-96e5072bd19a/)\n## [Kickstart Your Data Science Journey - A Guide for Aspiring Data Scientists](https://towardsdatascience.com/kickstart-your-data-science-journey-a-guide-for-aspiring-data-scientists-96e5072bd19a/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nKey Technical Skills You Need to Kick-start Your Career in Data Science\n[Saankhya Mondal](https://towardsdatascience.com/author/saankhya/)\nNovember 6, 202416 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/05/00dvQ_lMd_zi7SzrY-scaled.jpg)](https://towardsdatascience.com/data-science-for-the-heart-c654135ceee5/)\n## [Data Science for the Heart](https://towardsdatascience.com/data-science-for-the-heart-c654135ceee5/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nCardiovascular Disease Data Analysis and Predictive Modeling\n[Suleman Bazai](https://towardsdatascience.com/author/sulemanbazai/)\nMay 17, 202112 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/04/1XT_X3kjP7ixaj09HZgGgew-scaled.jpeg)](https://towardsdatascience.com/why-do-you-need-to-use-sql-grouping-sets-for-aggregating-data-3d172ff5c088/)\n## [Why Do You Need to Use SQL Grouping Sets for Aggregating Data?](https://towardsdatascience.com/why-do-you-need-to-use-sql-grouping-sets-for-aggregating-data-3d172ff5c088/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nEfficiency, readability, and scalability\n[Soner Yıldırım](https://towardsdatascience.com/author/sonery/)\nApril 20, 20233 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/09/0mKg_KUbdKyioc2BE-scaled.jpg)](https://towardsdatascience.com/artificial-intelligence-is-transforming-modern-education-d95bf8d19acd/)\n## [Artificial Intelligence is Transforming Modern Education](https://towardsdatascience.com/artificial-intelligence-is-transforming-modern-education-d95bf8d19acd/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nA commentary piece on how AI is being used in today's classrooms as well as discussion on the path forward.\n[Sanjay Adhikesaven](https://towardsdatascience.com/author/sanjay.adhikesaven/)\nSeptember 11, 202210 min read\n\n\n  * [YouTube](https://www.youtube.com/c/TowardsDataScience)\n  * [X](https://x.com/TDataScience)\n  * [LinkedIn](https://www.linkedin.com/company/towards-data-science/)\n  * [Threads](https://www.threads.net/@towardsdatascience)\n  * [Bluesky](https://bsky.app/profile/towardsdatascience.com)\n\n\n[](https://towardsdatascience.com/)\nYour home for data science and AI. The world's leading publication for data science, data analytics, data engineering, machine learning, and artificial intelligence professionals.\nSubscribe to Our Newsletter[Write For TDS](https://towardsdatascience.com/submissions/)•[About](https://towardsdatascience.com/about-towards-data-science-d691af11cc2f/)•[Advertise](https://contact.towardsdatascience.com/advertise-with-towards-data-science)•[Privacy Policy](https://towardsdatascience.com/privacy-policy/)•[Terms of Use](https://towardsdatascience.com/website-terms-of-use/)\n© Insight Media Group, LLC 2026•[The New Stack](https://thenewstack.io)•[roadmap.sh](https://roadmap.sh)•[Creator Network](https://insightmediagroup.io/creator-network)\n####  Recommended Articles \nClose\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607686/image?etag=1782161464448&width=500&height=500) How Relevance Models Foreshadowed Transformers for NLP ](https://towardsdatascience.com/how-relevance-models-foreshadowed-transformers-for-nlp/ \"How Relevance Models Foreshadowed Transformers for NLP\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607639/image?etag=1781250125848&width=500&height=500) Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1 ](https://towardsdatascience.com/javascript-fatigue-you-dont-need-js-to-build-chatgpt/ \"Javascript Fatigue: HTMX Is All You Need to Build ChatGPT — Part 1\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/607930/image?etag=1782124566054&width=500&height=500) The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs ](https://towardsdatascience.com/subset-sum-problem-solved-in-linear-time-for-dense-enough-inputs/ \"The Subset Sum Problem Solved in Linear Time for Dense Enough Inputs\")\n  * [ ![](https://h030.towardsdatascience.com/rest/v2/contentStores/d7d3a4ab-7caf-4383-bbd2-fbf7fb4f1787/items/3660/image?etag=1780176246070&width=500&height=500) Does Your Company Have a Data Strategy? ](https://towardsdatascience.com/does-your-company-have-a-data-strategy-e8944dbec4ae/ \"Does Your Company Have a Data Strategy?\")\n\n\n",
  "body_base_path": "attachments/9e240e96b7df/pages/",
  "body_markdown_path": "attachments/9e240e96b7df/pages/archived-body.md",
  "local_html": "attachments/9e240e96b7df/pages/archived-body.html",
  "body_source": "prior_capture"
}