Skip to content
ImagineWorld

The Need for Explainable AI

node_idnode-book_neuro-symbolic-ai_chapter-04-the-need-for-explainable-ai
node_typechapter-node
schema_profileworld.chapter_node.v1
statusactive
entropyhigh
manifoldworld
domainimagineworld.net
authorityinforms
layercorpus
chapter_num4
chapter_titleThe Need for Explainable AI
pillar_membershipA — predictive_processing_active_inference + D — neuroscience_anchors
governed_byCORPUS
constitutional_citationCONSTITUTION
local graph

In the past few years, artificial intelligence (AI) has achieved impressive feats, much more than it ever did in the preceding decades. If we consider what happened in the last pandemic, AI was instrumental in helping the pharmaceutical industry develop a vaccine in record time. But AI’s extensive use is widespread in detecting all sorts of cancers, developing new drugs, and rehabilitating patients. On another front, we now have self-driving cars taking us from one place to the other, our airplanes are flown by an auto-pilot 90% of the time, and the level of safety we’ve reached is unheard of. If we look at basic human tasks, the ImageNet competition showed that even when it comes to simply labeling images (something we learned to do when we were still infants), an AI is capable of achieving much more accurate results. The list of examples can keep on going forever since AI systems can be found in most applications. The truth is that AI can augment itself to most human functions. It’s not only enhancing our throughput but also, in some cases, achieving results that are way better than what any human alone can ever attain.

No one can deny that the results obtained in various disciplines are impressive. However, we must be careful. The democratization of AI also means that anyone can download a machine learning model and use it in their applications. While there’s nothing wrong with that, you must be extremely careful that the proper scientific process is followed. Otherwise, as the IBM programmer George Fuechsel once said, “Garbage in, garbage out!”

The democratization of AI can be compared to a teenager learning to drive a car. The practice session is held in a confined environment without too many obstacles. This is done to prevent the young driver from causing potential damage. The young driver is always followed by an instructor who suggests minor improvements as they go along. When the instructor is satisfied with the level of driving achieved by the young apprentice, the instructor then increases the difficulty level by first driving on secondary roads and then on main roads. When it comes to AI, someone who is capable of switching on the car thinks that they can drive perfectly well on the main road. Many programmers are not mentored by an AI expert – they download one of the many freely available models, train it, and if it returns an accuracy close to 100%, then it is deemed successful.

But the truth is very far from that – high accuracy is not necessarily an indication of a successful model. The most common reason for high values is overfitting. This means that the model did not manage to generalize, and because of this, it fits the training data exactly. Imagine that we have the task of distinguishing between pictures of cats and dogs. The problem here is that while such a model is extremely good at classifying the pictures found in the training set if it is shown a new picture of an unseen dog, it is incapable of classifying it correctly. Of course, this is just one of the potential problems and there might be many others. Because of this, basing our success simply on accuracy levels might be misleading. We need an AI capable of giving us a justification for how it reached a particular conclusion, which is why we need explainable artificial intelligence (XAI).

XAI is a set of techniques designed to help human users comprehend and trust the results obtained by AI algorithms. It is used to describe an AI model (particularly those that are complex, such as deep learning algorithms), and its expected impact gives the results and shows any potential biases. By doing so, it reinforces the validity of the results while auditing the fairness, accentuating transparency, and reassuring the users that the results can be trusted for decision-making processes.

In the following sections, we’ll have a look at various aspects of XAI so that we can understand why it is needed. We will do so by looking at the potential dangers of using machine learning models without proper scientific processes. This chapter will focus on the need for XAI techniques, which help users comprehend and trust the results obtained by AI algorithms.

The overall goal of this chapter is to explain the importance of XAI and how it reinforces the validity of results while auditing fairness, increasing transparency, and reassuring users that results can be trusted for decision-making processes. This information is important because it highlights the potential risks of relying solely on high accuracy levels without considering the generalization of models, and it emphasizes the need for XAI techniques to ensure the validity and reliability of AI-generated results.

Specifically, we will cover the following topics in this chapter:

  • What is XAI?
  • Why do we need XAI?
  • The state-of-the-art models in XAI

XAI is a recent field of study that deals with designing AI models that are easier to understand. The need for such a field arose from the fact that, in recent years, there has been a move toward statistical AI since the results obtained from such a system were incredible, not only on a par with humans in most instances but also reaching super-human levels in various applications. Unfortunately, since statistical approaches use probabilities, even though superior, the resulting model is rather hard to read. As such, it is difficult to interpret its correctness in all cases.

For example, if tasked with creating a loan application system, we might devise a set of rules similar to those displayed in Figure 4.1:

Figure 4.1: Rule-based loan application process

These rules are easy to understand, even for someone who is not computer literate. These are usually called rule-based systems, which fall under the symbolic AI paradigms. However, when the process starts to become complex, it might be hard to develop these rules. Sometimes, it would be impossible to handcraft them one by one. Because of this, AI scientists resort to statistical AI. They gather a bunch of historic data, process it, and generate an automated set of rules, similar to those in Figure 4.2. As can be seen from the diagram, the rules are practically the same, even though they might be more accurate. However, they are much more challenging to understand with the naked eye, if not impossible!

Figure 4.2: Statistical-based loan application process

Of course, this diagram only shows a toy example to explain the concept. But imagine one of the big language models having a network of around 1 trillion parameters. How can a human being ever think of understanding what’s happening? It’s simply impossible. We refer to these AI systems as a black box model.

Think about it as a sausage machine. Insert some input from the left, let it process it, and get some output from the right. However, since it’s a black box, we cannot look into it and are not privy to the internal workings of the algorithm. The opposite of a black box is a glass box. It works in precisely the same way, but since the outer shell is made of glass, we can peep into its workings and see precisely what’s happening inside. A glass box process is explainable by design and therefore does not need XAI. So, to recap, rule-based systems like the one in Figure 4.1 are glass boxes, and statistical ones like those in Figure 4.2 are like black boxes.

XAI deals with finding ways of making black boxes less opaque. This is achieved using various approaches. XAI algorithms might look at the properties of the model and try to interpret them by giving meanings to the different components (such as the neurons or the attribute changes). They might also try to create an understandable representation of the internal logic behind a single decision or even try to describe all the internal workings of the system. Some of these algorithms do so by generating instructions using a rule-based approach. Others generate input-output pairs to denote the internal workings of the system using a case-based exploratory approach. Then, it’s up to the user to infer logic from such pairs. Considering the previous example of annotating images of cats and dogs, a rule-based approach would create a set of generic rules to distinguish between the two types of animals. On the other hand, the case-based approach would gather pictures that match the input requirements and present those.

Unfortunately, creating glass boxes is not so straightforward. An expert can create hand-crafted rules, but this is a rather difficult task that becomes somewhat impossible when dealing with complex systems. Rule-based, case-based, and other approaches do not always produce good results, hence why there is a drive for a new breed of algorithms such as neuro-symbolic AI, which will be discussed in the next chapter.

We have seen various technical reasons why we need XAI. All of them are very valid and extremely important. However, there are others that we should consider:

  • Human readability: Since AI permeates every aspect of our society, it is not surprising that it is extensively used for decision-making. However, our world is becoming increasingly more complex. With the rise in Internet of Things (IoT) devices, where everything is connected to the internet, we are in a position to measure everything much more accurately than was practically possible a few years back. Of course, this raises a new problem: all the data that’s harvested cannot be physically processed manually. It’s simply impossible. The only practical solution we have is to use AI systems capable of crunching vast volumes of numbers in an incredibly short amount of time. Thus, our reliance on AI is steadily increasing. Directors or Chief Executive Officers (CEOs) of various companies need to collate the suggestions provided by the AI and make informed decisions. They need to trust the AI and assume that the results are correct. XAI comes to the rescue because it gives the reasoning behind certain decisions that might appear opaque. Doing so will also increase transparency since the various components of a decision are explained and can be scrutinized. Such an approach gives decision-makers the peace of mind to better understand automated business decisions.

Justifiability: Every decision needs to be justified. This is not just a good practice that can be used to increase transparency and eventually trust but is also a moral right. If a person is affected in some way by a decision made by someone else, they need to understand why that decision was taken on their behalf. Not just that, but the onus of certain decisions is placed on the people who take them.

If we consider the General Data Protection Regulation (GDPR) that has been in force in the European Union since 2018, it specifically requests the data collector to have valid reasons for gathering data – they have to collect only what they need and nothing more. Furthermore, after using the data, they must delete it. Failure to abide by this regulation might lead to serious legal consequences. There have been various cases where companies made decisions without adequately informing their employees and clients. By doing so, they exposed themselves to legal action, and some got sued. Thus, if a machine suggests a particular course of action and the decision maker is unaware of the justifications, they can be liable to risk.

Discrimination: In today’s world, any form of discrimination is unacceptable. We are all equals, and everyone should enjoy the same rights, irrespective of their differences. It is unfortunate that inequalities still exist and stereotypes prevail. This can easily be tested by going on Google and searching for images of doctors and nurses. The prevailing number of doctor images show male doctors; the opposite happens for nurses. In itself, this reflects the gender disparities that exist in our world. But the problem arises when this publicly available data is fed to an AI. Intelligent systems do not make distinctions between one gender or another – for them, they’re just numeric representations. Thus, if you were to train an AI on that data, the imbalance in the training dataset will automatically result in discrimination.

This is precisely what happened with Amazon. The multinational e-commerce company employs more than 1.5 million people globally. So, you can imagine the scale of recruitment that they adopt. To streamline this process, Amazon engineers came up with the idea of creating an AI capable of sifting through the applications and shortlisting the most promising candidates, thus helping human resources (HR) save time. Like most AI systems, they needed data for training, so they thought of using the curricula vitae (CVs) of people who already work for Amazon. Their reasoning was relatively sound. If someone passed through the selection process and already worked for Amazon, the new candidates should have similar attributes. The system was eventually trained and produced a good enough accuracy to be used on real candidates. However, the HR personnel noticed something strange in the results: the system was consistently preferring male candidates and rejecting female applicants. On deeper inspection, the engineers

realized that the fault was with the data. In large tech companies such as Amazon, only around one-fourth of employees are female. So, when using the CVs of existing employees, engineers inadvertently introduced a bias in the system that discriminated against female candidates. Even though this discrimination was unintentional, using a black box algorithm makes it difficult to uncover such issues until it is too late.

  • Improvements: The world we live in is very dynamic; things are constantly changing and, as such, we have to respond to those changes swiftly. One of the biggest problems with automated systems is that when they work well, people tend to forget about them and only remember that they exist when things go astray. This is precisely what happened in Malta when they installed a speed camera on the sidewalk next to a landscaped area. The camera worked perfectly, fatalities decreased from the stretch of road, and it was returning a healthy income stream. Many years passed, and everyone forgot about it because the objective was met. One day, a government official noticed that one of the trees in the landscaped area had grown so much that it was obfuscating the camera’s view. When they checked, it was obvious the camera was not working, it generated no income, and fatalities increased again. Just because a system is working doesn’t mean that it is working well. As the world changes, improving the system gets even more complex if the internal working of the AI is hidden from the engineers that should be maintaining it. In the case of the speed camera, the maintenance people might have realized something was different but didn’t realize it was due to the tree in front of the camera. With a lack of information, they might have thought that it was due to better driving, less traffic, or a million other possible reasons. Unfortunately, we all know that correlation does not necessarily imply causation. But without all the information, it is difficult to understand what’s happening.

  • Overfitting: Many AI systems obtain impressive results, but some are too good to be true. When training such systems, you have to be extra careful about the possibility that the algorithm learned the training data so well that it can only recognize those examples and nothing else. This is usually called overfitting because the algorithm perfectly memorized the training data. A good indication of overfitting is when the algorithm’s precision hovers around 99%. While this might sound great, in reality, it only means that the system did not manage to reach generalization. Let’s look at a simple example.

If we’re tasked with creating a classifier to identify between images of cats and dogs, and we use four images as test data (two from each category), we are confident that the AI will distinguish between the two categories with 100% accuracy. While such a result might sound fantastic, as soon as we provide it with a fifth image that it has never seen before, the system will fail miserably. This is because the algorithm did not generalize the features of the two categories beyond the test data but only learned to distinguish between those four images. When creating such a system, we will never have the images of all the cats and dogs that exist. Thus, this poses a problem, and because of this, we need algorithms capable of generalizing beyond the test data.

Black box AI does not manage to identify the right relationships, and if we cannot understand which connections were picked, then we cannot find ways of improving the system. We need systems that we can understand so that we can be sure that the AI algorithm is looking at the bigger picture and not at a subset of it, hence why we need XAI!

To better understand the importance of XAI, it is important to contextualize it in several real-world applications. It is crucial to realize that an AI system that does not produce good results is not just a technical issue but can have real consequences on people’s lives. Let’s look at some cases.

A few years back, the University of Washington embarked on a rather challenging classification task, that of identifying between Huskies and wolves. Although it might seem simple initially, on further inspection, the undertaking becomes rather tricky due to the impressive similarities between the two animals.

They obtained several images representing the two animals in different contexts and used those to train a classifier. In line with AI best practices to avoid overfitting, the system was also tested on an independent set of unseen images, which is usually the case. Surprisingly, even though distinguishing between the two animals is very difficult for humans, the AI achieved an astonishing 90% accuracy. Of course, the researchers were very happy with such a result, but they wanted to understand how the AI manages such a feat. It could be that it managed to detect features that humans missed or some attributes that were underestimated. However, when they ran an explainer function to provide the reasons behind the AI’s classification, it was immediately evident that the system based its judgment on the image’s background. On analyzing hundreds of photos, the AI learned that wolf images were taken in the wild and usually had a snowy background.

On the other hand, Huskies, being domesticated animals, were usually portrayed in a more urban setting. Rather than creating a wolves versus Huskies classifier, unwittingly, all they made was a complex snow detector. The lesson from this is that just by looking at the performance of such systems, we would not be able to catch such faults.

When faced with a growing workload, many organizations resort to automation to relieve some of the pressures assaulting their workforce. This is what happened in Pittsburgh around the early 1990s. Since the local hospital was overwhelmed with an increasing number of pneumonia cases, they decided to conduct a study to predict the risks of complications in patients. The idea was to create a system that would categorize patients into two groups, low and high risk. Those in the low-risk category were sent home with a cocktail of antibiotics and ordered to rest. The others were admitted to the hospital immediately. In so doing, they would relieve the stress on the doctors and allow them to focus on The Need for Explainable AI


the most complicated and life-threatening cases. The programmers decided to create an Artificial Neural Network (ANN), which would analyze historic data amounting to around three-quarters of a million medical records obtained from the 78 hospitals participating in the study. The records were very representative of what was happening on the ground, and they even documented an 11% death rate. On training the system using this data, they obtained an 86% precision, which is an acceptable measure for such systems.

However, when the doctors tested the system with actual patients, they noticed a problem. When asthmatic patients with pneumonia were inputted into the system, the AI classified them as low risk. Any medical professional knows that someone with asthma is susceptible to lung infections, so there must be something wrong with the system. Thus, they raised red flags and stopped using the AI until further investigations were conducted by the programming team.

The programmers returned to the drawing board and analyzed every aspect of the system, but they could not find anything suspicious about how it was behaving. They also checked the data that was used for training, but still, everything seemed in line. They did all they could, but they hit a brick wall because they couldn’t look into the inner workings of the AI. The ANN was a black box system, so extracting an explanation from it was somewhat complicated and, in some cases, even impossible. As a workaround for this hurdle, they decided to use a rule-based system, which is not as good as an ANN, but at least they could analyze the internal workings of the system. The new system generated all the rules and finally managed to go through them, but to their horror, the rule-based system also generated a rule that said that if the person is asthmatic and has pneumonia, they should be considered low risk.

This was indeed a mystery worthy of a seasoned investigator. On further investigation, the researchers understood what was happening. In the historic data they were using, they had the original symptoms and the outcomes but were missing the therapy used. Thus, it transpired that asthmatic patients with pneumonia did have a higher rate of recovery than the others (as correctly identified by the algorithm), but this was because they were given better quality care. They were immediately admitted to intensive care, and as a result, they managed to recover. So, even though there was nothing wrong with the algorithms and the data used, the fact that crucial information was missing made all the difference. This goes to show two important things – the first is that correlation does not imply causation, and the second is that human intuition is extremely important. If it weren’t for the doctors, many more patients would have died that year!

We have already seen recruitment fail at Amazon. However, this is not an isolated case. Various companies are going down the same route. While Amazon is well known, so this news might sound sensational, how many more companies exist that are doing the same, if not worse, and we’re not privy to their deeds? Furthermore, let’s not forget that these new algorithms not only analyze the content on the CV of the candidate but they also snoop around on their social media accounts. Since most of our lives are exposed online, how fair is it to prevent potential candidates from getting their dream job or promotion simply because traces of past mistakes still linger online? Worse still, let’s not forget that AI systems are not infallible, and while surfing online, they might quickly gather information about someone with a similar name. Cases of mistaken identities are numerous and constantly increasing. Recruiters have to be extremely cautious because their decisions must be transparent and legally defensible, something that is very difficult to achieve with a black box AI. This issue is further accentuated in regulated industries such as financial services, where they cannot afford any bias in their selection algorithms; otherwise, they will expose themselves to discrimination lawsuits and other legal nightmares.

A juridical conviction can break a person forever, and this is even worse when a miscarriage of justice occurs. This was the case of Robert Williams, a family man who was spending some quality time with his daughters during a cold winter day in Detroit. Suddenly, the neighborhood lit up with the flashing lights of police cars approaching, and the children’s laughter was suffocated by the wailing of their sirens. In a fraction of a second, which was too short to mentally process, Mr. Williams was apprehended and taken away amid the cries of his family. Transparency was thrown out of the window that day; no one bothered to explain what happened, and he was detained for 30 long hours in police custody. Subsequently, he was arraigned for theft and released with a $1,000 bond.

Mr. Williams understood that he was being charged with theft from a local jewelry store. The AI had matched his face with that of one of the robbers, hence why the charges were issued. There was no turning back now; he had to prove his innocence. Luckily for him, at the time of the robbery, he published a post on social media that proved that he was somewhere else. But the story could have taken a very negative twist. The police’s over-reliance on AI led to this false arrest. The facial recognition software identified Mr. Williams from a database of 49 million images. However, the police failed to realize that even the most advanced computer vision algorithms have a 5% error, and Mr. Williams fell into that category.

But not everyone is so lucky. A Wisconsin man was sentenced to 6 years in jail by another system called Compass. The AI analyzed all the variables, and the result was that he was tagged as a threat to his community. The problem with this analysis is that since the algorithm is proprietary to a private organization, they are not bound to disclose how the AI works and why certain decisions were taken. A post-judgment analysis of the system quickly uncovered that statistically, white defendants were more likely to be incorrectly judged with a higher recidivism rate.

In China, they have an even more complex system known as the social score. A network of around 200 million public cameras and an army of sensors is constantly gathering information about the country’s citizens to reward or punish people who don’t exhibit trustworthy behavior. In some districts, they took it further by using advanced predictive analytics to prevent crime before it happens. So, if I’m an individual well known for forced entry into luxury apartments and I happen to pass through a high-end district, the police will monitor my movements and apprehend me if I exhibit any suspicious behavior.

It is clear from these examples that AI is already being used to make profound life-changing decisions. While the intention is probably good, we must remember that no system is infallible and that human intuition should also factor as part of the equation. Because of this, using glass boxes when making decisions that will impact humans’ lives is imperative.

Self-driving vehicles are also not privy to controversies. Even though they might be orders of magnitude safer than human-operated machines, people are still skeptical when trusting their lives to the hand of AI. There is still a trust issue, which will take time until it is surpassed. This is ironic, considering that in modern aviation, almost 90% of the flight is entrusted to AI. Furthermore, recent innovations have also developed systems capable of handling the remaining 10%. But people need the reassurance that even if AI is in control, there’s a person behind it ready to take over when things go wrong.

The challenge with cars is much more significant. In the aviation industry, we have around 25,000 planes worldwide, and they operate in a highly regulated environment with safety features in place. The automobile industry has around 1.4 billion vehicles worldwide operating in diverse environments with less stringent regulations and safety features. Because of this, self-driving cars must be able to reassure their users.

We’ve already experienced various accidents by high-profile companies whereby the autonomous vehicle bashed into a stationary obstacle, killing some of the passengers. Once again, there was no visibility on the cause of the accident, and these accidents were concealed. Of course, this does not help increase the trust users have in the system. Furthermore, there have been various studies that were rather worrying.

A recent study by researchers at the Georgia Institute of Technology found that some of the widely used computer vision algorithms (typically found in self-driving cars) find it difficult to detect people with darker skin tones, thus placing them at a higher risk of collision. Once again, the problem boils down to bias inside the AI. This was also confirmed by another study conducted by Google researchers, whereby their AI system completely missed people with a dark skin color.

In another instance, Tencent’s Keen Security Lab shows how they can trick a self-driving car by placing three small stickers on the road. Even though they’re tiny, the sophisticated sensors installed on the self-driving cars manage to detect them, and the AI interprets them as signifying a left veering lane, thus steering the car into a wall.

Of course, these failures are somewhat normal when testing new technologies. Hence, it is crucial to conduct them in a controlled environment to ensure that no one gets hurt. However, we also need to understand how AI algorithms make their decisions because if we don’t, these hacks will keep disrupting the mass deployment of autonomous vehicles.

It is no surprise that various countries are conducting active research on using AI for military purposes. In recent wars, we’ve seen various use cases where AI has been extensively used, such as the following:

  • The identification of victims using biometrics
  • The location of persons of interest via satellite tracking
  • The snooping of enemy communication channels using natural language processing technologies
  • The deployment of drone surveillance in sensitive areas
  • The use of autonomous weapons capable of detecting and destroying enemy targets
  • The development of humanoid robots aimed at replacing foot soldiers on the battlefield one day

Billions of dollars are being pumped yearly to create more sophisticated AI military applications. However, even though novel technologies are being developed at a quick pace, the US Department of Defense flagged explainability as a significant stumbling block, so much so that the Defense Advanced Research Projects Agency (DARPA) launched an XAI program to overcome these hurdles. Through this program, analysts are using AI to identify patterns in surveillance data and come up with human-understandable explanations. This is important for a variety of reasons. First, all decisions taken on the battlefield need to be transparent and accountable. Any “justified” harm to human life during a war cannot be left to the discretion of the few but must withstand scrutiny by the higher powers in office. Second, if autonomous vehicles keep increasing, it is only fair that they are tried and tested well before any military personnel can entrust their life. Thus, to safeguard the lives of their soldiers, analysts are reluctant to act on information without a clear explanation.

After seeing these case studies, it is evident that we need to move toward XAI. We cannot rely only on the correctness of current AI models since they are opaque, non-intuitive, and complex for people to understand. If we want people to trust autonomous decisions taken by these systems, users must understand how to manage the AI effectively. Let’s not forget that algorithms and automation are becoming more pervasive. It permeates every aspect of our life. Businesses are heavily relying on AI-driven analytics, and we’ve started to see inroads in domains where the human expert was traditionally uncontested (for example, the judiciary, medical diagnostics, and so on). AI has several benefits over its human counterparts since it’s precise, faster, doesn’t get tired or sick, and will not go on holiday. However, as we’ve seen in the previous examples, biases and erroneous decisions can spread quickly.

Today, we are facing a situation where AI models are becoming more significant with millions of parameters, thus making them impossible to understand by humans. Some of these models offer little control over the underlying logic, and there are no simple means of correcting any errors that might arise.

With the introduction of the European GDPR, black box approaches have become much more challenging to use in business since they cannot explain their internal workings. Two fundamental rights enshrined in the law are the right to erasure and the right to be forgotten. This means that technically, anyone can make a request to any institution and demand the erasure of their private data. However, when the data is stored within an AI model, the situation becomes much more complex than it sounds because it is not just a matter of removing someone’s data from a file. It has to be deleted from the database storing that data, from crash recovery backups, from data mirrored in data centers, and physically deleted from the hard disk (rather than just removing the link). This makes the erasure task extremely complex.

Given all these challenges, we need to find ways of making AI models explainable, and in the following section, we will look at some of the most prominent techniques currently in use.

XAI is a research area that has been gaining popularity in the past few years. In this section, we will look at a synthesis of the most critical XAI models in use today.

The Accumulated Local Effects (ALE) method computes the effects of features globally. It is mainly used with tabular data, where different variables can be compared. The idea behind ALE is that if we have a small enough window, we can create an accurate estimate of the changes within a specific period. So, if we have a variable and we can sample its values across different periods, we can create an accurate estimate of how that variable is changing over time. The process is then repeated across all the accumulated data and is used to augment the global prediction. The algorithm focuses on the changes between one sampling point and the other, thus making the data relatively easy to interpret for any analyst.

Anchors try to explain the behavior of complex models using high-precision rules. These rules define the local conditions using if-then statements, which ensure a prediction with high confidence. The focus is shifted to the input, which is essential for the classifier to make its predictions. Because of this, anchors are relatively easy to understand and apply to any data, thus making them model-agnostic. The assumption anchors use is that even though the model might be too complex globally, it can be explained by zooming into individual predictions. As can be seen in Figure 4.3, the anchor of the image identifies the dog. Thus, we can be sure that the AI is working correctly since no additional anchors are referenced by the AI. This contrasts significantly with the wolf versus Huskies case study we discussed earlier since, in that case, the anchor was referencing the snow and not the animal.

Figure 4.3: Photo of a dog on the left and its anchor on the right

The Contrastive Explanation Method (CEM) creates local explanations based upon particular instances. It defines Pertinent Positives (PPs) and Pertinent Negatives (PNs). Essentially, the PP finds the essential features of a data item to categorize that element as part of the positive examples. PN is the opposite and identifies the components without which the classification should maintain the same output. So, if we want to recognize the number 1, we can quickly identify the PP and PN:

1 1 1 1 1 1 1 1 1 1

Figure 4.4: Varied designs for the number 1

As we can see from these 10 examples of the various designs for the number 1, the long line that makes the number from top to bottom will be considered a PP since it is an essential element of all the different variants of the written number 1. However, any other additional horizontal or diagonal line used in the different styles is superfluous and would be considered a PN. Because of this, CEM is designed to be applied locally.

Counterfactual explanations is a model-agnostic XAI technique that checks the AI model using explanations that describe the slightest change in a feature that would eventually change the prediction. These rules take the form of, “If X had not occurred, Y would not have occurred.” [figure outside: Figure 4.3] [figure outside: Figure 4.4] The first part of the statement defines the event, while the second part is the causation. The model looks at the edge examples and notes what would happen. So, if we consider the example of taking a bank loan, a change in salary is an event that would allow the person to take a higher loan. Of course, not all the counterfactual instances are doable. While a change in salary might be possible (due to a pay rise, promotion, extra jobs, and so on), if we consider the motive behind rental property prices, the location is a significant factor but not something we can change. Since counterfactual instances deal with granular data, they are applied locally.

An Explainable Boosting Machine (EBM) is an interpretable model that uses machine learning techniques such as bagging and gradient boosting over traditional Generalized Additive Models (GAMs). A GAM is a linear model that also allows complex non-linear features. EBM works by building trees and performing a cyclic gradient-boosting GAM with interaction detection. This results in models that are typically highly accurate and comparable to state-of-the-art black boxes but with the benefit of also being completely interpretable. They are also very compact and fast. The downside is that EBMs usually take longer to train than other comparing algorithms. Due to their nature, they can be used for both local and global predictions.

Global Interpretation via Recursive Partitioning

Section titled “Global Interpretation via Recursive Partitioning”

Global Interpretation via Recursive Partitioning (GIRP) creates a binary tree representing a global machine learning model. The most vital rules, which are selected using a contribution matrix (obtained from the input variables), are represented as branches in the binary tree. To generate such a tree, a recursive process is launched, which partitions the input variables based on their contribution to the search space. Since it is applied to the global model, it cannot give local explanations like the other models.

Integrated gradients also work with input features of an AI model and assign them different importance levels based on the change in gradient. The gradient is gradually changed, and at every iteration, the effect of the different input features is noted. In doing so, we can identify which are essential and which aren’t, thus allowing us to zoom in and focus on the most promising features. Such a technique is model-agnostic and can be used to explain any kind of data. This technique is rather popular and has been used not only to understand feature importance but also to identify skewed data and debug AI performance. Integrated gradients are typically applied locally.

The state-of-the-art models in XAI


Local interpretable model-agnostic explanations

Section titled “Local interpretable model-agnostic explanations”

As the name implies, local interpretable model-agnostic explanations (LIME) is both model-agnostic and focuses on local interpretations. When presented with a model and a test sample, LIME uses the data found in the test samples to create new synthetic data that follows a normal distribution. This new data is then fed to the existing model and used to generate new predictions. Each feature set is then weighted by checking the quality of the results vis-à-vis the original data points.

In so doing, the most critical features are selected. The most remarkable mechanism of the model is that it creates a sort of glass box surrounding the black box algorithm. As can be seen in Figure 4.5, in the case of the wolves versus Huskies case study, the background of the image was more important for the classification of the animal than the actual features of the wolves:

Figure 4.5: Image with recognized features marked using a red tint (adapted from source: Madeleine Lewander from Pixabay)

Morris Sensitivity Analysis (MSA) implements a one-step-at-a-time (OAT) approach that analyzes the sensitivity of the global model. At any point, only one input has its level adjusted during every run. Such an approach is usually much faster than similar models. However, it might risk missing non-linearities. Such a model is usually used to determine which input is more critical for additional analysis, and it can only be applied globally. The Need for Explainable AI


A partial dependence plot (PDP) shows the effect of various features on the predicted outcome. It can provide insight into the relationships between a feature and a target. These can form a linear, monotonic, or complex relationship. In a linear relationship, variables change similarly and at the same rate. A monotonic relationship is similar because variables change similarly but at a different rate. Even though PDP can be relatively quick at providing explanations, it assumes feature independence. However, we all know this condition is not always true and can be misleading if not met. Such a model typically works on the global model.

Permutation importance measures the input feature’s significance based on the increase in the model’s error. The underlying assumption is that the model’s error should also change if we shuffle the values of the pattern. Suppose the change in values does not affect the global error level. In that case, it simply means that the feature is probably unimportant since, irrespective of its value, it has almost no effect on the final output. On the other hand, if a change in the permutations drastically affects the output error, then there is a strong link, and the feature cannot be ignored when devising an explanation for that model. To identify these features, one of them is removed from the dataset, the estimator is re-trained, and the score is checked. Since we’re working on the whole model, permutation importance only works at a global level.

Protodash presents a novel approach based on the premise that a few representative prototypes can represent the most critical data points. This concept is interesting because, in the past few years, we’ve seen a surge in the creation of enormous language models such as Kimi-k2.63, BERT, and many others. However, many people question whether the models’ size can be reduced and still obtain comparative results. Varying research seems to suggest that this is possible since a big chunk of what’s in the model appears redundant in most cases. Protodash does just that by weighing each prototype to evaluate its representation level of data.

The system requires three essential inputs: the dataset that needs explaining, the collection from where to extract the prototypes, and the number of prototypes to choose from. Protodash will identify different prototypes, thus seeking a more comprehensive representation of the underlying data. When a prototype is found, the next prototype that’s sought will also model the underlying data but will have new characteristics different from the other prototype. By using this approach, the system guarantees a broader representation. The prototype search continues until the number of prototypes (defined a priori) is reached. Since the system finds targeted prototypes, it provides local results.

In this chapter, we looked at XAI to understand what it is and why it is so important, especially within the context of black-box AI models. We also saw how, due to the increasing complexity of these models, XAI is somewhat inevitable. Following that, we also looked at various case studies, some of which were rather eye-opening, especially when considering that AI is being augmented in every aspect of our lives. Finally, we presented a non-exhaustive list of XAI methodologies. The models shown were the most popular and representative of various novel approaches in the field of XAI.

In the next chapter, we will look at a new breed of powerful AI models that are also inherently explainable. Because of this, we will look at neuro-symbolic AI and how it promises to address the issues mentioned so far.