{"id":240,"date":"2024-07-22T13:13:35","date_gmt":"2024-07-22T17:13:35","guid":{"rendered":"https:\/\/www.econai.tech\/?page_id=240"},"modified":"2026-05-06T09:02:17","modified_gmt":"2026-05-06T13:02:17","slug":"model-explainability-and-interpretability","status":"publish","type":"page","link":"https:\/\/tomomitanaka.ai\/?page_id=240","title":{"rendered":"Explainability and Interpretability"},"content":{"rendered":"\n<p>In the era of complex machine learning models, the need for transparency and understanding has never been greater. <\/p>\n\n\n\n<p>As AI systems increasingly influence critical decisions in fields like finance, healthcare, and criminal justice, it&#8217;s crucial to be able to explain and interpret their outputs. <\/p>\n\n\n\n<p>This post explores the concepts of model explainability and interpretability, using the <a href=\"https:\/\/archive.ics.uci.edu\/dataset\/2\/adult\">Adult dataset (also known as the Census Income dataset)<\/a> as a practical example.<\/p>\n\n\n\n<p>You can find&nbsp;<a href=\"https:\/\/github.com\/tomomitanaka00\/AI_Safety\/blob\/main\/AI_Safety_Adult.ipynb\">the complete code<\/a>&nbsp;in my GitHub repository.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Explainability vs. Interpretability<\/h3>\n\n\n\n<p>While often used interchangeably, these terms have subtle differences:<\/p>\n\n\n\n<p><strong>Model explainability<\/strong> refers to the ability to describe the factors and the process by which a model makes its decisions. <\/p>\n\n\n\n<p><strong>Interpretability<\/strong>, on the other hand, is the degree to which a human can understand the cause of a decision made by a model. <\/p>\n\n\n\n<p>Both concepts are critical, particularly in high-stakes applications such as finance, healthcare, and criminal justice, where understanding why a model made a particular decision is as important as the decision itself.<\/p>\n\n\n\n<div class=\"wp-block-jin-gb-block-box-with-headline kaisetsu-box1\"><div class=\"kaisetsu-box1-title\">Why Explainability Matters<\/div>\n<p><strong>Trust<\/strong>: Users and stakeholders need to trust the model&#8217;s decisions.<\/p>\n\n\n\n<p><strong>Ethical Considerations<\/strong>: Transparent models help in identifying and mitigating biases.<\/p>\n\n\n\n<p><strong>Debugging<\/strong>: Understanding the model helps in identifying and fixing errors.<\/p>\n\n\n\n<p><strong>Regulatory Compliance<\/strong>: Many sectors require explainable AI for legal reasons.<\/p>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Techniques for Model Explainability<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">1. SHAP (SHapley Additive exPlanations)<\/h4>\n\n\n\n<p>SHAP values provide a unified measure of feature importance that works across various model types.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2. LIME (Local Interpretable Model-agnostic Explanations)<\/h4>\n\n\n\n<p>LIME explains individual predictions by approximating the model locally with an interpretable model.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">3. Partial Dependence Plots (PDP)<\/h4>\n\n\n\n<p>PDPs show the marginal effect of a feature on the predicted outcome.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">4. Permutation Importance<\/h4>\n\n\n\n<p>This technique measures feature importance by randomly shuffling feature values and observing the impact on model performance.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example: Adult Dataset<\/h3>\n\n\n\n<p>To illustrate model explainability and interpretability, let&#8217;s work with the Adult dataset, also known as the Census Income dataset. <\/p>\n\n\n\n<p>This dataset contains demographic information about individuals and is commonly used to predict whether a person earns more than $50,000 a year.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. Building the Model<\/h4>\n\n\n\n<p>For this example, we\u2019ll train a Gradient Boosting model, known for its predictive power but often criticized for being a black-box model due to its complexity.<\/p>\n\n\n\n<p>Gradient Boosting is an ensemble learning technique that combines multiple weak learners (typically decision trees) to create a strong predictive model. While this approach often leads to high accuracy, it can make the model difficult to interpret.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2. Results of Model Evaluation<\/h4>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td><\/td><td class=\"has-text-align-right\" data-align=\"right\">precision<\/td><td class=\"has-text-align-right\" data-align=\"right\">recall<\/td><td class=\"has-text-align-right\" data-align=\"right\">f1-score<\/td><\/tr><tr><td>Class 0 (majority)<\/td><td class=\"has-text-align-right\" data-align=\"right\">0.88<\/td><td class=\"has-text-align-right\" data-align=\"right\">0.95<\/td><td class=\"has-text-align-right\" data-align=\"right\">0.91<\/td><\/tr><tr><td>Class 1 (minority)<\/td><td class=\"has-text-align-right\" data-align=\"right\">0.80<\/td><td class=\"has-text-align-right\" data-align=\"right\">0.61<\/td><td class=\"has-text-align-right\" data-align=\"right\">0.69<\/td><\/tr><tr><td>Weighted Av.<\/td><td class=\"has-text-align-right\" data-align=\"right\">0.86<\/td><td class=\"has-text-align-right\" data-align=\"right\">0.86<\/td><td class=\"has-text-align-right\" data-align=\"right\">0.86<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The above classification report provides a detailed performance evaluation of the Gradient Boosting model on the test set.<\/p>\n\n\n\n<p>Our Gradient Boosting Classifier, trained on the Census Income dataset, achieved an accuracy of <strong>86%<\/strong> on the test set. This accuracy indicates that the model is robust in predicting whether an individual&#8217;s income exceeds $50,000 based on the provided features. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">3. Model Explainability<\/h4>\n\n\n\n<p>To understand the underlying decision-making process of our model, we utilized several interpretability techniques, including <strong>SHAP<\/strong> (SHapley Additive exPlanations), Partial Dependence Plots (<strong>PDP<\/strong>), and <strong>LIME<\/strong> (Local Interpretable Model-agnostic Explanations). <\/p>\n\n\n\n<p>These tools provided valuable insights into the key drivers of the model&#8217;s predictions:<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">SHAP Summary Plot<\/h5>\n\n\n\n<p>The SHAP summary plot revealed that <strong>relationship status<\/strong>, <strong>age<\/strong>, and <strong>education level<\/strong> (measured by education-num) are the most influential features in determining income.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Relationship<\/strong> status emerged as the top predictor, indicating significant variation in income levels based on marital and familial roles.<\/li>\n\n\n\n<li><strong>Age<\/strong> and <strong>education-num<\/strong> followed closely, reflecting the expected correlation between more experience, higher education, and increased earning potential.<\/li>\n\n\n\n<li>Other notable features included <strong>capital-gain<\/strong>, <strong>hours-per-week<\/strong>, and <strong>occupation<\/strong>, all of which had moderate impacts on the model&#8217;s predictions.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"710\" src=\"https:\/\/www.econai.tech\/wp-content\/uploads\/2024\/08\/shap_summary_plot.png\" alt=\"\" class=\"wp-image-4702\"\/><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\">Partial Dependence Plots (PDP)<\/h5>\n\n\n\n<p>The PDPs provided a deeper look at how specific features influence predictions across the dataset.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Relationship<\/strong>: there was a sharp decrease in the probability of earning >$50K for certain relationship statuses, highlighting the socioeconomic impact of marital and family roles.<\/li>\n\n\n\n<li><strong>Age<\/strong> demonstrated a clear trend where income probability increases with age until it plateaus, suggesting that experience contributes positively to income, but only up to a certain point.<\/li>\n\n\n\n<li><strong>Education-num<\/strong> (years of education) showed a strong positive correlation with income, emphasizing the value of higher education in boosting earning potential.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"307\" src=\"https:\/\/www.econai.tech\/wp-content\/uploads\/2024\/08\/pdp_plots-1024x307.png\" alt=\"\" class=\"wp-image-4711\" srcset=\"https:\/\/tomomitanaka.ai\/wp-content\/uploads\/2024\/08\/pdp_plots-1024x307.png 1024w, https:\/\/tomomitanaka.ai\/wp-content\/uploads\/2024\/08\/pdp_plots-300x90.png 300w, https:\/\/tomomitanaka.ai\/wp-content\/uploads\/2024\/08\/pdp_plots-768x230.png 768w, https:\/\/tomomitanaka.ai\/wp-content\/uploads\/2024\/08\/pdp_plots-1536x461.png 1536w, https:\/\/tomomitanaka.ai\/wp-content\/uploads\/2024\/08\/pdp_plots.png 2000w, https:\/\/www.econai.tech\/wp-content\/uploads\/2024\/08\/pdp_plots-1024x307.png 856w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\">LIME Explanation<\/h5>\n\n\n\n<p>LIME was used to provide a local explanation for an individual prediction. <\/p>\n\n\n\n<p>The explanation highlighted that for the specific instance analyzed, features such as <strong>relationship<\/strong>, <strong>education-num<\/strong>, and <strong>age<\/strong> had the most significant influence on predicting the likelihood of earning >$50K.<\/p>\n\n\n\n<p>This local interpretability helps in understanding how the model arrives at decisions for individual cases, ensuring transparency in the model&#8217;s predictions.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"480\" src=\"https:\/\/www.econai.tech\/wp-content\/uploads\/2024\/08\/lime_explanation.png\" alt=\"\" class=\"wp-image-4714\"\/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Conclusion<\/h3>\n\n\n\n<p>The interpretability techniques applied in this analysis not only validated the performance of our Gradient Boosting Classifier but also provided transparency into the model\u2019s decision-making process. <\/p>\n\n\n\n<p>Understanding that features like <strong>relationship<\/strong>, <strong>age<\/strong>, and <strong>education<\/strong> are strong predictors of income can inform future enhancements to the model and guide policymakers in addressing income disparities. <\/p>\n\n\n\n<p>Overall, these insights demonstrate the power of machine learning models when combined with interpretability techniques to yield both accurate and explainable results.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the era of complex machine learning models, the need for transparency and understanding has never been greater. As AI systems increasingly influence critical decisions in fields like finance, healthcare, and criminal justice, it#8217;s crucial to be able to explain and interpret their outputs. This post explores the concepts of model explainability and interpretability, using<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":140,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-240","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/tomomitanaka.ai\/index.php?rest_route=\/wp\/v2\/pages\/240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tomomitanaka.ai\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/tomomitanaka.ai\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/tomomitanaka.ai\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tomomitanaka.ai\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=240"}],"version-history":[{"count":51,"href":"https:\/\/tomomitanaka.ai\/index.php?rest_route=\/wp\/v2\/pages\/240\/revisions"}],"predecessor-version":[{"id":6398,"href":"https:\/\/tomomitanaka.ai\/index.php?rest_route=\/wp\/v2\/pages\/240\/revisions\/6398"}],"up":[{"embeddable":true,"href":"https:\/\/tomomitanaka.ai\/index.php?rest_route=\/wp\/v2\/pages\/140"}],"wp:attachment":[{"href":"https:\/\/tomomitanaka.ai\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}