{
  "source_file": "0930",
  "source_platform": "Medium",
  "author": "John Leung",
  "title_listed": "Monitoring Machine Learning Models in Production: Why and How?",
  "keywords": "",
  "domain": "机器学习",
  "content_type": "深度技术解析",
  "is_paid_flag": "否",
  "url": "https://towardsdatascience.com/monitoring-machine-learning-models-in-production-why-and-how-13d07a5ff0c6/",
  "publish_date": "2023-09-06",
  "corpus_stage": "",
  "notes": "",
  "id": "c5ddcb7e2cdc",
  "collected_at": "2026-10-02T04:36:46",
  "title": "Monitoring Machine Learning Models in Production: Why and How? | 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# Monitoring Machine Learning Models in Production: Why and How?\nHow our model is impacted in the evolving world? An analysis focusing on drift examples, and implementing Python-based monitoring...\n[John Leung](https://towardsdatascience.com/author/johnleungtj/)\nSeptember 5, 202312 min read\n### How is our model impacted in the evolving world? An analysis focusing on drift examples, and implementing Python-based monitoring strategies\nMachine Learning (ML) model development often takes time and requires technical expertise. As data science enthusiasts, when we acquire a dataset to explore and analyze, we eagerly train and validate it using diverse [state-of-the-art models](https://medium.com/geekculture/whats-the-public-sentiment-under-inflationary-economic-environment-5edc899efa29) or employing [data-centric strategies](https://medium.com/mlearning-ai/how-to-apply-data-centric-ai-mindset-to-text-classification-problems-b41656c70c16). It feels incredibly fulfilling when we optimize the model's performance as if all the tasks have been accomplished.\nHowever, after deploying the model to production, there are plenty of reasons that contribute to lower model performance or degradation.\n![Photo by Adrien Delforge on Unsplash](../images/000.jpg)\nPhoto by [Adrien Delforge](https://unsplash.com/@adriendlf?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)\n**#1 The training data is generated through simulation**\nLearn this step by step with the interactive [AI Engineer](https://roadmap.sh/ai-engineer), [Data Analyst](https://roadmap.sh/data-analyst) and [Machine Learning](https://roadmap.sh/machine-learning) roadmaps.\nData scientists often [face limitations](https://www.cio.com/article/465251/how-can-cios-protect-personal-identifiable-information-pii-for-a-new-class-of-data-consumers.html) in accessing the production data, which results in training the model using simulated or sample data instead. While data engineers bear the responsibility of ensuring the representativeness of the training data in terms of scale and complexity, the training data still deviates to some extent from the production data. There is also a risk of systematic flaws in upstream data processing, such as data collection and labeling. These factors can impact the extraction of additional useful input features or hinder the model's ability to generalize well.\n> **Example:** Investor data in the financial industry or patient information in the healthcare industry is often simulated due to security and privacy concerns.\n**#2 The new production data exhibits a new data distribution**\nOver time, the characteristics of input features can also change, such as shifts in age groups, income ranges, or other customer demographics. The data source itself may even be completely replaced due to various cases. During the model development process, optimization relies on learning and capturing patterns from the majority group within the training data. However, as time progresses, the previous majority may transition into the minority in the production data, rendering the original static model inadequate for meeting the most recent production needs.\n> **Example:** The model is well trained initially using customer data in Asian regions. Recently since the business expands into the United States, the same model directly makes prediction based on the input features which have exhibited variations.\n![Data drift \\(Image by author\\)](../images/001.png)\nData drift (Image by author)\n**#3 The patterns that we predict are evolving**\nApart from shifts in the distribution of input features, the [relationship between the features and the target variable](https://en.wikipedia.org/wiki/Concept_drift) can also change in the evolving environment. These changes can occur in unexpected ways over time, rendering the original model progressively ineffective.\n  * Sudden concept change\n\n\nThese changes can occur abruptly, sometimes within a few weeks, due to unforeseen circumstances.\n> **Example:** The surge in demand for virtual meeting services during public COVID-19 lockdowns.\n  * Gradual concept change\n\n\nThis type of change takes longer to manifest and is often a natural progression.\n> **Example:** The gradual increase in the price of dairy products due to long-term inflation.\n  * Recurrent concept change\n\n\nThese changes can happen periodically, often during specific times of the year.\n> **Example:** The rapid growth in e-commerce sales during various special days like Black Friday and the Saturday before Christmas.\n![Concept drift \\(Image by author\\)](../images/002.png)\nConcept drift (Image by author)\n* * *\n### Model development is only a tiny part of a production-ready ML system\nMany companies emphasize data-driven decision-making through the use of ML applications. Imagine that your ML models are utilized in critical applications, such as medical diagnosis, to support healthcare professionals in identifying diseases and conditions. Any model degradation means impacting the accuracy of diagnoses, potentially resulting in incorrect treatment plans and compromised patient outcomes. There are tons of cases with high importance in the real world, thus it becomes imperative to implement objective and continuous monitoring to detect any possible shifts.\nIn the following sections, we will delve into various layers of monitoring and provide illustrative Python code examples to demonstrate their implementation.\n![Photo by Nathy dog on Unsplash](../images/003.jpg)\nPhoto by [Nathy dog](https://unsplash.com/@nathdah?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)\n### 1 Monitor the model performance metrics\nTo detect any sign of model degradation, one of the direct and effective ways is to keep track of the performance metrics over time.\n  * [Performance metrics for regression model](https://towardsdatascience.com/what-are-the-best-metrics-to-evaluate-your-regression-model-418ca481755b): R-squared, Root mean squared error (RMSE), and mean absolute error (MAE)\n  * [Performance metrics for classification model](https://towardsdatascience.com/the-5-classification-evaluation-metrics-you-must-know-aa97784ff226): Precision, recall, and F1-score\n\n\nThese performance metrics collected from the initial deployment serve as benchmarks for ongoing monitoring and evaluation. Periodically reassessing them is crucial whenever a new batch of ground truth data is collected, such as upon completion of a marketing campaign. If the error metrics rise above a predefined threshold, or if the metrics such as R-squared fall below the threshold, it is necessary to consider re-executing the data engineering process and retraining the model.\nWhile this monitoring approach provides valuable insights into any drifts, it tends to lag. We can take a more proactive approach to monitor the latest input data.\n### 2 Detect the changes in data distribution\nInstead of waiting for sufficient input data for reliable evaluation of model performance, we can apply statistical methods for comparing the data distributions of two datasets. In our case, we can determine if the distribution of the training dataset is the same as that of the latest production dataset. If it is not statistically confident that two distributions are the same, it suggests a drift in the model. This is as a proxy for performance changes.\n  * Kolmogorov-Smirnov Test ([K-S Test](https://towardsdatascience.com/kolmogorov-smirnov-test-84c92fb4158d)): nonparametric test (i.e. with no assumption on the underlying data distribution) **for numeric features** , it is more sensitive near the center of the distribution than at the tails.\n\n\n> **Interpretation:** When p-value < 0.05, an alert indicating the presence of a drift is triggered.\n  * Population Stability Index ([PSI](https://towardsdatascience.com/psi-and-csi-top-2-model-monitoring-metrics-924a2540bed8)): A statistical test that can be applied to **both numeric and categorical variables**. It is a metric that shows how each variable has diverged independently from the baseline values. It is sometimes called the Characteristic Stability Index (CSI) when evaluating the distribution of features rather than target variables.\n\n\n> **Interpretation:** A value 0~0.1 means no significant distribution change; a value 0.1~0.2 considered a moderate distribution change; and a value larger than 0.2 interpreted as a significant distribution change.\nOther famous statistical tests include [Kullback-Leibler divergence](https://towardsdatascience.com/understanding-kl-divergence-f3ddc8dff254), [Jensen-Shannon divergence](https://towardsdatascience.com/how-to-understand-and-use-jensen-shannon-divergence-b10e11b03fd6), and [Wasserstein distance](https://towardsdatascience.com/the-gromov-wasserstein-distance-835c39d4751d).\n### 3 Monitor drift using a sliding window approach\nAny delay in detecting data or pattern drifts results in a time gap, potentially leading to discrepancies between the ground truth and model predictions. To bridge the gap, are there any further advancements available? One promising idea is leveraging streaming data instead of batch data.\nThe Adaptive Windowing ([ADWIN](https://scikit-multiflow.readthedocs.io/en/stable/api/generated/skmultiflow.drift_detection.ADWIN.html)) algorithm utilizes a sliding window approach to effectively detect concept drift. Unlike traditional fixed-size windows, ADWIN decides the size of the window by cutting the statistics window at different points. Whenever newly arriving data comes, ADWIN analyses the statistics and identifies the point at which two sub-windows demonstrate notable differences in their means.\n> **Interpretation:** When the absolute difference between the two means exceeds a pre-defined threshold, an alert indicating the presence of a drift is triggered.\n* * *\n### **Example Walkthrough**\nLet's explore an example that demonstrates the implementation of the above monitoring strategies.\nWe will utilize a [dataset](https://www.kaggle.com/datasets/parisrohan/credit-score-classification?datasetId=2289007&sortBy=voteCount&select=train.csv) obtained from Kaggle. The dataset comprises 100k records, encompassing 28 features **** that describe the customer demographics and their credit-related history.\nOur objective is to segregate customers in a global financial company into credit score brackets. The target variable is **Credit_Score** , a categorical measure classified as 'Poor', 'Standard', and 'Good'.\nExamples of features include:\n  * _Occupation_ : Occupation of the customers (e.g. scientist, teacher, engineer, etc.)\n  * _Annual _Income_ : Annual income of the customers\n  * _Credit_History _Age_ : The age of customers' credit history\n  * _Payment _Behaviour_ : 6 groups of payment behaviors based on spending frequency (low/ high) and payment amount (small/ medium/ large)\n\n\n![Photo by CardMapr.nl on Unsplash](../images/004.jpg)\nPhoto by [CardMapr.nl](https://unsplash.com/@cardmapr?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)\n**Model performance metrics**\nLet's start by applying data cleansing and transformation techniques, including but not limited to:\n  * Correcting/ Removing records with missing values or incorrect data (e.g. age < 0), or duplicates\n  * Detecting and handling data outliers\n  * Performing min-max scaling on numeric variables\n  * Applying label encoding on categorical variables\n\n\n_This part requires in-depth exploratory data analysis. However, since the focus is on sharing the monitoring strategies, the transformations performed are not discussed in detail here._\nAfterward, we split the dataset and developed the advanced gradient boosting algorithm, [LightGBM](https://lightgbm.readthedocs.io/en/stable/).\npython\n\n```\nimport numpy as np\nimport pandas as pd\nfrom sklearn import metrics\nfrom sklearn.metrics import f1_score, precision_score, recall_score\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import LabelEncoder\nfrom lightgbm import LGBMClassifier\n\n# Convert target variable to numeric\ndf['Credit_Score'] = df['Credit_Score'].str.replace('Good', '3', n=-1)\ndf['Credit_Score'] = df['Credit_Score'].str.replace('Standard', '2', n=-1)\ndf['Credit_Score'] = df['Credit_Score'].str.replace('Poor', '1', n=-1)\ndf['Credit_Score'] = df[['Credit_Score']].apply(pd.to_numeric)\n\n# Split the dataset\nX=df.loc[:, df.columns != 'Credit_Score']\nY=df['Credit_Score']\nx_train, x_test, y_train, y_test = train_test_split(X, Y, test_size=0.25)\n\n# Train the LightGBM model\nlgbm = LGBMClassifier()\nlgbm.fit(x_train, y_train)\ny_pred = lgbm.predict(x_test)\n\n# Print performance metrics\nprint('F1 score: %.3f' % f1_score(y_test, y_pred, average='weighted'))\nprint('Precision: %.3f' % precision_score(y_test, y_pred, average='weighted'))\nprint('Recall: %.3f' % recall_score(y_test, y_pred, average='weighted'))\n```\n\nDuring our model development, we gathered several performance metrics, including an F1 score of 0.810, a precision score of 0.818, and a recall score of 0.807. Subsequent monitoring can be evaluated similarly. For instance, if the F1 score falls below 0.75, it serves as an alert, prompting us to take immediate action to mitigate the issue.\n**K-S Test**\nTo demonstrate how the K-S Test works, I have selected a numeric feature _Credit_History _Age_. We will examine the sensitivity of this statistical test by creating three distinct datasets: one with 1000 samples, another with 5000 samples, and a third with approximately 64000 samples, which corresponds to the total size of the cleaned training samples. Each data point within the _Credit_History _Age_ feature has been randomly picked from the training data and altered by a random floating-point number.\n![Data distributions of &#039;Credit_History_Age&#039; in original data and drifted data \\(Image by author\\)](../images/005.png)\nData distributions of 'Credit_History_Age' in original data and drifted data (Image by author)\nWe obtained the following results:\n  * For the dataset with 1000 samples, the p-value of the K-S Test is 0.093.\n  * For the dataset with 5000 samples, the p-value of the K-S Test is 0.002.\n  * For the dataset with around 64000 samples, the p-value of the K-S Test is 0.000.\n\n\nWhen examining the data drift scenario using 1000 samples, the p-value exceeded 0.05. Consequently, we can conclude that the two distributions remain similar. However, as the sample size increased to 5000 and beyond, the K-S Test exhibited exceptional performance, yielding p-values significantly lower than 0.05. This provides a clear indication of a data distribution drift, serving as a clear alert.\npython\n\n```\nfrom scipy import stats\n\n# Create new datasets with different no. of samples\noriginal_df = x_train[['Credit_History_Age', 'Payment_Behaviour']].reset_index(drop=True)\nnew_df = x_train[['Credit_History_Age', 'Payment_Behaviour']].reset_index(drop=True)\nnew_df1 = new_df.sample(n = 1000).reset_index(drop=True)\nnew_df2 = new_df.sample(n = 5000).reset_index(drop=True)\nnew_df3 = new_df.sample(n = len(x_train)).reset_index(drop=True)\n\n# Prepare drifted data for numeric feature\ndef drift_numeric_col(df, numeric_col, drift_range):\n    df[numeric_col] = df[numeric_col] + np.random.uniform(0, drift_range, size=(df.shape[0], ))\n\ndrift_numeric_col(new_df1, 'Credit_History_Age', 2)\ndrift_numeric_col(new_df2, 'Credit_History_Age', 2)\ndrift_numeric_col(new_df3, 'Credit_History_Age', 2)\n\n# K-S Test\ndef ks_test(original_df, new_df, numeric_col):\n    test = stats.ks_2samp(original_df[numeric_col], new_df[numeric_col])\n    print(\"Column : %s , p-value : %1.3f\" % (numeric_col, test[1]))\n\n# Conduct K-S Test for numeric feature\nks_test(original_df, new_df1, 'Credit_History_Age')\nks_test(original_df, new_df2, 'Credit_History_Age')\nks_test(original_df, new_df3, 'Credit_History_Age')\n```\n\n**PSI**\nIn addition to utilizing the K-S Test, we will also leverage the PSI (Population Stability Index) to evaluate the numeric feature _Credit_History _Age_ and assess the categorical feature _Payment _Behaviour_. To represent the drift effect, we have randomly replaced 80% of the data of the feature _Payment _Behaviour_ with specific label values.\npython\n\n```\n# Prepare drifted data for categorical column\ndef drift_cat_col(df, cat_col, drift_ratio):\n    no_of_drift = round(len(df)*drift_ratio)\n    random_numbers = [random.randint(0, 1) for _ in range(no_of_drift)]\n    indices = random.sample(range(len(df[cat_col])), no_of_drift)\n    df.loc[indices, cat_col] = random_numbers\n\ndrift_cat_col(new_df1, 'Payment_Behaviour', 0.8)\ndrift_cat_col(new_df2, 'Payment_Behaviour', 0.8)\ndrift_cat_col(new_df3, 'Payment_Behaviour', 0.8)\n```\n\n![Data distributions of &#039;Payment_Behaviour&#039; in original data and drifted data \\(Image by author\\)](../images/006.png)\nData distributions of 'Payment_Behaviour' in original data and drifted data (Image by author)\n  * Numeric feature _Credit_History _Age_\n\n\nWith a sample size of 1000, the PSI value is 0.023.\nWith a sample size of 5000, the PSI value is 0.015.\nWith a sample size of approximately 64000, the PSI value is 0.021.\n  * Categorical feature _Payment _Behaviour_\n\n\nWith a sample size of 1000, the PSI value is 0.108.\nWith a sample size of 5000, the PSI value is 0.111.\nWith a sample size of approximately 64000, the PSI value is 0.112.\nAll the PSI values for the _Credit_History _Age_ feature are significantly lower than 0.1, indicating no significant distribution change. By comparing these results with those obtained from the K-S Test, we observe that the K-S Test exhibits greater sensitivity in detecting distribution changes compared to PSI.\nOn the other hand, the PSI values for the _Payment _Behaviour_ feature are around 0.11, signifying a moderate distribution change. Interestingly, the three PSI values remain relatively consistent, implying that PSI's effectiveness is less dependent on sample sizes. Besides, PSI has the flexibility to monitor across various feature types, positioning it still a valuable approach for drift detection.\nBelow is the implementation code of PSI:\npython\n\n```\ndef psi(data_base, data_new, num_bins = 10):\n    # Sort the data\n    data_base = sorted(data_base)\n    data_new = sorted(data_new)\n\n    # Prepare the bins\n    min_val = min(data_base[0], data_new[0])\n    max_val = max(data_base[-1], data_new[-1])\n    bins = [min_val + (max_val - min_val)*(i)/num_bins for i in range(num_bins+1)]\n    bins[0] = min_val - 0.0001\n    bins[-1] = max_val + 0.0001\n\n    # Bucketize the baseline data and count the samples\n    bins_base = pd.cut(data_base, bins = bins, labels = range(1,num_bins+1))\n    df_base = pd.DataFrame({'base': data_base, 'bin': bins_base})\n    grp_base = df_base.groupby('bin').count()\n    grp_base['percent_base'] = grp_base['base'] / grp_base['base'].sum() \n\n    # Bucketize the new data and count the samples\n    bins_new = pd.cut(data_new, bins = bins, labels = range(1,num_bins+1))\n    df_new = pd.DataFrame({'new': data_new, 'bin': bins_new})\n    grp_new = df_new.groupby('bin').count()\n    grp_new['percent_new'] = grp_new['new'] / grp_new['new'].sum()\n\n    # Compare the bins\n    psi_df = grp_base.join(grp_new, on = \"bin\", how = \"inner\")\n\n    # Calculate the PSI\n    psi_df['percent_base'] = psi_df['percent_base'].replace(0, 0.0001)\n    psi_df['percent_new'] = psi_df['percent_new'].replace(0, 0.0001)\n    psi_df['psi'] = (psi_df['percent_base'] - psi_df['percent_new']) * np.log(psi_df['percent_base'] / psi_df['percent_new'])\n\n    # Return the total PSI value\n    return np.sum(psi_df['psi'].values)\n\n# Conduct K-S Test for numeric feature\npsi(original_df['Credit_History_Age'], new_df1['Credit_History_Age'])\npsi(original_df['Credit_History_Age'], new_df2['Credit_History_Age'])\npsi(original_df['Credit_History_Age'], new_df3['Credit_History_Age'])\n\n# Conduct K-S Test for categorical feature\npsi(original_df['Payment_Behaviour'], new_df1['Payment_Behaviour'])\npsi(original_df['Payment_Behaviour'], new_df2['Payment_Behaviour'])\npsi(original_df['Payment_Behaviour'], new_df3['Payment_Behaviour'])\n```\n\n**ADWIN algorithm**\nLastly, we test the power of ADWIN in detecting the change in the numeric feature _Credit_History _Age_. The [data stream](https://en.wikipedia.org/wiki/Streaming_data) consists of the training data, followed by the drifted data. We expect that the algorithm will promptly identify the drift shortly after examining the entirety of the original data.\nTo visually represent the situation, a scatter plot is created to showcase the final 500 points of the original data in blue, followed by the initial 500 points of the drifted data, depicted in green. The drifted data exhibits a slightly higher average value.\n![Scatter plot \\(Image by author\\)](../images/007.png)\nScatter plot (Image by author)\nBy continuously adding stream elements, ADWIN identifies the change at index 64457, which is the 637th data point within the drifted data. In comparison, the K-S Test and PSI necessitate a larger number of data points to conclude the presence of a drift confidently. The better performance of ADWIN is a testament to its capability to monitor diverse features at speed and ease.\nBelow is the implementation code of ADWIN:\npython\n\n```\nfrom skmultiflow.drift_detection import ADWIN\n\nadwin = ADWIN()\ndata_stream=[]\ndata_stream = np.concatenate((original_df['Credit_History_Age'],new_df3['Credit_History_Age']))\n\n# Add stream elements to ADWIN and verify if drift occurred\nfor i in range(len(data_stream)):\n  adwin.add_element(data_stream[i])\n  if adwin.detected_change():\n  print('Change detected at index {}'.format(i))\n  adwin.reset()\n```\n\n### Wrapping it up\nWe've delved into the crucial concepts of data drift and model drift, which can lead to model decay in production. We can proactively monitor and detect drift conditions using model performance metrics, statistical tests, and adaptive windowing techniques. Unlike participating in a one-time Kaggle competition, building a production-ready ML system is an iterative journey. It requires a mindset shift towards integrating comprehensive model monitoring to ensure a robust and consistently high-performance serving space.\n* * *\n### Before you go\nIf you enjoy this reading, I invite you to **** follow [my Medium page](https://medium.com/@johnleungTJ). By doing so, you can stay updated with exciting content related to data science side projects, Machine Learning Operations (MLOps) demonstrations, and project management methodologies.\n> [**Optimizing Your Strategies with Approaches Beyond A/B Testing**](https://towardsdatascience.com/optimizing-your-strategies-with-approaches-beyond-a-b-testing-bf11508f8930)\n> [**How to Apply Data-centric AI Mindset to Text Classification Problems?**](https://medium.com/mlearning-ai/how-to-apply-data-centric-ai-mindset-to-text-classification-problems-b41656c70c16)\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-4766f66da8cde6940868.jpeg)\nWritten By\n## [John Leung](https://towardsdatascience.com/author/johnleungtj/)\n[See all from John Leung](https://towardsdatascience.com/author/johnleungtj/)\n[Artificial Intelligence](https://towardsdatascience.com/tag/artificial-intelligence/)[Machine Learning](https://towardsdatascience.com/tag/machine-learning/)[Mlops](https://towardsdatascience.com/tag/mlops/)[Python](https://towardsdatascience.com/tag/python/)[Statistics](https://towardsdatascience.com/tag/statistics/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fmonitoring-machine-learning-models-in-production-why-and-how-13d07a5ff0c6%2F&title=Monitoring%20Machine%20Learning%20Models%20in%20Production%3A%20Why%20and%20How%3F)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fmonitoring-machine-learning-models-in-production-why-and-how-13d07a5ff0c6%2F&title=Monitoring%20Machine%20Learning%20Models%20in%20Production%3A%20Why%20and%20How%3F)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fmonitoring-machine-learning-models-in-production-why-and-how-13d07a5ff0c6%2F&text=Monitoring%20Machine%20Learning%20Models%20in%20Production%3A%20Why%20and%20How%3F)\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/008.jpeg)](https://towardsdatascience.com/text-extraction-using-regular-expression-python-186369add656/)\n## [Text Extraction using Regular Expression (Python)](https://towardsdatascience.com/text-extraction-using-regular-expression-python-186369add656/)\n[Programming](https://towardsdatascience.com/category/programming/)\nAn example of extracting text with keywords with Regular Expression.\n[KahEm Chu](https://towardsdatascience.com/author/kahemchu/)\nApril 10, 20215 min read\n  * [![](../images/009.jpg)](https://towardsdatascience.com/building-your-first-desktop-application-using-pyside6-a-data-scientist-edition-e2275cf0c977/)\n## [Building Your First Desktop Application using PySide6 [A Data Scientist Edition]](https://towardsdatascience.com/building-your-first-desktop-application-using-pyside6-a-data-scientist-edition-e2275cf0c977/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nSurprise, surprise. It's not as hard as I thought it would be.\n[Arunn Thevapalan](https://towardsdatascience.com/author/arunnthevapalan/)\nMarch 16, 202414 min read\n  * [![](../images/010.jpg)](https://towardsdatascience.com/make-python-faster-by-caching-functions-memoization-4fca250ab5f6/)\n## [Make Python Faster by Caching Functions: Memoization](https://towardsdatascience.com/make-python-faster-by-caching-functions-memoization-4fca250ab5f6/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nThe article discusses memoization using the Python standard library. The functools.lru_cache decorator makes this so simple!\n[Marcin Kozak](https://towardsdatascience.com/author/nyggus/)\nNovember 11, 202312 min read\n  * [![](../images/011.jpeg)](https://towardsdatascience.com/weekly-review-of-reinforcement-learning-papers-9-d0f7eff9eae2/)\n## [Weekly review of Reinforcement Learning papers #9](https://towardsdatascience.com/weekly-review-of-reinforcement-learning-papers-9-d0f7eff9eae2/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nEvery Monday, I present 4 publications from my research area. Let's discuss them! [← Previous...\n[Quentin Gallouédec](https://towardsdatascience.com/author/qgallouedec/)\nMay 17, 20215 min read\n  * [![](../images/012.jpeg)](https://towardsdatascience.com/using-make-for-data-science-projects-changed-my-life-23de1597e2e/)\n## [Using Make for Data Science Projects Changed My Life](https://towardsdatascience.com/using-make-for-data-science-projects-changed-my-life-23de1597e2e/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nThe bedrock utility helps keep code modular and levels up your iteration speed\n[Sean Easter](https://towardsdatascience.com/author/seaneaster/)\nMarch 1, 202211 min read\n  * [![](../images/013.jpg)](https://towardsdatascience.com/why-is-it-important-to-constantly-monitor-machine-learning-and-deep-learning-models-after-4136f6067547/)\n## [Why is it Important to Constantly Monitor Machine Learning and Deep Learning Models after...](https://towardsdatascience.com/why-is-it-important-to-constantly-monitor-machine-learning-and-deep-learning-models-after-4136f6067547/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nUnderstanding the importance of monitoring the ML and deep learning models after production can have a significant impact that these models...\n[Suhas Maddali](https://towardsdatascience.com/author/suhas-maddali007/)\nJune 28, 20226 min read\n  * [![](../images/014.jpg)](https://towardsdatascience.com/automating-the-setup-of-my-data-science-projects-656bb5c9ff5e/)\n## [Automating the Setup of my Data Science Projects](https://towardsdatascience.com/automating-the-setup-of-my-data-science-projects-656bb5c9ff5e/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nUsing Python to automate the process of setting up new project directories and making the first commit to a new repository in Github\n[Jack Leitch](https://towardsdatascience.com/author/jackmleitch/)\nDecember 21, 20204 min read\n  * [![](../images/015.jpeg)](https://towardsdatascience.com/the-top-three-lessons-learned-building-more-than-1-000-machine-learning-models-3fe188fdb4dd/)\n## [The Top Three Lessons Learned Building More Than 1,000 Machine Learning Models](https://towardsdatascience.com/the-top-three-lessons-learned-building-more-than-1-000-machine-learning-models-3fe188fdb4dd/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nAs someone who has overseen and created thousands of machine learning models, I want to share some of the most important insights learned.\n[Dr. Xuxu Wang](https://towardsdatascience.com/author/xuxu_wang/)\nJuly 21, 20205 min read\n  * [![](../images/016.jpg)](https://towardsdatascience.com/should-i-really-eat-that-mushroom-9edeaa69d934/)\n## [Should I Really Eat That Mushroom?](https://towardsdatascience.com/should-i-really-eat-that-mushroom-9edeaa69d934/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nClassifying edible and poisonous mushrooms with CatBoost gradient boosted decision trees\n[Caroline Arnold](https://towardsdatascience.com/author/caroline.arnold_63207/)\nAugust 17, 20235 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": "Monitoring Machine Learning Models in Production: Why and How? | Towards Data Science",
    "description": "How our model is impacted in the evolving world? An analysis focusing on drift examples, and implementing Python-based monitoring...",
    "keywords": null,
    "author": "John Leung",
    "og:locale": "en_US",
    "og:type": "article",
    "og:title": "Monitoring Machine Learning Models in Production: Why and How?",
    "og:description": "How our model is impacted in the evolving world? An analysis focusing on drift examples, and implementing Python-based monitoring...",
    "og:url": "https://towardsdatascience.com/monitoring-machine-learning-models-in-production-why-and-how-13d07a5ff0c6/",
    "og:site_name": "Towards Data Science",
    "og:image": "https://assets.insightmediagroup.io/media/wp-content/uploads/2023/09/00bV_DzPbXJsjS1sE-scaled.jpg",
    "og:image:width": "2560",
    "og:image:height": "1440",
    "og:image:type": "image/jpeg",
    "twitter:card": "summary_large_image",
    "twitter:site": "@TDataScience",
    "twitter:creator": "@TDataScience",
    "twitter:label1": "Written by",
    "twitter:data1": "John Leung",
    "twitter:label2": "Est. reading time",
    "twitter:data2": "12 min read",
    "article:published_time": "2023-09-05T18:21:18.000Z",
    "article:modified_time": "2023-09-05T18:21:18.000Z",
    "article:author": "https://towardsdatascience.com/author/johnleungtj/"
  },
  "paywall": {
    "listed_paid": false,
    "detected": false,
    "marker": "",
    "public_only": false,
    "policy": "付费/会员内容只保留页面公开可见部分，不绕过付费墙"
  },
  "crawl": {
    "success": true,
    "status_code": 202,
    "error": ""
  },
  "code_blocks": [
    {
      "language": "txt",
      "file": "attachments/c5ddcb7e2cdc/code/block_000.txt",
      "chars": 1108
    },
    {
      "language": "txt",
      "file": "attachments/c5ddcb7e2cdc/code/block_001.txt",
      "chars": 1177
    },
    {
      "language": "txt",
      "file": "attachments/c5ddcb7e2cdc/code/block_002.txt",
      "chars": 468
    },
    {
      "language": "txt",
      "file": "attachments/c5ddcb7e2cdc/code/block_003.txt",
      "chars": 1963
    },
    {
      "language": "txt",
      "file": "attachments/c5ddcb7e2cdc/code/block_004.txt",
      "chars": 400
    }
  ],
  "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:56:54Z"
    },
    {
      "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:58:21Z"
    },
    {
      "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:58:21Z"
    },
    {
      "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:58:21Z"
    }
  ],
  "audio": [],
  "videos": [
    {
      "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/johnleungtj/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/what-are-the-best-metrics-to-evaluate-your-regression-model-418ca481755b"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/the-5-classification-evaluation-metrics-you-must-know-aa97784ff226"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/kolmogorov-smirnov-test-84c92fb4158d"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/psi-and-csi-top-2-model-monitoring-metrics-924a2540bed8"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/understanding-kl-divergence-f3ddc8dff254"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/how-to-understand-and-use-jensen-shannon-divergence-b10e11b03fd6"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/the-gromov-wasserstein-distance-835c39d4751d"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/optimizing-your-strategies-with-approaches-beyond-a-b-testing-bf11508f8930"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/artificial-intelligence/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/machine-learning/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/mlops/"
    },
    {
      "type": "internal",
      "href": "https://towardsdatascience.com/tag/python/"
    },
    {
      "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://medium.com/geekculture/whats-the-public-sentiment-under-inflationary-economic-environment-5edc899efa29"
    },
    {
      "type": "external",
      "href": "https://medium.com/mlearning-ai/how-to-apply-data-centric-ai-mindset-to-text-classification-problems-b41656c70c16"
    },
    {
      "type": "external",
      "href": "https://unsplash.com/@adriendlf"
    },
    {
      "type": "external",
      "href": "https://unsplash.com"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/ai-engineer"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/data-analyst"
    },
    {
      "type": "external",
      "href": "https://roadmap.sh/machine-learning"
    },
    {
      "type": "external",
      "href": "https://www.cio.com/article/465251/how-can-cios-protect-personal-identifiable-information-pii-for-a-new-class-of-data-consumers.html"
    },
    {
      "type": "external",
      "href": "https://en.wikipedia.org/wiki/Concept_drift"
    },
    {
      "type": "external",
      "href": "https://unsplash.com/@nathdah"
    },
    {
      "type": "external",
      "href": "https://scikit-multiflow.readthedocs.io/en/stable/api/generated/skmultiflow.drift_detection.ADWIN.html"
    },
    {
      "type": "external",
      "href": "https://www.kaggle.com/datasets/parisrohan/credit-score-classification?datasetId=2289007&select=train.csv&sortBy=voteCount"
    },
    {
      "type": "external",
      "href": "https://unsplash.com/@cardmapr"
    },
    {
      "type": "external",
      "href": "https://lightgbm.readthedocs.io/en/stable/"
    },
    {
      "type": "external",
      "href": "https://en.wikipedia.org/wiki/Streaming_data"
    },
    {
      "type": "external",
      "href": "https://medium.com/@johnleungTJ"
    },
    {
      "type": "external",
      "href": "https://www.facebook.com/sharer/sharer.php?title=Monitoring+Machine+Learning+Models+in+Production%3A+Why+and+How%3F&u=https%3A%2F%2Ftowardsdatascience.com%2Fmonitoring-machine-learning-models-in-production-why-and-how-13d07a5ff0c6%2F"
    }
  ],
  "repair_version": 2,
  "repaired_at": "2026-10-20T17:29:27Z",
  "source_url": "https://towardsdatascience.com/monitoring-machine-learning-models-in-production-why-and-how-13d07a5ff0c6/",
  "delivery_status": "unverified",
  "discovery_status": "http_403",
  "missing_reason": "源页面未重新核验:http_403；已按保留正文补采图片",
  "repair_error": "",
  "actual_video_files": [],
  "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# Monitoring Machine Learning Models in Production: Why and How?\nHow our model is impacted in the evolving world? An analysis focusing on drift examples, and implementing Python-based monitoring...\n[John Leung](https://towardsdatascience.com/author/johnleungtj/)\nSeptember 5, 202312 min read\n### How is our model impacted in the evolving world? An analysis focusing on drift examples, and implementing Python-based monitoring strategies\nMachine Learning (ML) model development often takes time and requires technical expertise. As data science enthusiasts, when we acquire a dataset to explore and analyze, we eagerly train and validate it using diverse [state-of-the-art models](https://medium.com/geekculture/whats-the-public-sentiment-under-inflationary-economic-environment-5edc899efa29) or employing [data-centric strategies](https://medium.com/mlearning-ai/how-to-apply-data-centric-ai-mindset-to-text-classification-problems-b41656c70c16). It feels incredibly fulfilling when we optimize the model's performance as if all the tasks have been accomplished.\nHowever, after deploying the model to production, there are plenty of reasons that contribute to lower model performance or degradation.\n![Photo by Adrien Delforge on Unsplash](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/09/00bV_DzPbXJsjS1sE-scaled.jpg)\nPhoto by [Adrien Delforge](https://unsplash.com/@adriendlf?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)\n**#1 The training data is generated through simulation**\nLearn this step by step with the interactive [AI Engineer](https://roadmap.sh/ai-engineer), [Data Analyst](https://roadmap.sh/data-analyst) and [Machine Learning](https://roadmap.sh/machine-learning) roadmaps.\nData scientists often [face limitations](https://www.cio.com/article/465251/how-can-cios-protect-personal-identifiable-information-pii-for-a-new-class-of-data-consumers.html) in accessing the production data, which results in training the model using simulated or sample data instead. While data engineers bear the responsibility of ensuring the representativeness of the training data in terms of scale and complexity, the training data still deviates to some extent from the production data. There is also a risk of systematic flaws in upstream data processing, such as data collection and labeling. These factors can impact the extraction of additional useful input features or hinder the model's ability to generalize well.\n> **Example:** Investor data in the financial industry or patient information in the healthcare industry is often simulated due to security and privacy concerns.\n**#2 The new production data exhibits a new data distribution**\nOver time, the characteristics of input features can also change, such as shifts in age groups, income ranges, or other customer demographics. The data source itself may even be completely replaced due to various cases. During the model development process, optimization relies on learning and capturing patterns from the majority group within the training data. However, as time progresses, the previous majority may transition into the minority in the production data, rendering the original static model inadequate for meeting the most recent production needs.\n> **Example:** The model is well trained initially using customer data in Asian regions. Recently since the business expands into the United States, the same model directly makes prediction based on the input features which have exhibited variations.\n![Data drift \\(Image by author\\)](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/09/1wzz1meY28vtP29Rdte3EBQ.png)\nData drift (Image by author)\n**#3 The patterns that we predict are evolving**\nApart from shifts in the distribution of input features, the [relationship between the features and the target variable](https://en.wikipedia.org/wiki/Concept_drift) can also change in the evolving environment. These changes can occur in unexpected ways over time, rendering the original model progressively ineffective.\n  * Sudden concept change\n\n\nThese changes can occur abruptly, sometimes within a few weeks, due to unforeseen circumstances.\n> **Example:** The surge in demand for virtual meeting services during public COVID-19 lockdowns.\n  * Gradual concept change\n\n\nThis type of change takes longer to manifest and is often a natural progression.\n> **Example:** The gradual increase in the price of dairy products due to long-term inflation.\n  * Recurrent concept change\n\n\nThese changes can happen periodically, often during specific times of the year.\n> **Example:** The rapid growth in e-commerce sales during various special days like Black Friday and the Saturday before Christmas.\n![Concept drift \\(Image by author\\)](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/09/1YGJ_TdHR-IIFe9iEB0X1ow.png)\nConcept drift (Image by author)\n* * *\n### Model development is only a tiny part of a production-ready ML system\nMany companies emphasize data-driven decision-making through the use of ML applications. Imagine that your ML models are utilized in critical applications, such as medical diagnosis, to support healthcare professionals in identifying diseases and conditions. Any model degradation means impacting the accuracy of diagnoses, potentially resulting in incorrect treatment plans and compromised patient outcomes. There are tons of cases with high importance in the real world, thus it becomes imperative to implement objective and continuous monitoring to detect any possible shifts.\nIn the following sections, we will delve into various layers of monitoring and provide illustrative Python code examples to demonstrate their implementation.\n![Photo by Nathy dog on Unsplash](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/09/00ZJIiJ5AG2Gu-liU-scaled.jpg)\nPhoto by [Nathy dog](https://unsplash.com/@nathdah?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)\n### 1 Monitor the model performance metrics\nTo detect any sign of model degradation, one of the direct and effective ways is to keep track of the performance metrics over time.\n  * [Performance metrics for regression model](https://towardsdatascience.com/what-are-the-best-metrics-to-evaluate-your-regression-model-418ca481755b): R-squared, Root mean squared error (RMSE), and mean absolute error (MAE)\n  * [Performance metrics for classification model](https://towardsdatascience.com/the-5-classification-evaluation-metrics-you-must-know-aa97784ff226): Precision, recall, and F1-score\n\n\nThese performance metrics collected from the initial deployment serve as benchmarks for ongoing monitoring and evaluation. Periodically reassessing them is crucial whenever a new batch of ground truth data is collected, such as upon completion of a marketing campaign. If the error metrics rise above a predefined threshold, or if the metrics such as R-squared fall below the threshold, it is necessary to consider re-executing the data engineering process and retraining the model.\nWhile this monitoring approach provides valuable insights into any drifts, it tends to lag. We can take a more proactive approach to monitor the latest input data.\n### 2 Detect the changes in data distribution\nInstead of waiting for sufficient input data for reliable evaluation of model performance, we can apply statistical methods for comparing the data distributions of two datasets. In our case, we can determine if the distribution of the training dataset is the same as that of the latest production dataset. If it is not statistically confident that two distributions are the same, it suggests a drift in the model. This is as a proxy for performance changes.\n  * Kolmogorov-Smirnov Test ([K-S Test](https://towardsdatascience.com/kolmogorov-smirnov-test-84c92fb4158d)): nonparametric test (i.e. with no assumption on the underlying data distribution) **for numeric features** , it is more sensitive near the center of the distribution than at the tails.\n\n\n> **Interpretation:** When p-value < 0.05, an alert indicating the presence of a drift is triggered.\n  * Population Stability Index ([PSI](https://towardsdatascience.com/psi-and-csi-top-2-model-monitoring-metrics-924a2540bed8)): A statistical test that can be applied to **both numeric and categorical variables**. It is a metric that shows how each variable has diverged independently from the baseline values. It is sometimes called the Characteristic Stability Index (CSI) when evaluating the distribution of features rather than target variables.\n\n\n> **Interpretation:** A value 0~0.1 means no significant distribution change; a value 0.1~0.2 considered a moderate distribution change; and a value larger than 0.2 interpreted as a significant distribution change.\nOther famous statistical tests include [Kullback-Leibler divergence](https://towardsdatascience.com/understanding-kl-divergence-f3ddc8dff254), [Jensen-Shannon divergence](https://towardsdatascience.com/how-to-understand-and-use-jensen-shannon-divergence-b10e11b03fd6), and [Wasserstein distance](https://towardsdatascience.com/the-gromov-wasserstein-distance-835c39d4751d).\n### 3 Monitor drift using a sliding window approach\nAny delay in detecting data or pattern drifts results in a time gap, potentially leading to discrepancies between the ground truth and model predictions. To bridge the gap, are there any further advancements available? One promising idea is leveraging streaming data instead of batch data.\nThe Adaptive Windowing ([ADWIN](https://scikit-multiflow.readthedocs.io/en/stable/api/generated/skmultiflow.drift_detection.ADWIN.html)) algorithm utilizes a sliding window approach to effectively detect concept drift. Unlike traditional fixed-size windows, ADWIN decides the size of the window by cutting the statistics window at different points. Whenever newly arriving data comes, ADWIN analyses the statistics and identifies the point at which two sub-windows demonstrate notable differences in their means.\n> **Interpretation:** When the absolute difference between the two means exceeds a pre-defined threshold, an alert indicating the presence of a drift is triggered.\n* * *\n### **Example Walkthrough**\nLet's explore an example that demonstrates the implementation of the above monitoring strategies.\nWe will utilize a [dataset](https://www.kaggle.com/datasets/parisrohan/credit-score-classification?datasetId=2289007&sortBy=voteCount&select=train.csv) obtained from Kaggle. The dataset comprises 100k records, encompassing 28 features **** that describe the customer demographics and their credit-related history.\nOur objective is to segregate customers in a global financial company into credit score brackets. The target variable is **Credit_Score** , a categorical measure classified as 'Poor', 'Standard', and 'Good'.\nExamples of features include:\n  * _Occupation_ : Occupation of the customers (e.g. scientist, teacher, engineer, etc.)\n  * _Annual _Income_ : Annual income of the customers\n  * _Credit_History _Age_ : The age of customers' credit history\n  * _Payment _Behaviour_ : 6 groups of payment behaviors based on spending frequency (low/ high) and payment amount (small/ medium/ large)\n\n\n![Photo by CardMapr.nl on Unsplash](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/09/0hpsQwk5r0j_syEN5-scaled.jpg)\nPhoto by [CardMapr.nl](https://unsplash.com/@cardmapr?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)\n**Model performance metrics**\nLet's start by applying data cleansing and transformation techniques, including but not limited to:\n  * Correcting/ Removing records with missing values or incorrect data (e.g. age < 0), or duplicates\n  * Detecting and handling data outliers\n  * Performing min-max scaling on numeric variables\n  * Applying label encoding on categorical variables\n\n\n_This part requires in-depth exploratory data analysis. However, since the focus is on sharing the monitoring strategies, the transformations performed are not discussed in detail here._\nAfterward, we split the dataset and developed the advanced gradient boosting algorithm, [LightGBM](https://lightgbm.readthedocs.io/en/stable/).\npython\n\n```\nimport numpy as np\nimport pandas as pd\nfrom sklearn import metrics\nfrom sklearn.metrics import f1_score, precision_score, recall_score\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.preprocessing import LabelEncoder\nfrom lightgbm import LGBMClassifier\n\n# Convert target variable to numeric\ndf['Credit_Score'] = df['Credit_Score'].str.replace('Good', '3', n=-1)\ndf['Credit_Score'] = df['Credit_Score'].str.replace('Standard', '2', n=-1)\ndf['Credit_Score'] = df['Credit_Score'].str.replace('Poor', '1', n=-1)\ndf['Credit_Score'] = df[['Credit_Score']].apply(pd.to_numeric)\n\n# Split the dataset\nX=df.loc[:, df.columns != 'Credit_Score']\nY=df['Credit_Score']\nx_train, x_test, y_train, y_test = train_test_split(X, Y, test_size=0.25)\n\n# Train the LightGBM model\nlgbm = LGBMClassifier()\nlgbm.fit(x_train, y_train)\ny_pred = lgbm.predict(x_test)\n\n# Print performance metrics\nprint('F1 score: %.3f' % f1_score(y_test, y_pred, average='weighted'))\nprint('Precision: %.3f' % precision_score(y_test, y_pred, average='weighted'))\nprint('Recall: %.3f' % recall_score(y_test, y_pred, average='weighted'))\n```\n\nDuring our model development, we gathered several performance metrics, including an F1 score of 0.810, a precision score of 0.818, and a recall score of 0.807. Subsequent monitoring can be evaluated similarly. For instance, if the F1 score falls below 0.75, it serves as an alert, prompting us to take immediate action to mitigate the issue.\n**K-S Test**\nTo demonstrate how the K-S Test works, I have selected a numeric feature _Credit_History _Age_. We will examine the sensitivity of this statistical test by creating three distinct datasets: one with 1000 samples, another with 5000 samples, and a third with approximately 64000 samples, which corresponds to the total size of the cleaned training samples. Each data point within the _Credit_History _Age_ feature has been randomly picked from the training data and altered by a random floating-point number.\n![Data distributions of &#039;Credit_History_Age&#039; in original data and drifted data \\(Image by author\\)](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/09/1XRWMTRf5wrmP1sPU_TNunQ.png)\nData distributions of 'Credit_History_Age' in original data and drifted data (Image by author)\nWe obtained the following results:\n  * For the dataset with 1000 samples, the p-value of the K-S Test is 0.093.\n  * For the dataset with 5000 samples, the p-value of the K-S Test is 0.002.\n  * For the dataset with around 64000 samples, the p-value of the K-S Test is 0.000.\n\n\nWhen examining the data drift scenario using 1000 samples, the p-value exceeded 0.05. Consequently, we can conclude that the two distributions remain similar. However, as the sample size increased to 5000 and beyond, the K-S Test exhibited exceptional performance, yielding p-values significantly lower than 0.05. This provides a clear indication of a data distribution drift, serving as a clear alert.\npython\n\n```\nfrom scipy import stats\n\n# Create new datasets with different no. of samples\noriginal_df = x_train[['Credit_History_Age', 'Payment_Behaviour']].reset_index(drop=True)\nnew_df = x_train[['Credit_History_Age', 'Payment_Behaviour']].reset_index(drop=True)\nnew_df1 = new_df.sample(n = 1000).reset_index(drop=True)\nnew_df2 = new_df.sample(n = 5000).reset_index(drop=True)\nnew_df3 = new_df.sample(n = len(x_train)).reset_index(drop=True)\n\n# Prepare drifted data for numeric feature\ndef drift_numeric_col(df, numeric_col, drift_range):\n    df[numeric_col] = df[numeric_col] + np.random.uniform(0, drift_range, size=(df.shape[0], ))\n\ndrift_numeric_col(new_df1, 'Credit_History_Age', 2)\ndrift_numeric_col(new_df2, 'Credit_History_Age', 2)\ndrift_numeric_col(new_df3, 'Credit_History_Age', 2)\n\n# K-S Test\ndef ks_test(original_df, new_df, numeric_col):\n    test = stats.ks_2samp(original_df[numeric_col], new_df[numeric_col])\n    print(\"Column : %s , p-value : %1.3f\" % (numeric_col, test[1]))\n\n# Conduct K-S Test for numeric feature\nks_test(original_df, new_df1, 'Credit_History_Age')\nks_test(original_df, new_df2, 'Credit_History_Age')\nks_test(original_df, new_df3, 'Credit_History_Age')\n```\n\n**PSI**\nIn addition to utilizing the K-S Test, we will also leverage the PSI (Population Stability Index) to evaluate the numeric feature _Credit_History _Age_ and assess the categorical feature _Payment _Behaviour_. To represent the drift effect, we have randomly replaced 80% of the data of the feature _Payment _Behaviour_ with specific label values.\npython\n\n```\n# Prepare drifted data for categorical column\ndef drift_cat_col(df, cat_col, drift_ratio):\n    no_of_drift = round(len(df)*drift_ratio)\n    random_numbers = [random.randint(0, 1) for _ in range(no_of_drift)]\n    indices = random.sample(range(len(df[cat_col])), no_of_drift)\n    df.loc[indices, cat_col] = random_numbers\n\ndrift_cat_col(new_df1, 'Payment_Behaviour', 0.8)\ndrift_cat_col(new_df2, 'Payment_Behaviour', 0.8)\ndrift_cat_col(new_df3, 'Payment_Behaviour', 0.8)\n```\n\n![Data distributions of &#039;Payment_Behaviour&#039; in original data and drifted data \\(Image by author\\)](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/09/10gNA74PGjOyBySwkkqhwag.png)\nData distributions of 'Payment_Behaviour' in original data and drifted data (Image by author)\n  * Numeric feature _Credit_History _Age_\n\n\nWith a sample size of 1000, the PSI value is 0.023.\nWith a sample size of 5000, the PSI value is 0.015.\nWith a sample size of approximately 64000, the PSI value is 0.021.\n  * Categorical feature _Payment _Behaviour_\n\n\nWith a sample size of 1000, the PSI value is 0.108.\nWith a sample size of 5000, the PSI value is 0.111.\nWith a sample size of approximately 64000, the PSI value is 0.112.\nAll the PSI values for the _Credit_History _Age_ feature are significantly lower than 0.1, indicating no significant distribution change. By comparing these results with those obtained from the K-S Test, we observe that the K-S Test exhibits greater sensitivity in detecting distribution changes compared to PSI.\nOn the other hand, the PSI values for the _Payment _Behaviour_ feature are around 0.11, signifying a moderate distribution change. Interestingly, the three PSI values remain relatively consistent, implying that PSI's effectiveness is less dependent on sample sizes. Besides, PSI has the flexibility to monitor across various feature types, positioning it still a valuable approach for drift detection.\nBelow is the implementation code of PSI:\npython\n\n```\ndef psi(data_base, data_new, num_bins = 10):\n    # Sort the data\n    data_base = sorted(data_base)\n    data_new = sorted(data_new)\n\n    # Prepare the bins\n    min_val = min(data_base[0], data_new[0])\n    max_val = max(data_base[-1], data_new[-1])\n    bins = [min_val + (max_val - min_val)*(i)/num_bins for i in range(num_bins+1)]\n    bins[0] = min_val - 0.0001\n    bins[-1] = max_val + 0.0001\n\n    # Bucketize the baseline data and count the samples\n    bins_base = pd.cut(data_base, bins = bins, labels = range(1,num_bins+1))\n    df_base = pd.DataFrame({'base': data_base, 'bin': bins_base})\n    grp_base = df_base.groupby('bin').count()\n    grp_base['percent_base'] = grp_base['base'] / grp_base['base'].sum() \n\n    # Bucketize the new data and count the samples\n    bins_new = pd.cut(data_new, bins = bins, labels = range(1,num_bins+1))\n    df_new = pd.DataFrame({'new': data_new, 'bin': bins_new})\n    grp_new = df_new.groupby('bin').count()\n    grp_new['percent_new'] = grp_new['new'] / grp_new['new'].sum()\n\n    # Compare the bins\n    psi_df = grp_base.join(grp_new, on = \"bin\", how = \"inner\")\n\n    # Calculate the PSI\n    psi_df['percent_base'] = psi_df['percent_base'].replace(0, 0.0001)\n    psi_df['percent_new'] = psi_df['percent_new'].replace(0, 0.0001)\n    psi_df['psi'] = (psi_df['percent_base'] - psi_df['percent_new']) * np.log(psi_df['percent_base'] / psi_df['percent_new'])\n\n    # Return the total PSI value\n    return np.sum(psi_df['psi'].values)\n\n# Conduct K-S Test for numeric feature\npsi(original_df['Credit_History_Age'], new_df1['Credit_History_Age'])\npsi(original_df['Credit_History_Age'], new_df2['Credit_History_Age'])\npsi(original_df['Credit_History_Age'], new_df3['Credit_History_Age'])\n\n# Conduct K-S Test for categorical feature\npsi(original_df['Payment_Behaviour'], new_df1['Payment_Behaviour'])\npsi(original_df['Payment_Behaviour'], new_df2['Payment_Behaviour'])\npsi(original_df['Payment_Behaviour'], new_df3['Payment_Behaviour'])\n```\n\n**ADWIN algorithm**\nLastly, we test the power of ADWIN in detecting the change in the numeric feature _Credit_History _Age_. The [data stream](https://en.wikipedia.org/wiki/Streaming_data) consists of the training data, followed by the drifted data. We expect that the algorithm will promptly identify the drift shortly after examining the entirety of the original data.\nTo visually represent the situation, a scatter plot is created to showcase the final 500 points of the original data in blue, followed by the initial 500 points of the drifted data, depicted in green. The drifted data exhibits a slightly higher average value.\n![Scatter plot \\(Image by author\\)](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/09/1IdY2GQf1xTLDB9p8ue3YAQ.png)\nScatter plot (Image by author)\nBy continuously adding stream elements, ADWIN identifies the change at index 64457, which is the 637th data point within the drifted data. In comparison, the K-S Test and PSI necessitate a larger number of data points to conclude the presence of a drift confidently. The better performance of ADWIN is a testament to its capability to monitor diverse features at speed and ease.\nBelow is the implementation code of ADWIN:\npython\n\n```\nfrom skmultiflow.drift_detection import ADWIN\n\nadwin = ADWIN()\ndata_stream=[]\ndata_stream = np.concatenate((original_df['Credit_History_Age'],new_df3['Credit_History_Age']))\n\n# Add stream elements to ADWIN and verify if drift occurred\nfor i in range(len(data_stream)):\n  adwin.add_element(data_stream[i])\n  if adwin.detected_change():\n  print('Change detected at index {}'.format(i))\n  adwin.reset()\n```\n\n### Wrapping it up\nWe've delved into the crucial concepts of data drift and model drift, which can lead to model decay in production. We can proactively monitor and detect drift conditions using model performance metrics, statistical tests, and adaptive windowing techniques. Unlike participating in a one-time Kaggle competition, building a production-ready ML system is an iterative journey. It requires a mindset shift towards integrating comprehensive model monitoring to ensure a robust and consistently high-performance serving space.\n* * *\n### Before you go\nIf you enjoy this reading, I invite you to **** follow [my Medium page](https://medium.com/@johnleungTJ). By doing so, you can stay updated with exciting content related to data science side projects, Machine Learning Operations (MLOps) demonstrations, and project management methodologies.\n> [**Optimizing Your Strategies with Approaches Beyond A/B Testing**](https://towardsdatascience.com/optimizing-your-strategies-with-approaches-beyond-a-b-testing-bf11508f8930)\n> [**How to Apply Data-centric AI Mindset to Text Classification Problems?**](https://medium.com/mlearning-ai/how-to-apply-data-centric-ai-mindset-to-text-classification-problems-b41656c70c16)\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/1787657188043_vu8s9b.jpeg)\nWritten By\n## [John Leung](https://towardsdatascience.com/author/johnleungtj/)\n[See all from John Leung](https://towardsdatascience.com/author/johnleungtj/)\n[Artificial Intelligence](https://towardsdatascience.com/tag/artificial-intelligence/)[Machine Learning](https://towardsdatascience.com/tag/machine-learning/)[Mlops](https://towardsdatascience.com/tag/mlops/)[Python](https://towardsdatascience.com/tag/python/)[Statistics](https://towardsdatascience.com/tag/statistics/)\nShare This Article\n  * [](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Ftowardsdatascience.com%2Fmonitoring-machine-learning-models-in-production-why-and-how-13d07a5ff0c6%2F&title=Monitoring%20Machine%20Learning%20Models%20in%20Production%3A%20Why%20and%20How%3F)\n  * [](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Ftowardsdatascience.com%2Fmonitoring-machine-learning-models-in-production-why-and-how-13d07a5ff0c6%2F&title=Monitoring%20Machine%20Learning%20Models%20in%20Production%3A%20Why%20and%20How%3F)\n  * [](https://x.com/share?url=https%3A%2F%2Ftowardsdatascience.com%2Fmonitoring-machine-learning-models-in-production-why-and-how-13d07a5ff0c6%2F&text=Monitoring%20Machine%20Learning%20Models%20in%20Production%3A%20Why%20and%20How%3F)\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/2021/04/1ES0X4K4vKhdxTeU-jbclzw-scaled.jpeg)](https://towardsdatascience.com/text-extraction-using-regular-expression-python-186369add656/)\n## [Text Extraction using Regular Expression (Python)](https://towardsdatascience.com/text-extraction-using-regular-expression-python-186369add656/)\n[Programming](https://towardsdatascience.com/category/programming/)\nAn example of extracting text with keywords with Regular Expression.\n[KahEm Chu](https://towardsdatascience.com/author/kahemchu/)\nApril 10, 20215 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2024/03/0ffSo12moqSDb6Qmz-scaled.jpg)](https://towardsdatascience.com/building-your-first-desktop-application-using-pyside6-a-data-scientist-edition-e2275cf0c977/)\n## [Building Your First Desktop Application using PySide6 [A Data Scientist Edition]](https://towardsdatascience.com/building-your-first-desktop-application-using-pyside6-a-data-scientist-edition-e2275cf0c977/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nSurprise, surprise. It's not as hard as I thought it would be.\n[Arunn Thevapalan](https://towardsdatascience.com/author/arunnthevapalan/)\nMarch 16, 202414 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/11/0r9-o8F7Mt-9PzQT4-scaled.jpg)](https://towardsdatascience.com/make-python-faster-by-caching-functions-memoization-4fca250ab5f6/)\n## [Make Python Faster by Caching Functions: Memoization](https://towardsdatascience.com/make-python-faster-by-caching-functions-memoization-4fca250ab5f6/)\n[Data Science](https://towardsdatascience.com/category/data-science/)\nThe article discusses memoization using the Python standard library. The functools.lru_cache decorator makes this so simple!\n[Marcin Kozak](https://towardsdatascience.com/author/nyggus/)\nNovember 11, 202312 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/05/0X4q1tzv1ze_i3fB5-scaled.jpeg)](https://towardsdatascience.com/weekly-review-of-reinforcement-learning-papers-9-d0f7eff9eae2/)\n## [Weekly review of Reinforcement Learning papers #9](https://towardsdatascience.com/weekly-review-of-reinforcement-learning-papers-9-d0f7eff9eae2/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nEvery Monday, I present 4 publications from my research area. Let's discuss them! [← Previous...\n[Quentin Gallouédec](https://towardsdatascience.com/author/qgallouedec/)\nMay 17, 20215 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/03/1G6zf33q-qNoyAZ_KQqvUKA.jpeg)](https://towardsdatascience.com/using-make-for-data-science-projects-changed-my-life-23de1597e2e/)\n## [Using Make for Data Science Projects Changed My Life](https://towardsdatascience.com/using-make-for-data-science-projects-changed-my-life-23de1597e2e/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nThe bedrock utility helps keep code modular and levels up your iteration speed\n[Sean Easter](https://towardsdatascience.com/author/seaneaster/)\nMarch 1, 202211 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2022/06/0w_5On4DZUTASidbJ-scaled.jpg)](https://towardsdatascience.com/why-is-it-important-to-constantly-monitor-machine-learning-and-deep-learning-models-after-4136f6067547/)\n## [Why is it Important to Constantly Monitor Machine Learning and Deep Learning Models after...](https://towardsdatascience.com/why-is-it-important-to-constantly-monitor-machine-learning-and-deep-learning-models-after-4136f6067547/)\n[Artificial Intelligence](https://towardsdatascience.com/category/artificial-intelligence/)\nUnderstanding the importance of monitoring the ML and deep learning models after production can have a significant impact that these models...\n[Suhas Maddali](https://towardsdatascience.com/author/suhas-maddali007/)\nJune 28, 20226 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2020/12/0LrjR3vGa1OrCpOWh-scaled.jpg)](https://towardsdatascience.com/automating-the-setup-of-my-data-science-projects-656bb5c9ff5e/)\n## [Automating the Setup of my Data Science Projects](https://towardsdatascience.com/automating-the-setup-of-my-data-science-projects-656bb5c9ff5e/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nUsing Python to automate the process of setting up new project directories and making the first commit to a new repository in Github\n[Jack Leitch](https://towardsdatascience.com/author/jackmleitch/)\nDecember 21, 20204 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2021/08/1Gs-91OoxjBQicsatrYhpfw-scaled.jpeg)](https://towardsdatascience.com/the-top-three-lessons-learned-building-more-than-1-000-machine-learning-models-3fe188fdb4dd/)\n## [The Top Three Lessons Learned Building More Than 1,000 Machine Learning Models](https://towardsdatascience.com/the-top-three-lessons-learned-building-more-than-1-000-machine-learning-models-3fe188fdb4dd/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nAs someone who has overseen and created thousands of machine learning models, I want to share some of the most important insights learned.\n[Dr. Xuxu Wang](https://towardsdatascience.com/author/xuxu_wang/)\nJuly 21, 20205 min read\n  * [![](https://assets.insightmediagroup.io/media/wp-content/uploads/2023/08/0kyDQt8njujDluFW4-scaled.jpg)](https://towardsdatascience.com/should-i-really-eat-that-mushroom-9edeaa69d934/)\n## [Should I Really Eat That Mushroom?](https://towardsdatascience.com/should-i-really-eat-that-mushroom-9edeaa69d934/)\n[Machine Learning](https://towardsdatascience.com/category/artificial-intelligence/machine-learning/)\nClassifying edible and poisonous mushrooms with CatBoost gradient boosted decision trees\n[Caroline Arnold](https://towardsdatascience.com/author/caroline.arnold_63207/)\nAugust 17, 20235 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/c5ddcb7e2cdc/pages/",
  "body_markdown_path": "attachments/c5ddcb7e2cdc/pages/archived-body.md",
  "local_html": "attachments/c5ddcb7e2cdc/pages/archived-body.html",
  "body_source": "prior_capture"
}