<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Code4Thought</title>
    <description>The latest articles on DEV Community by Code4Thought (@code4thought).</description>
    <link>https://dev.to/code4thought</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F1299%2F1ee34dda-dd7d-44c0-8ed0-1d04f7a55c56.png</url>
      <title>DEV Community: Code4Thought</title>
      <link>https://dev.to/code4thought</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/code4thought"/>
    <language>en</language>
    <item>
      <title>Fix your recommender system to fix your profitability</title>
      <dc:creator>Romanos Kapsalis</dc:creator>
      <pubDate>Tue, 17 May 2022 13:35:13 +0000</pubDate>
      <link>https://dev.to/code4thought/fix-your-recommender-system-to-fix-your-profitability-4el2</link>
      <guid>https://dev.to/code4thought/fix-your-recommender-system-to-fix-your-profitability-4el2</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;How bias in Recommender Systems affects e-commerce, society and eventually your profits&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In 2021:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Almost 70%&lt;/strong&gt; of internet users in the EU, have bought or ordered goods or services for private use [source: &lt;a href="https://ec.europa.eu/eurostat/web/products-eurostat-news/-/ddn-20220202-1"&gt;Eurostat&lt;/a&gt;].&lt;/li&gt;
&lt;li&gt;In the US, e-commerce sales were estimated to be approximately &lt;strong&gt;870 billion&lt;/strong&gt; dollars [source: &lt;a href="https://www.digitalcommerce360.com/article/coronavirus-impact-online-retail/"&gt;Digital Commerce 360&lt;/a&gt;].&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Undoubtedly the COVID-19 pandemic has fuelled a significant increase in internet usage both in e-commerce sales and in content-provider systems. However, the key factor behind this increase is the utilization of Recommender Systems (RecSys) by an exponentially growing number of &lt;a href="https://www.mdpi.com/2079-9292/11/1/141/htm"&gt;services&lt;/a&gt;.&lt;br&gt;
Recommender (or recommendation) systems* provide recommendations to users, based on user behavior data, either &lt;a href="https://en.wikipedia.org/wiki/Recommender_system#:~:text=When%20building%20a%20model%20from%20a%20user%27s%20behavior%2C%20a%20distinction%20is%20often%20made%20between%20explicit%20and%20implicit%20forms%20of%20data%20collection."&gt;explicitly or implicitly&lt;/a&gt;. Ideally, RecSys offer continuous user engagement with content, as well as increasing loyalty and satisfaction of users. But what are the major contributing factors behind these?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;RecSys can provide personalized content. A &lt;a href="https://www.mckinsey.com/business-functions/marketing-and-sales/our-insights/the-value-of-getting-personalization-right-or-wrong-is-multiplying"&gt;recent study&lt;/a&gt; in the US showed that &lt;strong&gt;71%&lt;/strong&gt; of customers expect companies to deliver personalized interactions and &lt;strong&gt;76%&lt;/strong&gt; of them get frustrated when they don't get it.&lt;/li&gt;
&lt;li&gt;RecSys can offer a vast amount of similar items to those recently purchased, viewed or rated by the users and as a result they spend more time interacting with the products.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What is more, these systems can have a serious impact on sales promotions (e.g. what types of products users can select and consume), as sellers can persuade customers to buy specific items. All the aforementioned benefits of RecSys can lead to increased consumption and thus, higher profits for businesses.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--giOAMGTN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n4pe2av4ncbytuq8rudx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--giOAMGTN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n4pe2av4ncbytuq8rudx.png" width="880" height="427"&gt;&lt;/a&gt;&lt;br&gt;Image 1: Examples of RecSys benefits on popular systems
  &lt;/p&gt;

&lt;p&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  Bias in RecSys
&lt;/h2&gt;

&lt;p&gt;Despite the above mentioned benefits of RecSys, there are a number of performance and ethical issues that need to be addressed and investigated. Apart from well known performance issues in RecSys such as &lt;a href="https://www.ijcai.org/Proceedings/13/Papers/495.pdf"&gt;cold-start and data sparsity&lt;/a&gt;, little attention has been paid to ethical issues, until recently. In this article, we will focus on how the ethical issues related to recommender systems and their impact merely on us (either as consumers or citizens and users) can also significantly impact e-commerce platforms.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y6G5TrsA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rugcflsfha3faunf7ac0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y6G5TrsA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rugcflsfha3faunf7ac0.png" width="871" height="714"&gt;&lt;/a&gt;&lt;br&gt;Image 2: Long tail diagram (dataset: &lt;a href="https://grouplens.org/datasets/movielens/100k/"&gt;movielens-100k&lt;/a&gt;)
  &lt;/p&gt;

&lt;p&gt;One of the most important types of bias that arise in RecSys is &lt;strong&gt;popularity bias&lt;/strong&gt;. This type of bias describes the phenomenon of popular items ("head") being recommended frequently while less popular ("long-tail"), niche products, are recommended rarely or not at all. The 80/20 ratio is based on the Pareto principle: for many outcomes, roughly 80% of consequences come from 20% of cause.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;But why is popularity bias so important?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  Popularity bias in society
&lt;/h2&gt;

&lt;p&gt;It was previously mentioned that RecSys offer continuous user engagement and &lt;a href="https://www.forbes.com/sites/michaelfertik/2019/12/16/why-customer-engagement-should-be-every-businesss-top-priority-in-2020/?sh=387165706214"&gt;this is highly correlated with company profitability&lt;/a&gt;. The more the users are engaged the more likely it becomes for a platform to increase their sales as well as their profitability. But that doesn't come without a cost.&lt;br&gt;
First and foremost, popularity bias in RecSys highly affects society. For instance, it has played a vital role in the wide spread of misinformation and fake news as &lt;a href="https://www.nature.com/articles/s41598-018-34203-2"&gt;it hinders significantly the quality of the content provided to users&lt;/a&gt;. Additionally, the article "&lt;a href="https://www.technologyreview.com/2021/03/11/1020600/facebook-responsible-ai-misinformation/"&gt;How Facebook got addicted to spreading misinformation&lt;/a&gt;", describes a similar case. There we can see that machine learning models programmed to maximize engagement bear the risk to increase polarization, amplify fake news and hate speech and lead to unpredicted consequences, such as election sway and the genocide of the Rohingya Muslim minority in Myanmar.&lt;br&gt;
Popularity bias &lt;a href="https://www.nature.com/articles/s41598-018-34203-2"&gt;is also highly connected with a phenomenon called "echo chambers"&lt;/a&gt; where users only encounter opinions that reflect and reinforce their own, without encountering opposing opinions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lCLg5tbY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vnhf3xcxme5e8jmu2jy2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lCLg5tbY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vnhf3xcxme5e8jmu2jy2.png" width="679" height="322"&gt;&lt;/a&gt;&lt;br&gt;Image 3: Echo chambers on Twitter. Nodes represent a user who sent a message, and edges, a user retweeting another user (Blue represents liberals and red conservatives) [Source: &lt;a href="https://www.pnas.org/doi/10.1073/pnas.1618923114"&gt;PNAS&lt;/a&gt;]
  &lt;/p&gt;

&lt;p&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  Popularity bias impact in e-commerce
&lt;/h2&gt;

&lt;p&gt;The effects of popularity bias can also have a significant (negative) business impact especially on e-commerce systems. Apart from popularity bias, there are some other aspects of RecSys quality that need to be addressed, which are presented in Image 4.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SghqLL7m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kax3cggdlpjb2x4n2y2p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SghqLL7m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kax3cggdlpjb2x4n2y2p.png" width="880" height="300"&gt;&lt;/a&gt;&lt;br&gt;Image 4: Aspects of RecSys quality and their business impact
  &lt;/p&gt;

&lt;p&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  Study &amp;amp; Findings
&lt;/h2&gt;

&lt;p&gt;In order to investigate the business impact of popularity bias and of the other aspects of RecSys quality (Diversity, Coverage and Novelty) and to gain a better understanding of their sources, an extensive study was held by our team, using a real dataset provided by a major electronics retailer. The dataset contained 8.263 ratings, 3.078 products and 276 users.&lt;br&gt;
The first step of the process was to build 11 different RecSys models utilizing 11 different algorithms, from classical to the most recent, State-Of-The-Art, approaches (see Image 5 for more details). Each of these systems produced a list of 10 items for every user. Then, we had to evaluate the results produced by the respective RecSys. For this purpose 12 different metrics were selected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GOTQkgZC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8hl0zpjuy22kle7tb728.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GOTQkgZC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8hl0zpjuy22kle7tb728.png" width="861" height="333"&gt;&lt;/a&gt;&lt;br&gt;Image 5: Algorithms and evaluation metrics used in the study
  &lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Findings
&lt;/h2&gt;

&lt;p&gt;The main findings of our study are as follows:&lt;br&gt;
 &lt;br&gt;
🔎    From &lt;a href="https://arxiv.org/abs/1205.6700"&gt;Average Recommendation Popularity (ARP)&lt;/a&gt; (Image 6) it is apparent that &lt;strong&gt;&lt;u&gt;most of the algorithms recommended the most popular items&lt;/u&gt;&lt;/strong&gt;. More specifically, despite the fact that the average number of ratings per item in the dataset is 2.68, all the algorithms' scores, except ItemKNN, NGCF and Random are much higher than this value.&lt;br&gt;
  &lt;br&gt;
🔎    The algorithms used, not only recommend the most popular algorithms, but they tend to &lt;strong&gt;&lt;u&gt;completely ignore user preferences&lt;/u&gt;&lt;/strong&gt;, as shown in the &lt;a href="https://dl.acm.org/doi/abs/10.1145/3397271.3401177"&gt;Popularity Ranking-based Equal Opportunity (PopREO)&lt;/a&gt; chart in Image 6.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dB4du_xo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/brwiwxj6xtutfgns458y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dB4du_xo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/brwiwxj6xtutfgns458y.png" width="880" height="279"&gt;&lt;/a&gt;&lt;br&gt;Image 6: Popularity bias as measured by 2 different metrics (the lower the better)
  &lt;/p&gt;

&lt;p&gt;🔎    The results of this study indicate that RecSys developers should be aware of the &lt;a href="https://blogs.oracle.com/ai-and-datascience/post/unlocking-fairness-a-trade-off-revisited"&gt;bias-accuracy trade-off&lt;/a&gt; and should avoid using algorithms that enlarge this phenomenon (of bias), as shown in Image 7. It has to be mentioned that the poor results in accuracy are caused by the: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;very high percentage of dataset sparsity (almost 99%)&lt;/li&gt;
&lt;li&gt;uneven distribution of ratings&lt;/li&gt;
&lt;li&gt;relatively small number of ratings&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QFtEYvKt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ee8l772wk1ovbv6ntdiy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QFtEYvKt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ee8l772wk1ovbv6ntdiy.png" width="880" height="297"&gt;&lt;/a&gt;&lt;br&gt;Image 7: Accuracy-popularity bias trade-off
  &lt;/p&gt;

&lt;p&gt;🔎    Algorithms may not cover all the items given as input, this can be clearly seen in Image 8. Consequently, &lt;strong&gt;a significant amount of items will remain unseen for the majority of users&lt;/strong&gt;, affecting the number of sales and decreasing user satisfaction. Moreover, it was found that diversity is not always connected with popularity bias and except our baseline algorithm, itemKNN and NGCF all the other algorithms are not enhancing diversity in recommended items&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iqcrDgp5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c5f1kqqwxlhvd7hk4cgu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iqcrDgp5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c5f1kqqwxlhvd7hk4cgu.png" width="880" height="305"&gt;&lt;/a&gt;&lt;br&gt;Image 8: Some RecSys algorithms have very low scores in Coverage, Diversity and Novelty
  &lt;/p&gt;

&lt;p&gt;  &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In terms of accuracy, users should be highly encouraged to rate products. RecSys need vast amounts of data to produce meaningful results. But in most cases, there are a number of customers that haven't offered explicit feedback to the system. Cookies might be one of the most effective ways to overcome this problem by collecting user data. However this bears additional overhead for managing risks related to privacy and GDPR compliance.&lt;br&gt;
  &lt;br&gt;
As regards popularity bias and other aspects of RecSys quality, the proposed solutions depend on whether the e-commerce system owner has access to the model or not. If they have access to the model then a bias mitigation technique (&lt;a href="https://analyticsindiamag.com/a-guide-to-different-bias-mitigation-techniques-in-machine-learning/"&gt;pre-processing, in-processing, post-processing or a combination of these&lt;/a&gt;) can be used. Otherwise, some other mediocre solutions can be applied such as encouraging users to rate recently purchased products.&lt;br&gt;
  &lt;br&gt;
Last but not least, bias can affect item providers (either sellers or manufacturers). The rationale behind this is that if the product belongs to the long tail category or if it is new, it may never be recommended to users.&lt;br&gt;
In conclusion, e-commerce businesses need to control popularity bias, diversity and novelty because they highly affect user satisfaction and their profits as well.&lt;/p&gt;




&lt;p&gt;*Note: in this article we refer to collaborative filtering systems and more specifically top-n recommenders that produce a list of top-n recommendations, as an output, for each user.&lt;/p&gt;

</description>
      <category>recommendersystems</category>
      <category>bias</category>
      <category>ecommerce</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Don't be wrong because you might be fooled:  Tips on how secure your ML model</title>
      <dc:creator>Andreas Messalas</dc:creator>
      <pubDate>Tue, 17 May 2022 09:27:10 +0000</pubDate>
      <link>https://dev.to/code4thought/dont-be-wrong-because-you-might-be-fooled-tips-on-how-secure-your-ml-model-33j9</link>
      <guid>https://dev.to/code4thought/dont-be-wrong-because-you-might-be-fooled-tips-on-how-secure-your-ml-model-33j9</guid>
      <description>&lt;p&gt;&lt;em&gt;Figuring out the reasons why your ML model might be consistently less accurate in certain classes than others, might help you increase not only its total accuracy but also its adversarial robustness.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Machine Learning (ML) models and especially the Deep Learning (DL) ones can achieve impressive results, especially on unstructured data like images and text. However, there is a fundamental limitation with the (supervised) ML framework: *&lt;em&gt;the distributions we end up using ML models on are NOT always the ones we train it on. *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This leads to models that on the one hand seem accurate but on the other hand they are brittle.&lt;br&gt;
Adversarial attacks exploit this brittleness and introduce unnoticeable perturbations to the images that force the model to flip their predictions.&lt;/p&gt;

&lt;p&gt;For &lt;a href="https://arxiv.org/abs/2108.06247"&gt;example&lt;/a&gt;, lighting a "Stop" sign in a specific way can make a traffic sign model predict it as a "Speed 30" sign (Fig. 1 left). In another &lt;a href="https://pubmed.ncbi.nlm.nih.gov/30898923/"&gt;example&lt;/a&gt;, just by rotating an image or replacing some words in a sentence of a medical diagnosis with their synonyms, you can fool models to give a wrong medical diagnosis and risk scores respectively (Fig. 1 right).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Tk5ZZmdd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7xlb2qwj8utnpyt5iqze.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Tk5ZZmdd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7xlb2qwj8utnpyt5iqze.png" width="880" height="211"&gt;&lt;/a&gt;&lt;br&gt;Fig. 1 (references [&lt;a href="https://arxiv.org/abs/2108.06247"&gt;1&lt;/a&gt;], [&lt;a href="https://pubmed.ncbi.nlm.nih.gov/30898923/"&gt;2&lt;/a&gt;])
  &lt;/p&gt;

&lt;p&gt;It is evident that adversarial robustness of a model is associated with its security and safety, thus it is important to be aware of its existence and its implications.&lt;br&gt;
In this article, we will use a model trained on the &lt;a href="https://www.cs.toronto.edu/~kriz/cifar.html"&gt;CIFAR10&lt;/a&gt; public dataset to:&lt;br&gt;
📌 Investigate the intuition that the model's inability to correctly predict an image also leads to higher susceptibility to adversarial attacks.&lt;br&gt;
📌 We will measure the class disparities, meaning that we will check the performance of the model across the 10 classes.&lt;br&gt;
📌 In the end, we will conduct a root cause analysis that will pinpoint the causes of these class differences that hopefully will help us fix not only the miss-classifications but also will increase the adversarial robustness of the model.&lt;/p&gt;




&lt;h2&gt;
  
  
  The "cat", "bird" and "dog" classes are harder to correctly classify and easier to attack
&lt;/h2&gt;

&lt;p&gt;We trained a simple model, using the well-known &lt;a href="https://arxiv.org/abs/1512.03385"&gt;ResNet&lt;/a&gt; architectural pattern on a 20 layer deep network, which achieves a 89.4% accuracy on the validation set. We then plotted the miss-rate (per class) to check if there are any disparities between the classes (Fig. 2).&lt;br&gt;
It is evident that the "cat", "bird" and "dog" classes are harder to correctly classify than the rest of the classes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Iy9bASgO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iukz5m804dbkycm14yfw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Iy9bASgO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iukz5m804dbkycm14yfw.png" width="880" height="640"&gt;&lt;/a&gt;&lt;br&gt;Fig. 2: Miss-Rates across the 10 classes of CIFAR10
  &lt;/p&gt;

&lt;p&gt;We then applied two kind of adversarial attacks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An &lt;strong&gt;untargeted attack&lt;/strong&gt;, where an attack is considered successful when the predicted class label is changed (to any other label)&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;targeted attack with the least-likely target&lt;/strong&gt;, where we have a successful attack when the predicted class label is changed specifically to the label that the model has the least confidence for the specific instance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Afterwards, we plotted the attack-success rate per class, which measures the percentage of successful attacks per class (note: each class in the test set has 1,000 images). We can observe that the most successfully attacked classes are the same ones that are also miss-classified (Fig 3).&lt;/p&gt;

&lt;p&gt;This is intuitive and to some extent expected, since the fact that the model miss-classifies some instances means that it pays more attention to features that are not very relevant to that class, so adding more perturbed features makes the model's job much harder and the attacker's goal easier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Grn6-xck--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h6a6154396znjkk4p69e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Grn6-xck--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h6a6154396znjkk4p69e.png" width="880" height="315"&gt;&lt;/a&gt;&lt;br&gt;Fig. 3: Attack Success Rate for Targeted and Untargeted attacks
  &lt;/p&gt;

&lt;h2&gt;
  
  
  Root cause analysis
&lt;/h2&gt;

&lt;p&gt;We identified three possible root causes for the class disparities in the model's predictions:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Miss-labeled/Confusing Training Data
&lt;/h3&gt;

&lt;p&gt;Data collection is probably the most costly and time-consuming part of most machine learning projects. It's perfectly reasonable to expect that this arduous process will entail some mistakes. We discovered that the CIFAR10 training set contains some images that either are miss-labeled or they are themselves confusing even for humans (Fig. 4).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Gz8vhmpc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1kt5kiw5w6qdc6q40g41.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Gz8vhmpc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1kt5kiw5w6qdc6q40g41.png" width="496" height="416"&gt;&lt;/a&gt;&lt;br&gt;Fig.4: Confusing/Miss-labeled images from CIFAR10 training dataset
  &lt;/p&gt;

&lt;p&gt;This could be considered some kind of involuntary data-poisoning, since a significant amount of these poisoned images can shift the data distributions to a false direction, thus making it more difficult for the model to learn meaningful features and consequently make correct predictions.&lt;/p&gt;

&lt;p&gt;Data poisoning is also linked with adversarial attacks, although in that case the poisoned data are carefully crafted. It is shown that even a single poisoned image can affect multiple test-images (Fig. 5).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aKmef3Kl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/58450muumstsczjllx7g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aKmef3Kl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/58450muumstsczjllx7g.png" width="880" height="371"&gt;&lt;/a&gt;&lt;br&gt;Fig. 5 (&lt;a href="https://dl.acm.org/doi/10.5555/3305381.3305576"&gt;Koh et al&lt;/a&gt;)
  &lt;/p&gt;

&lt;h2&gt;
  
  
  2. Is this a "cat" or a "dog"?
&lt;/h2&gt;

&lt;p&gt;The "cat" class has the worst miss-rate of all the classes, followed by the "dog" class which has the third worst miss-rate.&lt;/p&gt;

&lt;p&gt;Since these animals share some similar features (four legs, ears, tail), our intuition is that our model could not extract meaningful features to distinguish these two animals or has learned better "dog" features than the "cat" ones.&lt;/p&gt;

&lt;p&gt;Using saliency map explanations, we can verify this intuition: we can see that the model has not learned some distinctive cat characteristics such as the pointy ears and nose and instead focuses on the whole animal's face or body (Fig. 6).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ScKxDIkt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ascf5syifrgb1bu47sow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ScKxDIkt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ascf5syifrgb1bu47sow.png" width="880" height="617"&gt;&lt;/a&gt;&lt;br&gt;Fig. 6: Saliency map explanations for images of "cat" miss-classified as "dog"
  &lt;/p&gt;

&lt;h2&gt;
  
  
  3. Is this a "bird" or an "airplane"?
&lt;/h2&gt;

&lt;p&gt;A similar situation is happening with the "bird" and "airplane" classes. The model in this case is confused by the blue background, since most airplane images contain an object in a blue background (Fig. 7).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y9E8I_wv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l3i2o0z4n6d34cwt8pim.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y9E8I_wv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l3i2o0z4n6d34cwt8pim.png" width="880" height="588"&gt;&lt;/a&gt;&lt;br&gt;Fig. 7: Saliency map explanations for images of "bird" miss-classified as "airplane"
  &lt;/p&gt;




&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;p&gt;👉 &lt;strong&gt;Good data means a good model: spend some time investigating your data and try to identify if there are any systematic errors in your training set&lt;/strong&gt;.&lt;br&gt;
👉 &lt;strong&gt;Use explanation methods as a debugger, in order to understand why your model model misses certain groups of instances more than others&lt;/strong&gt;&lt;br&gt;
👉 &lt;strong&gt;Adversarial attacks are a cost-effective way to check the adversarial robustness of your model.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>trustworthyai</category>
      <category>security</category>
      <category>adversarialrobustness</category>
    </item>
    <item>
      <title>Fairness, Accountability &amp; Transparency (F.Acc.T) under GDPR</title>
      <dc:creator>Andreas Messalas</dc:creator>
      <pubDate>Sat, 14 Nov 2020 17:13:39 +0000</pubDate>
      <link>https://dev.to/code4thought/fairness-accountability-transparency-f-acc-t-under-gdpr-3nk5</link>
      <guid>https://dev.to/code4thought/fairness-accountability-transparency-f-acc-t-under-gdpr-3nk5</guid>
      <description>&lt;h1&gt;
  
  
  Why the need for Regulation?
&lt;/h1&gt;

&lt;p&gt;Algorithmic decisions are already crucially affecting our lives. The last few year, news like the ones listed below are becoming more and more common:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  "There's software used across the country to predict future criminals. And it's biased against blacks", 2016 [source: &lt;a href="https://www.propublica.org/article/machine-bias-risk-assessments-in-criminal-sentencing"&gt;ProPublica&lt;/a&gt;].&lt;/li&gt;
&lt;li&gt;  "Amazon reportedly scraps internal AI recruiting tool that was biased against women", 2018 [source: &lt;a href="https://www.theverge.com/2018/10/10/17958784/ai-recruiting-tool-bias-amazon-report"&gt;The Verge&lt;/a&gt;]&lt;/li&gt;
&lt;li&gt;  "Apple Card is being investigated over claims it gives women lower credit limits", 2019 [source: &lt;a href="https://www.technologyreview.com/2019/11/11/131983/apple-card-is-being-investigated-over-claims-it-gives-women-lower-credit-limits/"&gt;MIT Technology Review&lt;/a&gt;]&lt;/li&gt;
&lt;li&gt;  "Is an Algorithm Less Racist Than a Loan Officer?", 2020 [source: &lt;a href="https://www.nytimes.com/2020/09/18/business/digital-mortgages.html"&gt;NY Times&lt;/a&gt;]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The above indicate why we see a rise to new regulations and laws that aim to control to some extent the growing power of the algorithms. One of the first and most well-known regulations is the General Data Protection Regulation (&lt;a href="https://gdpr.eu/"&gt;GDPR&lt;/a&gt;) introduced by the European Parliament and Council of the European Union in May, 2016.&lt;/p&gt;

&lt;p&gt;In this article, we will focus on how the properties of Fairness, Accountability and Transparency (better known as &lt;a href="https://facctconference.org/"&gt;F.Acc.T&lt;/a&gt;) are reflected in the GDPR and we will examine the scope of the restrictions they impose on the public and private sector.&lt;/p&gt;

&lt;h1&gt;
  
  
  Principles of GDPR
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://eur-lex.europa.eu/eli/reg/2016/679/oj#d1e1807-1-1"&gt;Article 5(1) &amp;amp; (2) in GDPR&lt;/a&gt; lists the basic principles relating to the processing of personal data:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;lawfulness, fairness and transparency, purpose limitation, data minimisation, accuracy, storage limitation, integrity and confidentiality and accountability&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;While the F.Acc.T properties are clearly listed as principles, we need to take a deeper look in the GDPR text to understand what these terms actually mean.&lt;/p&gt;

&lt;h1&gt;
  
  
  Transparency under the GDPR
&lt;/h1&gt;

&lt;p&gt;Transparency has been a matter of debate between law scholars, since it is not very clear if GDPR contains the right to explanation of automated decisions. For example, the following two papers [&lt;a href="https://academic.oup.com/idpl/article/7/2/76/3860948"&gt;3&lt;/a&gt;, &lt;a href="https://academic.oup.com/idpl/article-abstract/7/4/243/4626991?redirectedFrom=fulltext"&gt;4&lt;/a&gt;] of the same &lt;a href="https://academic.oup.com/idpl"&gt;journal&lt;/a&gt;have almost contradicting titles (see Image 1).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D4cAN73P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hnn3eadn21sx8zjhd5s5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D4cAN73P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hnn3eadn21sx8zjhd5s5.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Image 1: Contradicting papers [&lt;a href="https://academic.oup.com/idpl/article/7/2/76/3860948"&gt;3&lt;/a&gt;, &lt;a href="https://academic.oup.com/idpl/article-abstract/7/4/243/4626991?redirectedFrom=fulltext"&gt;4&lt;/a&gt;] about the right to explanation&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The epicentre of this debate is located in &lt;a href="https://eur-lex.europa.eu/eli/reg/2016/679/oj#d1e2838-1-1"&gt;Article 22 (3) GDPR,&lt;/a&gt; where it is stated that: "[...] the data controller shall implement suitable measures to safeguard the data subject's rights and freedoms and legitimate interests, at least the right to obtain human intervention on the part of the controller, to express his or her point of view and to contest the decision". Here, it is not written explicitly if the right to an explanation exists.&lt;/p&gt;

&lt;p&gt;However, in &lt;a href="https://www.privacy-regulation.eu/en/r71.htm"&gt;Recital 71 GDPR&lt;/a&gt;, it is stated categorically that (inter alia) this right exists: "[...] such processing should be subject to suitable safeguards, which should include specific information to the data subject and the right to obtain human intervention, to express his or her point of view, to obtain an explanation of the decision reached after such assessment and to challenge the decision.".&lt;/p&gt;

&lt;p&gt;Since only articles are binding in the GDPR and not the recitals --- which provide context and greater depth of meaning to the articles --- most scholars [&lt;a href="https://academic.oup.com/idpl/article/7/2/76/3860948"&gt;3&lt;/a&gt;, &lt;a href="https://www.aaai.org/ojs/index.php/aimagazine/article/view/2741"&gt;4&lt;/a&gt; &amp;amp; &lt;a href="https://academic.oup.com/idpl/article/7/4/233/4762325"&gt;5&lt;/a&gt; ] believe that a right to an explanation does not follow from GDPR.&lt;/p&gt;

&lt;p&gt;There is another conflicting point: &lt;a href="https://eur-lex.europa.eu/eli/reg/2016/679/oj#d1e2513-1-1"&gt;Article 15 (1)(h)&lt;/a&gt; states the data controller should provide to the data subject "meaningful information about the logic involved".&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Some scholars [&lt;a href="https://academic.oup.com/idpl/article/7/2/76/3860948"&gt;3&lt;/a&gt;, &lt;a href="https://academic.oup.com/idpl/article-abstract/7/4/243/4626991?redirectedFrom=fulltext"&gt;4&lt;/a&gt;] interpret that the "meaningful information" refers only to the model's general structure, hence the explanations for individual predictions are not necessary.&lt;/li&gt;
&lt;li&gt;  Other scholars [&lt;a href="https://academic.oup.com/idpl/article/7/4/233/4762325"&gt;5&lt;/a&gt;] believe that in order for the information to be meaningful it needs to allow the data subjects to exercise their rights defined by Article 22(3), which is the right to "express his or her point of view and to contest the decision". Since explanations provide this ability, it is argued that they must be presented.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Loophole in the system
&lt;/h3&gt;

&lt;p&gt;However, even in the best case scenario, where everyone agrees that the right to explanations exists in the GDPR, the regulation states that it is referring only to "decisions based solely on automated processing" (&lt;a href="https://eur-lex.europa.eu/eli/reg/2016/679/oj#d1e2838-1-1"&gt;Article 22 (1)&lt;/a&gt;). This means that any kind of human intervention in the decision, exempts the controller from the obligation of providing explanations. For example, if a creditor uses an automated credit scoring system only as advisory and in the end they are the ones to take the final decision for the credit applicant, then in this case GDPR does not force the system to provide explanations to the creditor as well as to the applicant.&lt;/p&gt;

&lt;h3&gt;
  
  
  Code4Thought's stance
&lt;/h3&gt;

&lt;p&gt;We believe that explanations are essential to ensure transparency and trust across all kinds of stakeholders of an algorithmic system. From our experience, users of advisory automated systems usually are prone to follow the system's decision, even when sometimes the decision does not make much sense. From faithfully following erroneous &lt;a href="https://abcnews.go.com/US/google-maps-shortcut-colorado-turns-muddy-mess-hundred/story?id=63946068"&gt;Google Maps directions&lt;/a&gt; to &lt;a href="https://www.propublica.org/article/machine-bias-risk-assessments-in-criminal-sentencing"&gt;judges using racially biased risk assessments&lt;/a&gt; tools, the immense power of today's algorithmic systems tends to overthrow people's ability for critical thinking and as a result it takes its place.&lt;/p&gt;

&lt;p&gt;So, regardless of human intervention, we firmly believe that when algorithmic systems affect real people, explanations are necessary as they establish trust between the system and the data controllers as well as the data subjects. Moreover, they can scrutinize the algorithms for systematic bias, consequently increasing fairness. Last but not least, understanding the algorithm's reasoning can be very helpful for debugging/tuning purposes, while in other cases (e.g. for medical diagnosis) it is imperative.&lt;/p&gt;

&lt;h3&gt;
  
  
  Artificial Intelligence (AI) as a "black-box"
&lt;/h3&gt;

&lt;p&gt;The intricate and obscure inner structure of the most common AI model (e.g. deep neural nets, ensemble methods, GANs, etc.) forces us more often than not to treat them as "black-boxes", that is, getting their predictions in a no-questions-asked policy. As mentioned above, this can lead erroneous behavior of the models, which may be caused by undesired patterns in our data. Explanations help us detect such patterns: in Image 2 we observe a photo of a man (lead singer of "&lt;a href="https://www.youtube.com/watch?v=Soa3gO7tL-c&amp;amp;list=OLAK5uy_moErjO5DD0FUSvcJ2St23Zfo0XvezasFM&amp;amp;index=3"&gt;Green Day&lt;/a&gt;", &lt;a href="https://twitter.com/billiejoe?lang=el"&gt;B.J. Armstrong&lt;/a&gt;), who was falsely classified as a "Female" by a gender recognition "black-box" model. The explanation shows us that the (red) pixels representing the make-up around his eyes contributed heavily towards predicting him as "Female", suggesting that our model chose the gender of a picture solely by detecting make-up or the not appearance of a moustache. This discovery would motivate us to take a closer look to our training data and update them.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--O5T1Xs1P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/f811ejquz16cegy1apqi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--O5T1Xs1P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/f811ejquz16cegy1apqi.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Image 2: Explanation of a false prediction by a gender recognition model (photo by &lt;a href="http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html"&gt;CelebA dataset&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Explainability methods
&lt;/h3&gt;

&lt;p&gt;There are various explainability methods and Image 3 presents a taxonomy of them. One of Pythia's transparency tools is called &lt;a href="https://ieeexplore.ieee.org/document/8900669"&gt;MASHAP&lt;/a&gt;, which is a model-agnostic method that outputs feature summary in both local and global scope.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WgGWwArt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pxv0zpy5t5un81fu8ve2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WgGWwArt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pxv0zpy5t5un81fu8ve2.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Fairness under the GDPR
&lt;/h1&gt;

&lt;p&gt;Fairness might be the most difficult principle to define, since determining what is fair is a very subjective process, which varies from culture to culture. Asking ten different philosophers what defines fairness, the result would probably be ten different answers.&lt;/p&gt;

&lt;p&gt;Even the translation of the word "fair" in various european languages is not straight-forward, where two or three different words are used, each referring to slightly different nuances. For example, in the &lt;a href="https://eur-lex.europa.eu/legal-content/DE/TXT/?uri=CELEX:32016R0679"&gt;German text&lt;/a&gt;, across different articles and recitals, "fair" is translated as "nach Treu un Glaube", "faire" or "gerecht".&lt;/p&gt;

&lt;p&gt;In the context of GDPR, scholars believe that fairness can have many possible nuances, such as non-discrimination, fair balancing, procedural fairness, etc. [&lt;a href="https://academic.oup.com/yel/article-abstract/doi/10.1093/yel/yey004/5068688?redirectedFrom=fulltext"&gt;1&lt;/a&gt;, &lt;a href="https://dl.acm.org/doi/abs/10.1145/3351095.3372868"&gt;2&lt;/a&gt;]. Fairness as non-discrimination refers to the elimination of "[...] discriminatory effects on natural persons on the basis of racial or ethnic origin, political opinion, religion or beliefs, trade union membership, genetic or health status or sexual orientation, or processing that results in measures having such an effect" as defined in &lt;a href="https://www.privacy-regulation.eu/en/r71.htm"&gt;Recital 71&lt;/a&gt; GDPR. Procedural fairness is linked with timeliness, transparency and burden of care by data controllers [&lt;a href="https://academic.oup.com/yel/article-abstract/doi/10.1093/yel/yey004/5068688?redirectedFrom=fulltext"&gt;1&lt;/a&gt;]. Fair balancing is based on proportionality between interests and necessity of purposes [&lt;a href="https://academic.oup.com/yel/article-abstract/doi/10.1093/yel/yey004/5068688?redirectedFrom=fulltext"&gt;1&lt;/a&gt;, &lt;a href="https://dl.acm.org/doi/abs/10.1145/3351095.3372868"&gt;2&lt;/a&gt;].&lt;/p&gt;

&lt;h3&gt;
  
  
  Code4Thought's stance
&lt;/h3&gt;

&lt;p&gt;In Code4Thought, we strive to pinpoint discriminatory behavior in algorithmic systems based on proportional disparities in their outcomes, so our notion of fairness is adjacent with the non-discimination and fair-balancing concepts of GDPR. More specifically, we try to examine if an algorithmic system is biased against a specific &lt;a href="https://en.wikipedia.org/wiki/Protected_group"&gt;protected group&lt;/a&gt; of people by measuring, if the system favors one group over another for a specific outcome (&lt;a href="https://www.technologyreview.com/2019/11/11/131983/apple-card-is-being-investigated-over-claims-it-gives-women-lower-credit-limits/"&gt;e.g.&lt;/a&gt; Apple Card giving higher credit to male customers than female ones).&lt;/p&gt;

&lt;p&gt;While there is a &lt;a href="https://www.youtube.com/watch?v=jIXIuYdnyyk"&gt;plethora of metrics&lt;/a&gt; for measuring fairness and various open-source toolkits containing such metrics (e.g. IBM's &lt;a href="https://aif360.mybluemix.net/"&gt;AIF360&lt;/a&gt;, &lt;a href="http://aequitas.dssg.io/"&gt;Aequitas&lt;/a&gt;by the University of Chicago), we choose the Disparate Impact Ratio (DIR) as our general fairness metric, which is a "ratio of ratios", i.e. the proportion of individuals that receive a certain outcome for two groups.&lt;/p&gt;

&lt;p&gt;The reason behind this choice is the fact that DIR is usually connected with a well-known regulatory rule, called the "four-fifths-rule" introduced by the U.S. Equal Employment Opportunity Commission (EEOC) in &lt;a href="https://www.govinfo.gov/content/pkg/CFR-2018-title29-vol4/xml/CFR-2018-title29-vol4-part1607.xml"&gt;29 C.F.R. § 1607.4(D)&lt;/a&gt; published in July 2018, rendering the metric in a way as an industry standard. Ideally the DIR should be equal to one (i.e. equal proportions for all the groups that are selected for a certain outcome). However according to the aforementioned rule, any value of DIR below 80% can be regarded as "evidence of adverse impact". Since DIR is a fraction and the denominator might be larger than the numerator, we consider an acceptable range of DIR from 80% to 120%.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mCXyyM3T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zjl236ramxf33dyhn0uv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mCXyyM3T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zjl236ramxf33dyhn0uv.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Image 4: Screenshot of Pythia’s monitoring tool&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In Image 4, a screenshot of our Pythia's monitoring tool is displayed, measuring the DIR across time of Twitter's internal algorithm of selecting preview photos indicating possible bias (see our &lt;a href="https://www.code4thought.eu/index.php/2020/10/02/twitter-bias/"&gt;article&lt;/a&gt; for more information).&lt;/p&gt;

&lt;h1&gt;
  
  
  Accountability under the GDPR
&lt;/h1&gt;

&lt;p&gt;Authority is increasingly expressed algorithmically and decisions that used to be based on human intuition and reaction are now automated. Data controllers should be able to guide or restrain their algorithms when necessary.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://eur-lex.europa.eu/eli/reg/2016/679/oj#d1e3043-1-1"&gt;Article 24(2)&lt;/a&gt; GDPR mentions that "[..] the controller shall implement appropriate technical and organisational measures to ensure and to be able to demonstrate that processing is performed in accordance with this Regulation". Also in Article 5(2) it stated that "The controller shall be responsible for, and be able to demonstrate compliance with, paragraph 1 ('accountability')."&lt;/p&gt;

&lt;p&gt;Imposing accountability in algorithmic systems is not as technically challenging as fairness or transparency. It can be accomplished through the use of evaluation frameworks, in the form of simple check-lists and questionnaires that require input from experts that build or manage the system.&lt;/p&gt;

&lt;p&gt;In July 2020 the High-Level Expert Group on Artificial Intelligence (&lt;a href="https://ec.europa.eu/digital-single-market/en/high-level-expert-group-artificial-intelligence"&gt;AI HLEG&lt;/a&gt;) appointed by the European Union has created an &lt;a href="https://ec.europa.eu/digital-single-market/en/news/assessment-list-trustworthy-artificial-intelligence-altai-self-assessment"&gt;assessment list&lt;/a&gt; for trustworthy AI. Prior to that, Code4Thought had published in an academic conference a similar (but less broad) &lt;a href="https://ieeexplore.ieee.org/document/8900715"&gt;assessment framework&lt;/a&gt; for algorithmic accountability in 2019.&lt;/p&gt;

&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;We presented how the F.Acc.T principles are viewed through the lenses of GDPR. It is clear that besides the technical challenges of incorporating these principles in an algorithmic pipeline, the legal view of their imposition is also in some areas obscure (e.g. transparency).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;At Code4Thought, we hope that the legal gaps will be filled and the related conflicts will be resolved soon, thereby creating more clear and explicit guidelines and regulations for AI Ethics. But until then, we urge organisations to proactively care about the "F.Acc.T-ness" of their algorithmic systems, since we strongly believe that it can boost their trustworthiness and yield to more stable, responsible algorithmic systems and perhaps a more fair society.&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;It should be noted that globally there also other similar regulations for data privacy and protection, some of which are listed below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Personal Information Protection and Electronic Documents Act (&lt;a href="https://laws-lois.justice.gc.ca/ENG/ACTS/P-8.6/FullText.html"&gt;PIPEDA&lt;/a&gt;) by the Parliament of Canada in 2001&lt;/li&gt;
&lt;li&gt;  California Consumer Privacy Act (&lt;a href="http://leginfo.legislature.ca.gov/faces/codes_displayText.xhtml?division=3.&amp;amp;part=4.&amp;amp;lawCode=CIV&amp;amp;title=1.81.5"&gt;CCPA&lt;/a&gt;) by California State Legislature in June, 2018&lt;/li&gt;
&lt;li&gt;  Brazilian General Data Protection Law (Lei Geral de Proteção de Dados or &lt;a href="https://iapp.org/media/pdf/resource_center/Brazilian_General_Data_Protection_Law.pdf"&gt;LGPD&lt;/a&gt;) passed in 2018&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://ec.europa.eu/info/publications/white-paper-artificial-intelligence-european-approach-excellence-and-trust_en"&gt;White paper&lt;/a&gt; οn Artificial Intelligence --- A European approach to excellence and trust by the European Union in February, 2020&lt;/li&gt;
&lt;li&gt;  Denmark's &lt;a href="https://www.folketingstidende.dk/samling/20191/lovforslag/L124B/20191_L124B_som_vedtaget.pdf"&gt;legislation&lt;/a&gt; about AI &amp;amp; Data Ethics being the first country in Europe to implement such laws in May, 2020&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>machinelearning</category>
      <category>gdpr</category>
      <category>fairness</category>
      <category>transparency</category>
    </item>
    <item>
      <title>Is Twitter biased against BIPOC? A fairness &amp; transparency evaluation of Twitter's black-box model </title>
      <dc:creator>Andreas Messalas</dc:creator>
      <pubDate>Tue, 13 Oct 2020 18:20:45 +0000</pubDate>
      <link>https://dev.to/code4thought/is-twitter-biased-against-bipoc-maybe-it-s-not-what-you-think-it-is-28hm</link>
      <guid>https://dev.to/code4thought/is-twitter-biased-against-bipoc-maybe-it-s-not-what-you-think-it-is-28hm</guid>
      <description>&lt;h1&gt;
  
  
  &lt;strong&gt;The controversy&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;Twitter was in the &lt;a href="https://mashable.com/article/twitter-photo-preview-algorithmic-racial-bias/?europe=true"&gt;headlines&lt;/a&gt; recently for apparent racial bias in the photo preview of some tweets. More specifically, Twitter’s machine learning algorithm that selects which part of an image to show in a photo preview favors showing the faces of white people over black people. For example the following &lt;a href="https://twitter.com/bascule/status/1307440596668182528?s=20"&gt;&lt;strong&gt;tweet&lt;/strong&gt;&lt;/a&gt;, contains an image of Mitch McConnell (white male) and Barack Obama (black male) twice, but Twitter selects Mitch McConnell both times in the tweet’s preview photo.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tbVr2utT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/x2tva6adqig1qfhalo9g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tbVr2utT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/x2tva6adqig1qfhalo9g.png" alt="twitter-bias-1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This tweet went viral with (currently) 81K retweets, almost 200K likes and was covered in articles by &lt;a href="https://www.bbc.com/news/technology-54234822"&gt;BBC&lt;/a&gt; and &lt;a href="https://edition.cnn.com/2020/09/21/tech/twitter-racial-bias-preview/index.html"&gt;CNN&lt;/a&gt;. It also got the attention of many users who posted different configurations of images with black and white people and trying to verify themselves whether there is truly bias in Twitter’s preview selection model. Some even tried posting images with &lt;a href="https://twitter.com/ameliorate_d/status/1307576187942703104?s=20"&gt;white and black dogs&lt;/a&gt; as well as &lt;a href="https://twitter.com/_jsimonovski/status/1307542747197239296?s=20"&gt;cartoon characters&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--X46V6zz8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/epl1ooy7wet0s0wpf50c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X46V6zz8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/epl1ooy7wet0s0wpf50c.png" alt="twitter-bias-2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Twitter’s official reply was: “&lt;em&gt;We tested for bias before shipping the model &amp;amp; didn’t find evidence of racial or gender bias in our testing. But it’s clear that we’ve got more analysis to do. We’ll continue to share what we learn, what actions we take, &amp;amp; will open source it so others can review and replicate.&lt;/em&gt;”&lt;/p&gt;


&lt;blockquote class="ltag__twitter-tweet"&gt;

  &lt;div class="ltag__twitter-tweet__main"&gt;
    &lt;div class="ltag__twitter-tweet__header"&gt;
      &lt;img class="ltag__twitter-tweet__profile-image" src="https://res.cloudinary.com/practicaldev/image/fetch/s--RgQlkR0N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://pbs.twimg.com/profile_images/1270788093931446273/bkOFGWwe_normal.jpg" alt="Twitter Comms profile image"&gt;
      &lt;div class="ltag__twitter-tweet__full-name"&gt;
        Twitter Comms
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__username"&gt;
        @twittercomms
      &lt;/div&gt;
      &lt;div class="ltag__twitter-tweet__twitter-logo"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P4t6ys1m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-f95605061196010f91e64806688390eb1a4dbc9e913682e043eb8b1e06ca484f.svg" alt="twitter logo"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__body"&gt;
      &lt;a href="https://twitter.com/bascule"&gt;@bascule&lt;/a&gt; We tested for bias before shipping the model &amp;amp; didn't find evidence of racial or gender bias in our testing. But it’s clear that we’ve got more analysis to do. We'll continue to share what we learn, what actions we take, &amp;amp; will open source it so others can review and replicate.
    &lt;/div&gt;
    &lt;div class="ltag__twitter-tweet__date"&gt;
      17:54 PM - 20 Sep 2020
    &lt;/div&gt;


    &lt;div class="ltag__twitter-tweet__actions"&gt;
      &lt;a href="https://twitter.com/intent/tweet?in_reply_to=1307739940424359936" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-reply-action.svg" alt="Twitter reply action"&gt;
      &lt;/a&gt;
      &lt;a href="https://twitter.com/intent/retweet?tweet_id=1307739940424359936" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-retweet-action.svg" alt="Twitter retweet action"&gt;
      &lt;/a&gt;
      170
      &lt;a href="https://twitter.com/intent/like?tweet_id=1307739940424359936" class="ltag__twitter-tweet__actions__button"&gt;
        &lt;img src="https://practicaldev-herokuapp-com.freetls.fastly.net/assets/twitter-like-action.svg" alt="Twitter like action"&gt;
      &lt;/a&gt;
      1416
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/blockquote&gt;


&lt;h1&gt;
  
  
  &lt;strong&gt;Fairness evaluation&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;In &lt;a href="https://www.code4thought.eu"&gt;&lt;strong&gt;Code4Thought&lt;/strong&gt;&lt;/a&gt;, we are deeply concerned with bias and discrimination in algorithmic systems, especially when these systems can crucially affect real people. So we did our own testing with our fairness and transparency service called Pythia and we investigated if Twitter’s model is truly bias-free as Twitter’s official reply suggested.&lt;/p&gt;

&lt;p&gt;In order to have a more systematic approach, we used a specialized dataset containing images of faces of different racial groups, which is balanced for all groups. To keep things simple we used only adult black and white males for our experiments and we constructed a new dataset containing combined photos — collages — of adult black males at the top, white adult males in the bottom and a white background between them. Our new dataset contained 4,009 pictures of black and white adult males, which we uploaded in an account on Twitter called &lt;a href="https://twitter.com/bias_tester"&gt;&lt;strong&gt;@bias_tester&lt;/strong&gt;&lt;/a&gt;. Finally, we manually labeled the preview photo of each tweet as ‘Black male’ if Twitter’s underlying model selected the black male, otherwise we labeled it as ‘White male’.&lt;/p&gt;

&lt;p&gt;Using Code4Thought’s Pythia service on the new labeled dataset containing the 4,009 collage-photos and the preview label (‘Black male’, ’White male’), we examined Twitter’s model on fairness and transparency.&lt;/p&gt;

&lt;p&gt;The metric we choose to measure fairness is &lt;a href="https://en.wikipedia.org/wiki/Disparate_impact"&gt;Disparate Impact&lt;/a&gt; Ratio (DIR), which basically measures how differently the model behaves across different groups of people – in our case black and white adult males. More specifically it is the proportion of individuals that receive a positive outcome for two groups.&lt;/p&gt;

&lt;p&gt;If there is great disparity in the model’s outcome for each group, then we can claim that there might be bias in the model. According to “4-5ths rule” by the U.S. Equal Employment Opportunity Commission  (EEOC), any value of DIR below 80% can be regarded as evidence of adverse impact. Since DIR is a fraction and the denominator might be larger than the numerator, we consider an acceptable range of DIR from 80% to 120%.&lt;/p&gt;

&lt;p&gt;Twitter allows its users to upload a certain amount of tweets per day, so we sent batches of 300 tweets of our collages every 3 hours. After each batch was uploaded, we manually measured the number of black and white males in Twitter’s preview  photo and sent this data to our Pythia platform. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZyURo-YR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wffutas1y7m85ten9nd1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZyURo-YR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/wffutas1y7m85ten9nd1.png" alt="Pythia's Fairness platform"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;After all batches were sent, the total DIR was 0.61&lt;/strong&gt;, which is much less than the accepted threshold. This analysis suggests that Twitter’s preview photo selection model is more likely to choose a white male than a black male. We can observe that, while some batches of data (blue line) were compliant, the total DIR (orange line) was continuously not compliant, which is an indication of bias towards black males.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;Using explanations to verify bias&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;We would like to get a sense of how the underlying model “thinks” and try to understand its decision process, in order to find reasoning for the discovered bias of the fairness evaluation. We modified our existing dataset by using the individual images of the same black and white adult males from the collages, and labeled them with 1 if the photo was selected in the preview, otherwise we labeled them with 0. We used Pythia’s model-agnostic explainer , which utilizes surrogate models (i.e. models that try to mimic the original model) and Shapley values, in order to explain the predictions of the Twitter’s preview selection model, even without having direct access to it (more info about our method can be found in this corresponding &lt;a href="https://ieeexplore.ieee.org/abstract/document/8900669"&gt;paper&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Clearly the size of our dataset (8,018 pictures) is not enough to give us information in a confident way about how Twitter’s internal model makes its predictions, however it can give us already some insights.&lt;/p&gt;

&lt;p&gt;Below are some examples of explanations from our dataset. The green and red pixels in the grayscale image demonstrate positive and negative contributions correspondingly towards selecting the image as the preview photo. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F95CXjU5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/df2ty3fgq9wsiqphrzaz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F95CXjU5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/df2ty3fgq9wsiqphrzaz.png" alt="Pythia's explanation"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---iTx6tzY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/aoz35jglvngorwjjzhdz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---iTx6tzY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/aoz35jglvngorwjjzhdz.png" alt="Pythia's explanation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since we do not know what is the goal of Twitter’s preview selection model (e.g. facial recognition), it is difficult to understand the explanations. On a first glance, we might observe that the model tries to identify facial characteristics such as the eyes, nose and cheeks.&lt;/p&gt;

&lt;p&gt;Looking at the first two examples above, where the model selected the white male, we could say that pixels on the cheeks with a darker tone (whether because of the black skin or because of the shade) as well as the eyes of the black males contribute negatively and conclude that the model is biased against dark skin pixels. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NtfchkWs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rzalghnvbjofrqq18jxj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NtfchkWs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rzalghnvbjofrqq18jxj.png" alt="Pythia's explanation"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2OVcLoSr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/r824b1u00thltd4yubhs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2OVcLoSr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/r824b1u00thltd4yubhs.png" alt="Pythia's explanation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, we can not confirm this assertion by looking at the last two examples, where the model selected the black male. Moreover, some explanations show that pixels in the background also are contributive, which makes us wonder if any facial characteristic plays an important role at all in the model’s selection process&lt;/p&gt;

&lt;p&gt;This unclear behavior led us to analyze a bit further our data and look for other attributes of the images which are not correlated with the facial features of the person in the image. So we measured the &lt;a href="https://en.wikipedia.org/wiki/Acutance"&gt;sharpness&lt;/a&gt; and &lt;a href="https://en.wikipedia.org/wiki/Contrast_%28vision%29"&gt;contrast&lt;/a&gt; of the photos and using Pythia’s explainer again we checked whether either one of them played an important role in the predictions. The following &lt;a href="https://chartio.com/learn/charts/what-is-a-scatter-plot/#:~:text=A%20scatter%20plot%20%28aka%20scatter,to%20observe%20relationships%20between%20variables."&gt;scatter plot&lt;/a&gt; shows how sharpness plays an important role in the model’s decision process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EfYmk7ZT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3gq2xyow0vb3p3fgd5yc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EfYmk7ZT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3gq2xyow0vb3p3fgd5yc.png" alt="sharpness"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The vertical axis depicts the output of the (surrogate) model and the horizontal axis the sharpness of each image. We can observe that for less sharp photos (i.e. sharpness less than 3) the contribution is negative (red color) leading to a low model output score, while for photos with a higher value of sharpness (i.e. more than 5) the contribution is positive (green color) and the output score is higher.&lt;/p&gt;

&lt;p&gt;In fact, we measured the sharpness of the two pictures shown in the &lt;a href="https://twitter.com/bascule/status/1307440596668182528?ref_src=twsrc%5Etfw%7Ctwcamp%5Etweetembed%7Ctwterm%5E1307440596668182528%7Ctwgr%5Eshare_3&amp;amp;ref_url=https%3A%2F%2Fwww.code4thought.eu%2Findex.php%2F2020%2F10%2F02%2Ftwitter-bias%2F"&gt;tweet&lt;/a&gt; that started this whole debate, and we found that McConnell’s photo was sharper than Obama’s  –  the exact sharpness values were  5.65 and  3.54 correspondingly.   As for the contrast of the photos, there was no strong correlation with the model’s predictions and as a result it did not play an important role in the model.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;Bottomline: is there any discrimination in Twitter’s model?&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;Our analysis on the deducted explanations suggests that the model does not depend on any facial feature of the people inside an image, rather than on the total image quality, and probably on the sharpness of an image. Again, this conclusion derives from analysing a small dataset and we can not confidently assert that Twitter’s model has this behaviour overall.&lt;/p&gt;

&lt;p&gt;If we assume that our analysis is valid for larger datasets, then there is an important question that must be answered: Does the fact that Twitter’s model is not directly discriminatory, since it does not rely on racial or facial features, means that there is no ethical issue and that this controversy should end?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In Code4Thought we firmly believe that any trace of unfairness towards specific groups of people in an algorithmic process should be addressed and then solved, even if the process does not utilise any direct discriminatory procedures. We look forward to seeing Twitter’s further reactions and analysis on the issue in question and we hope that we did our small contribution to the public discourse on how we can make technology more fair and responsible.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>twitter</category>
      <category>bias</category>
      <category>machinelearning</category>
      <category>fairness</category>
    </item>
    <item>
      <title>Using explanations for finding bias in black-box models
</title>
      <dc:creator>Andreas Messalas</dc:creator>
      <pubDate>Thu, 03 Oct 2019 16:47:45 +0000</pubDate>
      <link>https://dev.to/code4thought/using-explanations-for-finding-bias-in-black-box-models-5449</link>
      <guid>https://dev.to/code4thought/using-explanations-for-finding-bias-in-black-box-models-5449</guid>
      <description>&lt;p&gt;There is no doubt, that machine learning (ML) models are being used for solving several business and even social problems. Every year, ML algorithms are getting more accurate, more innovative and consequently, more applicable to a wider range of applications. From  &lt;a href="https://ai.googleblog.com/2018/04/an-augmented-reality-microscope.html" rel="noopener noreferrer"&gt;detecting cancer&lt;/a&gt; to  &lt;a href="https://www.independent.co.uk/news/business/news/jp-morgan-software-lawyers-coin-contract-intelligence-parsing-financial-deals-seconds-legal-working-a7603256.html" rel="noopener noreferrer"&gt;banking&lt;/a&gt;  and  &lt;a href="https://arxiv.org/pdf/1604.07316v1.pdf" rel="noopener noreferrer"&gt;self-driving cars&lt;/a&gt;, the list of ML applications is never ending.&lt;/p&gt;

&lt;p&gt;However, as the predictive accuracy of ML models is getting better, the explainability of such models is seemingly getting weaker. Their intricate and obscure inner structure forces us more often than not to treat them as “black-boxes”, that is, getting their predictions in a no-questions-asked policy. Common “black-boxes” are Artificial Neural Networks (ANNs), ensemble methods. However seemingly interpretable models can be rendered unexplainable, like Decision Trees for instance when they have a big depth.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F57ncbsgky88p10tj03eh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F57ncbsgky88p10tj03eh.png" alt="Black-box models"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Neural Networks, Ensemble methods and most of the recent ML models behave like black-boxes&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The need to shed a light into the obscurity of the “black-box” models is evident:  &lt;a href="https://www.oreilly.com/radar/how-will-the-gdpr-impact-machine-learning/" rel="noopener noreferrer"&gt;GDPR’s article 15 and 22&lt;/a&gt;  (2018),  &lt;a href="https://www.oecd.org/going-digital/ai/principles/" rel="noopener noreferrer"&gt;OECD AI principles&lt;/a&gt;  (2019) and  &lt;a href="https://www.congress.gov/bill/116th-congress/house-bill/2231/all-info" rel="noopener noreferrer"&gt;Senate’s of the USA Algorithmic Accountability Act&lt;/a&gt;  bill (2019) are some examples which indicate that ML Interpretability, along with ML Accountability and Fairness, have already (or should) become integral characteristics for any application that makes automated decisions.&lt;/p&gt;

&lt;p&gt;Since many organizations will be obliged to provide explanations about the decisions of their automated predictive models, there will be a serious need for third-party organizations to perform the interpretability tasks and audit those models on their behalf. This provides an additional level of integrity and objectivity to the whole audit process, as the explanations are provided by an external factor. Moreover, not every organization (especially startups) has the resources to deal with interpretability issues, rendering third-party auditors necessary.&lt;/p&gt;

&lt;p&gt;However, in this manner intellectual property issues arise, since organizations will not want to disclose any information about the details of their model. Therefore, from the wide range of interpretability methods, the model-agnostic approaches (i.e. methods that are oblivious of the model’s details) are deemed to be appropriate for this purpose.&lt;/p&gt;

&lt;p&gt;Besides explaining the predictions of a black-box model, interpretability can also provide us with insight about erroneous behavior of our models, which may be caused by undesired patterns in our data. We will examine an example, where interpretability helps us identify gender bias in our data, using a model-agnostic method, which utilizes surrogate models and Shapley values.&lt;/p&gt;

&lt;p&gt;We use the “&lt;em&gt;Default of Credit Card Clients Dataset&lt;/em&gt;”, which contains information (demographic factors, credit data, history of payment, and bill statements) about 30,000 credit card clients in Taiwan from April 2005 to September 2005. The target of the models in our examples is to identify the defaulters (i.e. bank customers, who will not pay the next payment of their credit card).&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Gender biased data&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The existence of biased datasets is not uncommon. It can be caused from false preprocessing or even from collecting from a &lt;a href="https://rss.onlinelibrary.wiley.com/doi/full/10.1111/j.1740-9713.2016.00960.x" rel="noopener noreferrer"&gt;poor data source&lt;/a&gt;, creating &lt;a href="https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2477899" rel="noopener noreferrer"&gt;skewed and tainted samples&lt;/a&gt;. Examining the reasons behind a model’s prediction, may inform us about possible bias in the data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fumf3ew2btp88o825adt8.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fumf3ew2btp88o825adt8.PNG" alt="Dataset"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Defaulters based on Gender: The red and blue bars represent the original distributions of female and male customers, while the purple one depicts the new constructed biased distribution of male customers.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the “&lt;em&gt;Default of Credit Card Clients Dataset&lt;/em&gt;”, 43% of the defaulters are male and 57% are female. This does not consist in a biased dataset, since the non-defaulters have a similar distribution (39% and 61% respectively).&lt;/p&gt;

&lt;p&gt;We distort the dataset, by picking at random 957 male defaulters (i.e. one third of the overall male defaulters) and we alter their label. This creates a new biased dataset with 34% / 66%  male/female defaulters and 41% / 59% male/female non-defaulters respectively.&lt;br&gt;&lt;br&gt;
We  then remove the gender feature from the dataset and take the predictions of a black-box model trained on this biased dataset (to which we are indifferent about its structure). We then train a surrogate XGBoost model, from which we extract the Shapley values that help us explain the predictions of the original model. More precisely, we use the Shapley values to pinpoint the most important features and then we use natural language to describe them in the explanations.&lt;/p&gt;

&lt;p&gt;We examine the explanations for a false negative prediction (i.e. falsely predicted as non-defaulter) of a male customer and a false positive prediction (i.e. falsely predicted as defaulter) of a female customer. They are both single university graduates with similar credit limit. However, the male customer delayed the last 4 payments, while the female delayed only the final one.   &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
  &lt;tr&gt;
    &lt;th&gt;&lt;/th&gt;
    &lt;th&gt;&lt;/th&gt;
    &lt;th&gt;&lt;/th&gt;
    &lt;th&gt;&lt;/th&gt;
    &lt;th colspan="6"&gt;
&lt;span&gt;PAYMENT STATUS&lt;/span&gt;&lt;br&gt;&lt;span&gt; (months  delayed)&lt;/span&gt;
&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;ID&lt;/td&gt;
    &lt;td&gt;CREDIT LIMIT&lt;/td&gt;
    &lt;td&gt;EDUCATION&lt;/td&gt;
    &lt;td&gt;MARRIAGE&lt;/td&gt;
    &lt;td&gt;SEPT.&lt;/td&gt;
    &lt;td&gt;AUG.&lt;/td&gt;
    &lt;td&gt;JULY&lt;/td&gt;
    &lt;td&gt;JUNE&lt;/td&gt;
    &lt;td&gt;MAY&lt;/td&gt;
    &lt;td&gt;APRIL&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;26664&lt;br&gt;(male)&lt;/td&gt;
    &lt;td&gt;80000&lt;/td&gt;
    &lt;td&gt;university&lt;/td&gt;
    &lt;td&gt;single&lt;/td&gt;
    &lt;td&gt;5&lt;/td&gt;
    &lt;td&gt;4&lt;/td&gt;
    &lt;td&gt;3&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;paid duly&lt;/td&gt;
    &lt;td&gt;U.R.C&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;599&lt;br&gt;(female)&lt;/td&gt;
    &lt;td&gt;60000&lt;/td&gt;
    &lt;td&gt;university&lt;/td&gt;
    &lt;td&gt;single&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;U.R.C&lt;/td&gt;
    &lt;td&gt;U.R.C&lt;/td&gt;
    &lt;td&gt;U.R.C&lt;/td&gt;
    &lt;td&gt;U.R.C&lt;/td&gt;
    &lt;td&gt;U.R.C&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;center&gt;(*U.R.C: Use of Revolving Credit*)
&lt;/center&gt;

&lt;p&gt;For the male customer as the explanation below indicates,  the delay for the September payment had a negative impact of 33% (i.e. contributing towards ‘Default’). However, counterintuitively the delay for the August payment had a positive impact.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fa6h311sl21pqb608d955.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fa6h311sl21pqb608d955.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the female customer, the 2-month delay of September also contributed negatively with 47%, but in a much greater percentage compared to the 5-month delay of the male customer (33%). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Feymdslnl0pdk93x6cvm2.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Feymdslnl0pdk93x6cvm2.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Summary&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Although, the gender feature was not included in the training of the model, we observed with the help of the explanations, that the gender bias was encoded into other features (e.g. positive contribution for the delay of payment for the male customer). Moreover, by observing the percentage of the impact of the explanations, we detected a harsher confrontation of the model towards the female customer (e.g. greater negative impact for a lesser delay of payment). This strange behavior should alarm us and motivate us get a better sample of the defaulters. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Takeaway&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In cases where the dataset contains real people, it is important to ensure that the model does discriminate against one group over others. Explanations facilitate us detect bias, even if it is skewed, pinpoint unintended decision patterns of our black-box model and motivate us to fix our data.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>interpretability</category>
      <category>fairness</category>
      <category>bias</category>
    </item>
  </channel>
</rss>
