{"id":633090,"date":"2020-01-28T12:48:12","date_gmt":"2020-01-28T20:48:12","guid":{"rendered":"https:\/\/www.microsoft.com\/en-us\/research\/?p=633090"},"modified":"2023-10-04T10:32:50","modified_gmt":"2023-10-04T17:32:50","slug":"open-source-library-provides-explanation-for-machine-learning-through-diverse-counterfactuals","status":"publish","type":"post","link":"https:\/\/www.microsoft.com\/en-us\/research\/blog\/open-source-library-provides-explanation-for-machine-learning-through-diverse-counterfactuals\/","title":{"rendered":"Open-source library provides explanation for machine learning through diverse counterfactuals"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-633513 size-full\" src=\"https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2020\/01\/MSR-Amit_1400x788-v3-1blog.gif\" alt=\"diagram\" width=\"1400\" height=\"788\" \/>Consider a person who applies for a loan with a financial company, but their application is rejected by a machine learning algorithm used to determine who receives a loan from the company. How would you explain the decision made by the algorithm to this person? One option is to provide them with a list of features that contributed to the algorithm\u2019s decision, such as income and credit score. Many of the current explanation methods provide this information by either analyzing the algorithm\u2019s properties or approximating it with a simpler, interpretable model.<\/p>\n<p>However, these explanations do not help this person decide what to do next to increase their chances of getting the loan in the future. In particular, changing the most important features for prediction may not actually change the decision, and in some cases, important features may be impossible to change, such as age. A similar argument applies when algorithms are used to support decision-makers in scenarios such as screening job applicants, deciding health insurance, or disbursing government aid.<\/p>\n<p>Therefore, it is equally important to show alternative feature inputs that would have received a favorable outcome from the algorithm. Such alternative examples are known as <a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"https:\/\/arxiv.org\/abs\/1711.00399\"><em>counterfactual explanations<\/em><span class=\"sr-only\"> (opens in new tab)<\/span><\/a> since they explain an algorithm by reasoning about a hypothetical input. In effect, they help a person answer the \u201cwhat-if\u201d question: What would have happened in an alternative <a href=\"https:\/\/www.microsoft.com\/en-us\/research\/blog\/dowhy-a-library-for-causal-inference\/\">counterfactual world<\/a> where some of my features had been different?<\/p>\n<p>To address this question, our team of researchers proposes a method for generating numerous diverse counterfactuals, which takes into account usefulness and relative ease. A paper detailing our research, entitled \u201c<a href=\"https:\/\/www.microsoft.com\/en-us\/research\/publication\/explaining-machine-learning-classifiers-through-diverse-counterfactual-examples\/\">Explaining Machine Learning Classifiers through Diverse Counterfactual Explanations<\/a>,\u201d will be presented at the <a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"https:\/\/fatconference.org\/2020\/index.html\">ACM Conference on Fairness, Accountability, and Transparency (ACM FAT* 2020)<span class=\"sr-only\"> (opens in new tab)<\/span><\/a> in Barcelona, Spain. We have also released an open-source library, <a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"https:\/\/github.com\/microsoft\/dice\">Diverse Counterfactual Explanations (DiCE)<span class=\"sr-only\"> (opens in new tab)<\/span><\/a>, which implements our framework for generating counterfactual explanations. Although it is easy to generate a single counterfactual, the main challenge is to generate multiple useful ones, and that is the overlying goal of our method. This research was done in collaboration with <a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"https:\/\/chenhaot.com\/\">Chenhao Tan from University of Colorado, Boulder<span class=\"sr-only\"> (opens in new tab)<\/span><\/a>, and also includes Ramaravind Mothilal, who is currently an <a href=\"https:\/\/www.microsoft.com\/en-us\/research\/collaboration\/scai\/\">SCAI Center Fellow<\/a> at Microsoft Research India.<\/p>\n<h3>The challenge: Generating multiple counterfactuals that are useful to users and system builders<\/h3>\n<p>Specifically, <em>counterfactual explanation<\/em> refers to a perturbation on the original feature input that results in the machine learning model providing a different decision. Such explanations are certainly useful to a person facing the decision, but they are also useful to system builders and evaluators in debugging the algorithm. In this sense, counterfactual examples are similar to adversarial examples, except that problematic examples are based not only on proximity to original input, but also on various domain-dependent restrictions that should not affect the outcome, such as sensitive attributes. Perhaps their biggest benefit is that they are always faithful to the original algorithm\u2014following the counterfactual explanation will lead to the desired outcome, as long as the model stays the same.<\/p>\n<p>Because of the large space of possible counterfactuals, it is unclear which examples will be actionable for a user or which ones will expose the various properties that a model builder may be interested in. For instance, a counterfactual explanation may suggest to change one\u2019s house rent, but it does not disclose if there are other possible counterfactuals to the same effect or the relative ease with which different changes can be made.<\/p>\n<h3>Our solution: A method that creates many different counterfactuals at the same time<\/h3>\n<p>To find alternative counterfactuals that account for these additional factors, our method generates a diverse set of counterfactuals all at once. Much like web search engines, providing a set of diverse options allows a person to make an informed choice for the most actionable option. It also allows algorithm builders to test multiple ways of changing the outcome.<br \/>\nWe do this by formulating a joint optimization problem that optimizes both diversity and proximity to the original input, in addition to ensuring that the model provides the desired outcome for the counterfactual example. In addition, we support adding different kinds of user-specific requirements. By adding constraints to the optimization problem, one can specify which features are varied, by how much, and the relative difficulty of varying each feature. Figure 1 is an example of our method applied to explain a machine learning model that predicts income for a person.<\/p>\n<div id=\"attachment_633093\" style=\"width: 1075px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-633093\" class=\"wp-image-633093 size-full\" src=\"https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2020\/01\/Picture1-5e2b82c0d485b.png\" alt=\"diagram\" width=\"1065\" height=\"184\" srcset=\"https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2020\/01\/Picture1-5e2b82c0d485b.png 1065w, https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2020\/01\/Picture1-5e2b82c0d485b-300x52.png 300w, https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2020\/01\/Picture1-5e2b82c0d485b-1024x177.png 1024w, https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2020\/01\/Picture1-5e2b82c0d485b-768x133.png 768w\" sizes=\"auto, (max-width: 1065px) 100vw, 1065px\" \/><p id=\"caption-attachment-633093\" class=\"wp-caption-text\">Figure 1: Counterfactual explanations for a person from the <a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"https:\/\/archive.ics.uci.edu\/ml\/datasets\/Adult\">Adult Income Dataset<span class=\"sr-only\"> (opens in new tab)<\/span><\/a>, based on a given machine learning model that classifies their income. DiCE constructs an optimization function to generate <em>k<\/em>=4 counterfactuals that are both proximal to the original input and diverse. Dashes in a counterfactual example correspond to no change in those features.<\/p><\/div>\n<p>We find that our proposed method outperforms current methods for generating a diverse set of counterfactuals. We also discover an impressive property of counterfactuals: just a handful of counterfactual explanations are able to locally approximate the machine learning algorithm using a simple <em>k<\/em>-nearest neighbors classification model. That is, counterfactual explanations can approximate the local decision boundary with comparable accuracy to methods like <a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"https:\/\/github.com\/marcotcr\/lime\">LIME<span class=\"sr-only\"> (opens in new tab)<\/span><\/a> that are specifically optimized for the objective.<\/p>\n<p>That said, what qualifies as a useful counterfactual varies by application domain, and many challenges remain to deploy counterfactual examples for real-world systems. One of the key challenges is handling causal relationships between features while modifying them. Features do not exist in a vacuum; they are generated from a data-generating process that constrains their modification. Therefore, while a counterfactual explanation may change features independently, the suggested change can sometimes be impossible (for instance, getting a higher degree without aging). We are currently developing methods that can generate counterfactual examples that satisfy causal constraints and presented our <a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"https:\/\/arxiv.org\/abs\/1912.03277\">work<span class=\"sr-only\"> (opens in new tab)<\/span><\/a> at the NeurIPS 2019 workshop on <a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"http:\/\/tripods.cis.cornell.edu\/neurips19_causalml\/\">causal machine learning<span class=\"sr-only\"> (opens in new tab)<\/span><\/a>. In another <a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"https:\/\/arxiv.org\/abs\/1912.04930\">paper<span class=\"sr-only\"> (opens in new tab)<\/span><\/a> that is presented at the ACM FAT* 2020 conference, my colleague <a href=\"https:\/\/www.microsoft.com\/en-us\/research\/people\/solon\/\">Solon Barocas<\/a> raises several other important issues on deciding the explanations to be shown and the potential consequences of revealing too much about the algorithm.<\/p>\n<p>To accelerate research on these questions, we have released <a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"https:\/\/github.com\/microsoft\/dice\">an open-source library called Diverse Counterfactual Explanations (DiCE)<span class=\"sr-only\"> (opens in new tab)<\/span><\/a> that implements our methods and provides a framework for testing other counterfactual explanation methods. We look forward to adding more methods to the library and integrating with the broader <a class=\"msr-external-link glyph-append glyph-append-open-in-new-tab glyph-append-xsmall\" rel=\"noopener noreferrer\" target=\"_blank\" href=\"https:\/\/github.com\/interpretml\/interpret-community\">InterpretML framework<span class=\"sr-only\"> (opens in new tab)<\/span><\/a> for explaining machine learning models. Given the multiple objectives of diversity, proximity, and causal feasibility, we hope that the library enables development and benchmarking of different counterfactual explanation methods and provides an easy way for adapting counterfactual generation to different use cases for a model builder, evaluator, or end-user. To help researchers accomplish these goals, our team will be publishing regular updates to the GitHub page, including additions to the library and information about new methods.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Consider a person who applies for a loan with a financial company, but their application is rejected by a machine learning algorithm used to determine who receives a loan from the company. How would you explain the decision made by the algorithm to this person? One option is to provide them with a list of [&hellip;]<\/p>\n","protected":false},"author":38838,"featured_media":972729,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"msr-url-field":"","msr-podcast-episode":"","msrModifiedDate":"","msrModifiedDateEnabled":false,"ep_exclude_from_search":false,"_classifai_error":"","msr-author-ordering":[{"type":"user_nicename","value":"Amit Sharma","user_id":"30997"}],"msr_hide_image_in_river":0,"footnotes":""},"categories":[194455],"tags":[],"research-area":[13561],"msr-region":[],"msr-event-type":[],"msr-locale":[268875],"msr-post-option":[],"msr-impact-theme":[],"msr-promo-type":[],"msr-podcast-series":[],"class_list":["post-633090","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-machine-learning","msr-research-area-algorithms","msr-locale-en_us"],"msr_event_details":{"start":"","end":"","location":""},"podcast_url":"","podcast_episode":"","msr_research_lab":[],"msr_impact_theme":[],"related-publications":[],"related-downloads":[],"related-videos":[],"related-academic-programs":[],"related-groups":[470706,685431],"related-projects":[813025],"related-events":[],"related-researchers":[{"type":"user_nicename","value":"Amit Sharma","user_id":30997,"display_name":"Amit Sharma","author_link":"<a href=\"https:\/\/www.microsoft.com\/en-us\/research\/people\/amshar\/?lang=ko-kr\" aria-label=\"Amit Sharma \ub300\ud55c \ud504\ub85c\ud544 \ud398\uc774\uc9c0 \ubc29\ubb38\">Amit Sharma<\/a>","is_active":false,"last_first":"Sharma, Amit","people_section":0,"alias":"amshar"}],"msr_type":"Post","featured_image_thumbnail":"<img width=\"960\" height=\"540\" src=\"https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2020\/04\/MSR-blog_Amit-2020_counterfactual-example-960x540.jpg\" class=\"img-object-cover\" alt=\"DICE: counterfactual example diagram\" decoding=\"async\" loading=\"lazy\" srcset=\"https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2020\/04\/MSR-blog_Amit-2020_counterfactual-example-960x540.jpg 960w, https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2020\/04\/MSR-blog_Amit-2020_counterfactual-example-300x169.jpg 300w, https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2020\/04\/MSR-blog_Amit-2020_counterfactual-example-1024x576.jpg 1024w, https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2020\/04\/MSR-blog_Amit-2020_counterfactual-example-768x432.jpg 768w, https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2020\/04\/MSR-blog_Amit-2020_counterfactual-example-1066x600.jpg 1066w, https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2020\/04\/MSR-blog_Amit-2020_counterfactual-example-655x368.jpg 655w, https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2020\/04\/MSR-blog_Amit-2020_counterfactual-example-343x193.jpg 343w, https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2020\/04\/MSR-blog_Amit-2020_counterfactual-example-240x135.jpg 240w, https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2020\/04\/MSR-blog_Amit-2020_counterfactual-example-640x360.jpg 640w, https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2020\/04\/MSR-blog_Amit-2020_counterfactual-example-1280x720.jpg 1280w, https:\/\/www.microsoft.com\/en-us\/research\/wp-content\/uploads\/2020\/04\/MSR-blog_Amit-2020_counterfactual-example.jpg 1400w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/>","byline":"<a href=\"https:\/\/www.microsoft.com\/en-us\/research\/people\/amshar\/\" title=\"Go to researcher profile for Amit Sharma\" aria-label=\"Go to researcher profile for Amit Sharma\" data-bi-type=\"byline author\" data-bi-cN=\"Amit Sharma\">Amit Sharma<\/a>","formattedDate":"January 28, 2020","formattedExcerpt":"Consider a person who applies for a loan with a financial company, but their application is rejected by a machine learning algorithm used to determine who receives a loan from the company. How would you explain the decision made by the algorithm to this person?&hellip;","locale":{"slug":"en_us","name":"English","native":"","english":"English"},"_links":{"self":[{"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/posts\/633090","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/users\/38838"}],"replies":[{"embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/comments?post=633090"}],"version-history":[{"count":11,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/posts\/633090\/revisions"}],"predecessor-version":[{"id":633528,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/posts\/633090\/revisions\/633528"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/media\/972729"}],"wp:attachment":[{"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/media?parent=633090"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/categories?post=633090"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/tags?post=633090"},{"taxonomy":"msr-research-area","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/research-area?post=633090"},{"taxonomy":"msr-region","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/msr-region?post=633090"},{"taxonomy":"msr-event-type","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/msr-event-type?post=633090"},{"taxonomy":"msr-locale","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/msr-locale?post=633090"},{"taxonomy":"msr-post-option","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/msr-post-option?post=633090"},{"taxonomy":"msr-impact-theme","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/msr-impact-theme?post=633090"},{"taxonomy":"msr-promo-type","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/msr-promo-type?post=633090"},{"taxonomy":"msr-podcast-series","embeddable":true,"href":"https:\/\/www.microsoft.com\/en-us\/research\/wp-json\/wp\/v2\/msr-podcast-series?post=633090"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}