Introduction To Prescriptive AI: A Primer For Decision Intelligence Solutioning With Python
Introduction To Prescriptive AI: A Primer For Decision Intelligence Solutioning With Python
Introduction To Prescriptive AI: A Primer For Decision Intelligence Solutioning With Python
Prescriptive AI
A Primer for Decision Intelligence
Solutioning with Python
—
Akshay Kulkarni
Adarsha Shivananda
Avinash Manure
Introduction to
Prescriptive AI
A Primer for Decision
Intelligence Solutioning
with Python
Akshay Kulkarni
Adarsha Shivananda
Avinash Manure
Introduction to Prescriptive AI: A Primer for Decision Intelligence
Solutioning with Python
Akshay Kulkarni Adarsha Shivananda
Bangalore, Karnataka, India Hosanagara, Karnataka, India
Avinash Manure
Bangalore, Karnataka, India
Acknowledgments�����������������������������������������������������������������������������xiii
Introduction����������������������������������������������������������������������������������������xv
v
Table of Contents
vi
Table of Contents
vii
Table of Contents
Index�������������������������������������������������������������������������������������������������189
viii
About the Authors
Akshay Kulkarni is an artificial intelligence
(AI) and machine learning (ML) evangelist
and a thought leader. As a consultant, he has
worked with several Fortune 500 and global
enterprises to drive AI and data science–led
strategic transformations. He is a Google
developer, an author, and a regular speaker
at major AI and data science conferences
(including the O’Reilly Strata Data & AI
Conference and Great International Developer
Summit [GIDS]). He is a visiting faculty member at some of the top
graduate institutes in India. In 2019, he was featured as one of India’s “top
40 under 40” data scientists. In his spare time, Akshay enjoys reading,
writing, coding, and helping aspiring data scientists.
ix
About the Authors
x
About the Technical Reviewer
Nitin Ranjan Sharma is a manager at Novartis.
He leads a team that develops products using
multimodal techniques. As a consultant,
he has developed solutions for Fortune 500
companies and has been involved in solving
complex business problems using machine
learning and deep learning frameworks.
His major focus area and core expertise is
computer vision, including solving challenging
business problems dealing with images and
video data. Before Novartis, he was part of the data science team at Publicis
Sapient, EY, and TekSystems Global Services. He is a regular speaker at
data science community meetups and an open-source contributor. He also
enjoys training and mentoring data science enthusiasts.
xi
Acknowledgments
We would like to thank our families who have always made sure we had
the right environment at home to concentrate on this book and complete
it on time. We would also like to thank the publishing team—Mark Powers
and Celestin Suresh John, and our technical reviewer, Nitin Sharma—who
helped us make sure this book was the best it could be. We would also
like to thank our mentors who made sure we grew professionally and
personally by always supporting us in our dreams and guiding us toward
achieving our goals. Last but not least, we thank our parents, our friends,
and our colleagues who were always there in tough times and motivated us
to chase our dreams.
xiii
Introduction
This book will introduce you to the concept of decision intelligence,
including its history and current and future trends. It will help you
evaluate different decision intelligence techniques and guide you on
how to them through different prescriptive AI methods and incorporate
them into business workflows through different domain-specific use case
implementations.
This book is for data scientists, AI/machine learning engineers, and
deep learning professionals who are working toward building advanced
intelligent AI/ML applications. This book is also for business professionals
and nontechnical stakeholders who want to understand how decision
intelligence can help a business grow.
This book will take you through the journey of decision-making
in companies with key milestones, key statistics, and benefits. It will
provide insights on where decision intelligence fits within the AI life
cycle. This book will provide insights on how to prepare for prescriptive
AI (a key requirement to decision intelligence) with the help of a business
requirement document. It will then deep dive into different decision
intelligence methodologies, their advantages, and their limitations. Next,
you will learn how to perform different simulations and interpret the
results from them. Then you will be guided on how to enable and embed
the decision intelligence process into the business workflow through
prescriptive AI. You will learn about different cognitive biases that humans
make and how that can be lowered/eliminated through the combination
of machine and human intelligence. Finally, you will find different cases
studies by domain through tailored use cases.
xv
Introduction
xvi
CHAPTER 1
Decision Intelligence
Overview
Prescriptive AI is a type of artificial intelligence that is designed to provide
recommendations, solutions, or actions to optimize or improve a specific
process or outcome. It is unlike descriptive AI, which describes “what”
has happened in the past/present; inferential/diagnostic AI, which
helps us understand “why” something has happened; and predictive AI,
which helps predict what might happen in the future. Once we have the
predictions, prescriptive AI focuses on what actions should be taken to
achieve a particular goal or outcome.
Prescriptive AI can be used in a variety of applications, such as in
healthcare to help doctors diagnose diseases and prescribe treatments, in
finance to make investment decisions, and in manufacturing to optimize
production processes. It typically uses machine learning algorithms
and other advanced technologies to analyze large datasets and generate
recommendations based on the data.
Overall, the goal of prescriptive AI is to help humans make better
decisions by providing them with accurate and actionable insights based
on data-driven analysis.
Types of AI
Descriptive, diagnostic, predictive, and prescriptive AI are four different
types of artificial intelligence that are used in various applications. Here’s
an overview of each:
• Descriptive AI: Descriptive AI, also known as
descriptive analytics, is used to describe what has
happened in the past or is currently happening. It
involves analyzing historical data to identify patterns,
trends, and insights. Descriptive AI is often used for
reporting and business intelligence applications,
such as dashboards and scorecards that summarize
key performance metrics. It can also be used for
exploratory data analysis to uncover hidden insights
and correlations.
For example, a retail company may use descriptive
AI to analyze its sales data and identify which
products are selling the most, which stores are
performing the best, and which customers are
buying the most. This information can then be
used to make data-driven decisions on inventory
management, pricing strategies, and marketing
campaigns.
2
Chapter 1 Decision Intelligence Overview
3
Chapter 1 Decision Intelligence Overview
4
Chapter 1 Decision Intelligence Overview
Decision Intelligence
Decision intelligence (DI) is a discipline that combines techniques from
artificial intelligence, decision theory, and behavioral science to support
and improve human decision-making. It aims to provide a more structured
and rigorous approach to decision-making by using data and analytics
to help people make better decisions. It involves using a combination of
human expertise and machine intelligence to make better decisions in
complex and uncertain situations.
DI involves a variety of techniques, including machine learning,
optimization, simulation, and behavioral science, to provide decision-
makers with insights and recommendations. It typically involves collecting
and analyzing data from various sources, identifying decision criteria, and
generating possible alternatives based on various constraints and objectives.
The ultimate goal of DI is to enable organizations and individuals
to make better decisions that are more aligned with their goals, values,
and preferences. This can lead to improved efficiency, effectiveness,
and competitiveness in a wide range of domains, including business,
healthcare, government, and education.
5
Chapter 1 Decision Intelligence Overview
6
Chapter 1 Decision Intelligence Overview
Challenges in AI Adoption
There are several challenges that businesses face when adopting AI
technology. These are some of the key challenges:
8
Chapter 1 Decision Intelligence Overview
9
Chapter 1 Decision Intelligence Overview
10
Chapter 1 Decision Intelligence Overview
11
Chapter 1 Decision Intelligence Overview
12
Chapter 1 Decision Intelligence Overview
Challenges
Decision intelligence can be challenging to implement because it involves
several complex and interconnected processes. Here are a few reasons why
DI is hard:
13
Chapter 1 Decision Intelligence Overview
Applications
There are numerous applications of DI across different domains. Here are
some examples:
14
Chapter 1 Decision Intelligence Overview
15
Chapter 1 Decision Intelligence Overview
16
Chapter 1 Decision Intelligence Overview
17
Chapter 1 Decision Intelligence Overview
18
Chapter 1 Decision Intelligence Overview
20
Chapter 1 Decision Intelligence Overview
21
Chapter 1 Decision Intelligence Overview
22
Chapter 1 Decision Intelligence Overview
23
Chapter 1 Decision Intelligence Overview
24
Chapter 1 Decision Intelligence Overview
While these are just a few examples, they demonstrate the potential
of DI to improve decision-making and drive business value. As the
adoption of DI continues to grow, we can expect to see more companies
implementing DI and realizing its benefits.
Conclusion
You now understand what prescriptive AI is, its history, how it works,
its methodologies, its applications, and its pros and cons. In the coming
chapter, we will dig deeper into each of these aspects along with building
an end-to-end DI solution.
25
CHAPTER 2
Decision Intelligence
Requirements
Lots of AI projects will fail across industries because AI projects can be
complex and challenging, and many potential factors can contribute
to their failure. Some of the reasons for failure are lack of clear goals,
data quality issues, and difficulty integrating the AI system into existing
processes. Additionally, there can be organizational challenges such as a
lack of support or buy-in from stakeholders, unrealistic expectations, and a
lack of understanding of the capabilities and limitations of AI.
In this chapter, we are going to discuss how we might reduce the
failures by planning, having clear requirements, and understanding the DI
requirements framework.
28
Chapter 2 Decision Intelligence Requirements
29
Chapter 2 Decision Intelligence Requirements
30
Chapter 2 Decision Intelligence Requirements
So, let’s discuss a framework in detail. The first step is proper planning.
Planning
Planning is a crucial aspect of any AI project, as it helps to ensure that the
project is well-defined, is well-organized, and has a clear path to success.
These are some of the specific reasons why planning is important for AI
projects:
31
Chapter 2 Decision Intelligence Requirements
32
Chapter 2 Decision Intelligence Requirements
Approach
Approaching an AI project requires careful consideration of several key
factors including the type of problem being addressed, the available data,
the computing resources available, and the deployment requirements.
Here are some general guidelines for approaching an AI project:
33
Chapter 2 Decision Intelligence Requirements
34
Chapter 2 Decision Intelligence Requirements
35
Chapter 2 Decision Intelligence Requirements
Approval Mechanism/
Organization Alignment
Establishing an approval mechanism for AI projects is an important step to
ensure that the projects are aligned with organizational goals and values.
Here are some steps to follow to establish an approval mechanism for AI
projects:
1. Identify stakeholders: Start by identifying the
stakeholders who should be involved in the
approval process. This may include executive
leadership, legal counsel, data privacy and
security experts, and representatives from affected
business units.
36
Chapter 2 Decision Intelligence Requirements
37
Chapter 2 Decision Intelligence Requirements
38
Chapter 2 Decision Intelligence Requirements
39
Chapter 2 Decision Intelligence Requirements
Value
One of the biggest challenges that organizations face is to quantify the
benefits of their AI initiatives. Value realization involves effort, and until
one knows what benefits they are getting through their AI initiatives, they
cannot improve them. No wonder most of the AI use cases fail to get any
adoption at all due to the complexities in realizing the business value of
the use cases.
As shown in Figure 2-2, processing data, building models with good
accuracy, and deploying the models seems easier than tracking and
realizing the value of AI. It seems difficult because we have come from a
value standpoint when building AI projects and have never tracked the
KPIs and return on investment.
40
Chapter 2 Decision Intelligence Requirements
Return on Investment
The return on investment (ROI) of the project should consider the costs
of implementing the project and the potential value it will bring to the
business.
The ROI for an AI project refers to the expected or realized financial
return on investment for implementing an AI solution or initiative. It is
determined by comparing the cost of implementing the project, including
the cost of data acquisition, hardware and software, and personnel, to the
expected or realized benefits.
The benefits of an AI project can be difficult to quantify but may
include increased efficiency, improved accuracy, better decision-making,
and reduced labor costs. The ROI for an AI project can be calculated by
41
Chapter 2 Decision Intelligence Requirements
42
Chapter 2 Decision Intelligence Requirements
43
Chapter 2 Decision Intelligence Requirements
44
Chapter 2 Decision Intelligence Requirements
45
Chapter 2 Decision Intelligence Requirements
By following these steps, you can identify users for AI predictions and
ensure that they are provided with the information and resources they
need to effectively use the predictions to support decision-making and
improve outcomes.
Conclusion
In this chapter, we discussed the potential reasons for AI project failure,
the importance of decision intelligence in making better decisions using
AI, and the guidelines for the successful implementation of AI solutions.
It highlighted the need to ask critical questions before starting any AI
projects and debunked some of the myths surrounding AI. We also
introduced a DI requirements framework that covers planning, approach,
approval mechanism, KPIs, potential value, and consumption of AI
predictions, which are fundamental to AI projects.
46
CHAPTER 3
Decision Intelligence
Methodologies
The idea of decision-making is the main topic of this chapter, along
with its types. We will begin with the definition of decision-making and
examine its various forms. Then, we will understand the decision-making
process through an example. We will next go into greater detail about
the development of decision-making, also known as decision intelligence
methodologies, employed by humans over time, as well as their benefits
and drawbacks. Our discussion will end with suggestions for decision
intelligence approaches for various scenarios.
Decision-Making
To get to know the different decision intelligence methodologies, you have
to understand what decision-making is.
Decision-making can be defined as the mental process of choosing
among different options, culminating in the selection of a belief or action.
Thus, decision-making consists of two major components.
• An objective function
Types of Decision-Making
There are basically three types of decision-making. Let’s examine each
in detail.
48
Chapter 3 Decision Intelligence Methodologies
49
Chapter 3 Decision Intelligence Methodologies
50
Chapter 3 Decision Intelligence Methodologies
Decision-Making Process
As per the research by Baker et al. (2001), before making a decision, it
is important to identify the individuals or groups that are responsible
for making the decision and those who will be affected by it. This
helps to reduce any possible disagreement about problem definition,
51
Chapter 3 Decision Intelligence Methodologies
52
Chapter 3 Decision Intelligence Methodologies
53
Chapter 3 Decision Intelligence Methodologies
54
Chapter 3 Decision Intelligence Methodologies
• Premium interiors
• Wireless charger
• Touchscreen display
• Alloy wheels
55
Chapter 3 Decision Intelligence Methodologies
56
Chapter 3 Decision Intelligence Methodologies
Decision-Making Methodologies
Humans have evolved over the years, and along with them, the way they
make the decisions has also seen lots of changes. From making decisions
as an individual randomly to group decision-makers who are rational
to combining random and process-oriented and individual and group
decision-makers, the decision-making process has been constantly
increasing in its complexity.
The decision-making methodologies can be broadly divided into three
major categories, human-only, human-machine, and machine-only, as
shown in Figure 3-4.
57
Chapter 3 Decision Intelligence Methodologies
Human-Only Decision-Making
Human-only decision-making refers to the process of making choices
or decisions solely on the judgment of human beings, without the
involvement of artificial intelligence, machine learning, or any automated
decision-making systems.
Before the advent of machines (from the abacus to computers and AI
robots), humans have been making decisions either individually or in a
group for personal, social, or organizational needs. The type of decisions
that humans make vary depending upon the situation at hand, criticality of
58
Chapter 3 Decision Intelligence Methodologies
the decision, mental state of the people making the decision etc., ranging
from totally random to outcome based to a more systematic complex
decision-making.
The history of human decision-making can be traced back to the earliest
civilizations, where decisions were made by leaders, elders, or individuals
in positions of authority. Over time, the development of democratic
institutions, laws, and norms has led to an increased emphasis on individual
autonomy and the ability of individuals to make decisions for themselves.
Let’s further evaluate the different types of human-only decision-
making techniques.
Random Decisions
Random decision-making refers to the process of selecting an option or
making a choice randomly, rather than relying on reasoning, intuition,
or personal preference. This type of decision-making technique comes
naturally to us and has been used in situations where the stakes are not
high, there is an urgency to decide, there is no historical data to support
the decision-making process, or all or any combination of these situations.
Examples of random decision-making are flipping a coin or rolling a die.
Here are the advantages of random decisions:
• Removes confirmation bias: By relying on chance
instead of personal preference, random decision-
making can help to remove personal bias and increase
objectivity.
Morality/Ethics Based
Ethics-based or moral-based decision-making refers to the process of
making choices and taking actions that align with a set of moral or ethical
principles and values. The outcomes of these type of decisions may or may
not be favorable to the decision-maker; however, they are of the highest
ethics. The opposite of this is unethical decision-making. The decision-
maker deliberately makes a decision that is not ethical and is most of the
time favorable to them. There are several types of ethics-based decision-
making, including the following:
60
Chapter 3 Decision Intelligence Methodologies
61
Chapter 3 Decision Intelligence Methodologies
Experience Based
Experience-based decision-making refers to the process of making choices
and making actions based on past experiences, knowledge, and expertise.
There are several types of experience-based decision-making, including
the following:
62
Chapter 3 Decision Intelligence Methodologies
Authority Based
Authority-based decision-making, aka “just follow orders” decision-
making, is a process in which decisions are made by individuals in
positions of authority, and subordinates are expected to carry out those
decisions without question. This approach values obedience and hierarchy
and is often used in situations where time is limited or immediate action
is required. In such scenarios, the responsibility for decision-making is
centralized, and individuals lower in the hierarchy are expected to carry
out the decisions of their superiors. This approach can lead to efficient
implementation of decisions, but it can also discourage initiative,
creativity, and critical thinking and can create a lack of accountability
for the outcomes of decisions. There are several types of authority-based
decision-making, including the following:
63
Chapter 3 Decision Intelligence Methodologies
64
Chapter 3 Decision Intelligence Methodologies
Consensus Based
Consensus-based decision-making is a group decision-making process
in which all members of a group participate in reaching a decision
that everyone can support. This approach values collaboration,
communication, and agreement, rather than relying on a single person or
a majority vote. Participants work together to identify and explore options
and seek to find a solution that is satisfactory to all. The goal of consensus
decision-making is to find a solution that addresses the concerns and
needs of all parties involved, leading to more committed and effective
implementation of the decision. There are several types of consensus-
based decision-making, including the following:
65
Chapter 3 Decision Intelligence Methodologies
Voting Based
Voting-based decision-making is a process in which a group of people
cast ballots to determine a course of action. The decision is based on a
tally of the votes, with a majority or supermajority needed to determine
the outcome. This method is often used when time is limited or when
a consensus cannot be reached. Voting can take various forms, such as
a simple majority, a two-thirds majority, or a weighted vote based on
individual member’s stake or influence.
This approach values efficiency and fairness and ensures that the
decision reflects the will of the group. However, it can also lead to minority
views being ignored or overlooked. There are several types of voting-based
decision-making, including the following:
66
Chapter 3 Decision Intelligence Methodologies
67
Chapter 3 Decision Intelligence Methodologies
Threshold Based
This type of decision-making takes certain thresholds into consideration
for given activities to perform an action. This happens when the outcome
sample space is very limited and there is a lot of historical information
on the decisions taken based on the outcome. There are several types of
threshold-based decision-making, including the following:
68
Chapter 3 Decision Intelligence Methodologies
69
Chapter 3 Decision Intelligence Methodologies
failure to fully explore all available options and to consider the long-term
consequences of decisions. There are several types of satisficing-based
decision-making, including the following:
70
Chapter 3 Decision Intelligence Methodologies
Optimization/Maximization Based
Optimizing or maximizing decision-making is a process in which
individuals strive to make the best possible decision based on all
available information and constraints. This approach values finding the
best solution and is often used when the consequences of a decision
are significant or long-lasting. In an optimizing approach, individuals
consider all available options, weigh the pros and cons, and choose the
option that provides the greatest benefits or the least drawbacks. This
method can lead to the best possible outcome, but it can also be time-
consuming and resource-intensive, as it requires a thorough analysis of all
options. Maximizing decision-making can also result in decision paralysis
if individuals become overwhelmed by the available information and
are unable to make a decision. There are several types of optimization/
maximization-based decision-making, including these:
• Efficiency: Optimization/maximization-based
decision-making can be an efficient way to make
decisions, as it involves evaluating all options and
choosing the best one.
• Complexity: Optimization/maximization-based
decision-making can be complex, as it involves
evaluating all options and considering multiple factors.
• Resource-intensive: Optimization/maximization-
based decision-making can be resource-intensive,
requiring significant time, information, and
computational resources to find the best possible
solution.
72
Chapter 3 Decision Intelligence Methodologies
Human-Machine Decision-Making
As humans evolved, their decision-making techniques evolved too. Just
like we invented tools/techniques to help ease our day-to-day life (e.g.,
wheels for traveling, tools for farming, etc.), we also started to create tools
and techniques to aid our decision-making process. This led to human-
machine interactions that helped us make decisions quickly and with
more accuracy and to some extent mitigate the cognitive bias effects. Let’s
evaluate the different types of human-machine decision-making, aka
machine assisted decision-making.
73
Chapter 3 Decision Intelligence Methodologies
Instruction/Rule-Based Systems
In this technique, there is a computerized system that uses a set of
explicitly stated rules to support decision-making activities. These rules
are derived from domain expertise, regulations, or best practices, and
they are encoded in the system to assist with decision-making processes.
The system operates by matching the facts of a particular case against
the rules and suggesting the course of action that best fits the rules. Rule-
based human-machine decision-making is useful in situations where the
decision-making process is well defined and the rules are well understood,
as it provides a consistent and repeatable approach to decision-making.
However, it may not be well suited to situations where the rules are
complex or subject to change, as this requires manual updates to the
system’s rule base. Before the advent of computer systems, there were
other tools used for decision-making. For example, the abacus was used
for calculating finances. There are several types of instruction/rule-based
decision systems, including the following:
74
Chapter 3 Decision Intelligence Methodologies
Mathematical Models
In this technique, there is a computer-based system that uses
mathematical and statistical techniques to support decision-making. It
integrates mathematical models, data, and algorithms to analyze complex
problems and provide recommendations or solutions. The models used in
a mathematical decision system can be linear or nonlinear programming,
dynamic programming, or any other mathematical method suitable for
a particular problem. The system can also include data visualization
75
Chapter 3 Decision Intelligence Methodologies
tools to help users understand the results of the analysis. The goal of a
mathematical model is to provide objective and quantifiable insights
into decision problems and to help users make more informed decisions.
Mathematical modeling is commonly used in fields such as finance,
engineering, and healthcare to support complex decision-making
processes. There are several types of mathematical model-based decision
systems, including the following:
76
Chapter 3 Decision Intelligence Methodologies
Probabilistic Models
In this technique, there is a computerized system that uses probability
theory to support decision-making. It is based on the idea that many
real-world problems involve uncertainty and that a probabilistic approach
is more appropriate than a deterministic one in such cases. The system
uses probabilistic models, such as Bayesian networks or Markov decision
processes, to represent the relationships between variables and the
uncertainty associated with them. The models are used to calculate the
probability of different outcomes given certain inputs and to support
decision-making by providing recommendations or suggesting actions
with the highest expected value. Probabilistic decision-making is
commonly used in fields such as finance, insurance, and healthcare, where
decisions must be made in the face of uncertainty. By explicitly modeling
and quantifying uncertainty, a probabilistic model can provide more
robust and flexible support for decision-making. There are several types of
probability-based decision systems, including the following:
77
Chapter 3 Decision Intelligence Methodologies
78
Chapter 3 Decision Intelligence Methodologies
AI-Based Models
In this technique, there is a computer system that uses artificial
intelligence and machine learning algorithms to support decision-making.
It analyzes data, predicts outcomes, and makes recommendations to
help decision-makers make informed choices. It can be used in various
applications such as assessing risk, optimizing business processes, and
predicting future trends. The goal is to provide accurate and relevant
information to decision-makers in real time, enhancing the speed and
quality of decision-making. There are several types of AI or machine
learning–based decision systems, including the following:
79
Chapter 3 Decision Intelligence Methodologies
80
Chapter 3 Decision Intelligence Methodologies
Machine-Only Decision-Making
The human-machine decision-making, over the years, led to humans
realizing that some of the decision-making can be fully automated through
machines, with little to almost no oversight needed. This led to a new,
more advanced type of decision-making known as machine-only decision-
making, and the machines that make those type of decisions are called
autonomous systems. Let’s go through a few examples of machine-only
decision-making.
Autonomous Systems
Autonomous systems can make decisions and take actions without human
intervention. They use artificial intelligence, machine learning, and
other advanced technologies to analyze data, identify patterns, and make
predictions. Autonomous systems are designed to operate independently
and make decisions based on their understanding of the data and the
situation. These systems can be used in various applications, such as
robotics, unmanned aerial vehicles (UAVs), autonomous vehicles, and
smart homes. The goal of autonomous systems is to provide real-time,
accurate, and relevant information to support decision-making, while
reducing the need for human intervention and increasing efficiency and
speed. There are several types of fully autonomous decision systems,
including the following:
81
Chapter 3 Decision Intelligence Methodologies
82
Chapter 3 Decision Intelligence Methodologies
Conclusion
As we have seen, the decision-making process and its different
methodologies are complex. The structure of human society, comprising
individuals, groups, organizations, governments, etc., add to the
complexity. Hence, there usually is no single way of making decisions.
It can involve a combination of different types of decision-making
techniques with different methodologies. For example, a person planning
to purchase an apartment can do so just by doing the following:
83
CHAPTER 4
Interpreting Results
from Different
Methodologies
In the previous chapter, we saw different decision intelligence
methodologies, with their advantages and limitations. In this chapter, we will
implement various human-machine decision-making methodologies using
the Python programming language. Because covering all the methodologies
is not possible in a single chapter, or even book, we will focus on the most
commonly used ones: the mathematical, probabilistic, and AI-based
techniques. Also, we will look at how to interpret the results generated from
those methodologies and how to use them to make decisions.
is less uncertainty involved. Hence, we can find a lot of use cases in the
physics and engineering domains for mathematical models. Let’s look at
some examples of the linear and nonlinear mathematical models.
Linear Models
Linear models, as the name implies, are mathematical equations that
describe a linear relationship between two or more variables. They are
represented by the following equation:
where:
86
Chapter 4 Interpreting Results from Different Methodologies
• The profit per unit of product is $10, $11, $8, and $12.5
for diapers, sanitary pads, facial tissue, and toilet paper,
respectively.
Solution:
As the problem is related to production optimization, the environment
can be safely assumed to be a controlled one with little to no uncertainty.
Hence, we can use a mathematical model as a solution.
Based on the given problem statement and associated conditions, the
mathematical model can be defined like this:
Maximize: 10x1 + 11x2 + 8x3 + 12.5x4 (Profit)
Constraints:
x1 + x2 + x3 + x4 ≤ 45 (Manpower)
5x1 + 7x2 + 2x3 ≤ 100 (Wood pulp)
2x2 + 1x3 + 3x4 ≤ 75 (Fiber)
x1, x2, x3, x4 ≥ 0
87
Chapter 4 Interpreting Results from Different Methodologies
Here the model object is defined using the LpProblem module with
sense set to LpMaximize as we want to maximize the profit made from the
production.
88
Chapter 4 Interpreting Results from Different Methodologies
Step 5: Utilizing the default solver method for solving the given
optimization problem
[Out]:
status: 1, Optimal
objective: 512.5
x1: 20.0
x2: 0.0
x3: 0.0
x4: 25.0
Manpower: 0.0
Wood_Pulp: 0.0
Fiber: 0.0
From the previous output, we can see that the model suggests
producing 20 units of x1, i.e., diapers, and 25 units of x4, i.e., toilet paper, for
a maximum profit ($512.5) under the given constraints. Now, in a dynamic
real-world factory setting, the constraints will change, and hence there
arises a need to build a solution that can update the constraints based
on the changes (e.g., changes in profit value of the products) happening
over time due to multiple factors. So, this solution can be built into an
89
Chapter 4 Interpreting Results from Different Methodologies
API solution that can accept inputs (constraints and other details) either
manually through an UI or through other system outputs, and the results
can be consumed either through the same UI or through any other
application (Excel, custom applications, etc.).
Figure 4-1 shows how the high-level solution architecture would look.
Nonlinear Models
Linear models assume that the relationship between the inputs and
outputs is always linear. This assumption is often not true in real-world
situations where the relationship between variables is complex and
nonlinear. This is where the need for nonlinear models arises. They
can capture the complex behavior/relationships between the inputs
and outputs more accurately. They can be represented by the following
equation:
y = f(x)
where:
90
Chapter 4 Interpreting Results from Different Methodologies
Let’s understand how to solve a nonlinear problem with the help of the
following use case.
Problem Statement:
After the COVID-19 pandemic, company X plans to gradually have
its employees return to work at the office while maintaining a minimum
of 25 percent occupancy in both of its office blocks to ensure efficient
operations. The government has provided a risk index to assist companies
in determining the risks associated with re-opening offices during the
current situation. The risk index (RI) is defined in the following manner:
RI = 3x12 + 3x13 +x1x2- 2x22 + 2x23
where:
What is the safest way (according to the RI) for company X to resume
work from the office?
Solution:
With the RI definition and considering company X wants to minimize
the risk, we can define the objective function as follows:
Minimize: RI = 3x12 + 3x13 +x1x2- 2x22 + 2x23
Constraints:
x1 ≥ 0.25
x2 ≥ 0.25
x1, x2 ≤ 1
For this nonlinear problem, we will use the scipy package to derive the
solution.
Step 1: Importing the required libraries (especially scipy)
[In]:
import numpy as np
91
Chapter 4 Interpreting Results from Different Methodologies
import pandas as pd
import random
from scipy.optimize import minimize
[In]:
def geneate_kickoff_points(number_of_points):
'''
number_of_points [list]: how many points to generate
'''
kickoff_points = []
for point in range(number_of_points):
kickoff_points.append((random.random(), random.
random()))
return kickoff_points
92
Chapter 4 Interpreting Results from Different Methodologies
[In]:
for point in kickoff_points:
# for each point run the algorithm
result = minimize(
objective_function,
[point[0], point[1]],
method='SLSQP',
bounds=boundaries,
constraints=constraints
)
# first iteration always going to be the best so far
if first_iteration:
better_solution_found = False
best_solution = result
else:
# if we find a better solution, lets use it
if result.success and result.fun < best_solution.fun:
better_solution_found = True
best_solution = result
93
Chapter 4 Interpreting Results from Different Methodologies
94
Chapter 4 Interpreting Results from Different Methodologies
Markov Chain
Markov chain models are a type of probabilistic models that can be
employed to study dynamic systems, where the likelihood of transitioning
from one state to another is determined solely by the present state, without
any dependence on the system’s past history.
An example of a Markov chain model is a stock market model that
has three states: bull, bear, and flat. We can represent this as a three-state
Markov chain model, where the transition probabilities between states
depend only on the current state. For example, let’s say that the probability
of moving from a bull market to a bear market is 0.3, and it is 0.6 for staying
in bull market itself. The probability of moving from a bear market to a flat
market is 0.2, and it is 0.3 for staying in bear market itself. The probability
of moving from a flat market to a bull market is 0.2, and the probability of
staying in the flat market is 0.6. Figure 4-2 shows what the transition matrix
for the stock market model.
95
Chapter 4 Interpreting Results from Different Methodologies
[In]:
import numpy as np
import pandas as pd
from ChannelAttribution import *
96
Chapter 4 Interpreting Results from Different Methodologies
[In]:
attribution_data = pd.read_csv('attribution_data.csv')
attribution_data['time'] = pd.to_datetime(attribution_
data['time'])
daily_budget = pd.read_csv('daily_budget.csv')
[In]:
attribution_data['path_order'] = attribution_data.sort_
values(['time']).groupby(['cookie']).cumcount() + 1
[In]:
attribution_data_paths = attribution_data.groupby('cookie')
['channel'].agg(lambda x: x.tolist()).reset_index()
attribution_data_paths = attribution_data_paths.
rename(columns={'channel': 'path'})
[In]:
attribution_data_conversions = attribution_data.
groupby('cookie', as_index=False).agg({'conversion': 'sum',
'conversion_value': 'sum'})
97
Chapter 4 Interpreting Results from Different Methodologies
[In]:
attribution_data_final = pd.merge(attribution_data_paths,
attribution_data_conversions, how='left', on='cookie')
[In]:
print('Total conversions: {}'.format(sum(attribution_data.
conversion)))
print('Total conversion rate: {}%'.
format(round(sum(attribution_data.conversion) /
len(attribution_data)*100)))
print('Total value of conversions: ${}'.
format(round(sum(attribution_data.conversion_value))))
print('Average conversion value: ${}'.
format(round(sum(attribution_data.conversion_value) /
sum(attribution_data.conversion))))
[Out]:
Total conversions: 19613
Total conversion rate: 3%
Total value of conversions: $122529
Average conversion value: $6
[In]:
def listToString(df):
str1 = ""
for i in df['path']:
str1 += i + ' > '
return str1[:-3]
attribution_data_final['path'] = attribution_data_final.
apply(listToString, axis=1)
98
Chapter 4 Interpreting Results from Different Methodologies
We remove the user’s cookie and grouping by the path to see how
many times a specific combination of channels led to a conversion or null
outcome.
[In]:
attribution_data_final.drop(columns = 'cookie', inplace = True)
attribution_data_final['null'] = np.where(attribution_data_
final['conversion'] == 0,1,0)
attribution_data_final = attribution_data_final.
groupby(['path'], as_index = False).sum()
attribution_data_final.rename(columns={"conversion": "total_
conversions", "null": "total_null", "conversion_value": "total_
conversion_value"}, inplace = True)
[In]:
heuristic_models = heuristic_models(attribution_data_
final,"path","total_conversions",var_value="total_
conversion_value")
markov_model = markov_model(attribution_data_final, "path",
"total_conversions", var_value="total_conversion_value")
[Out]:
Number of simulations: 100000 - Convergence reached:
0.85% < 5.00%
Percentage of simulated paths that successfully end before
maximum number of steps (456) is reached: 99.99%
[In]:
all_attribution_models_result = pd.merge(heuristic_
models,markov_model,on="channel_name",how="inner")
99
Chapter 4 Interpreting Results from Different Methodologies
all_attribution_models_conversion_result = all_attribution_
models_result[["channel_name","first_touch_conversions","last_
touch_conversions",\
"linear_touch_conversions","total_conversions"]]
all_attribution_models_conversion_result.columns = ["channel_
name","first_touch","last_touch","linear_touch","markov_model"]
all_attribution_models_conversion_value_result = all_
attribution_models_result[["channel_name","first_touch_
value","last_touch_value",\
"linear_touch_value","total_conversion_value"]]
all_attribution_models_conversion_value_result.columns
= ["channel_name","first_touch","last_touch","linear_
touch","markov_model"]
all_attribution_models_conversion_value_result =
pd.melt(all_attribution_models_conversion_value_result, id_
vars="channel_name")
[In]:
daily_budget_agg = daily_budget.drop(['day', 'impressions'],
axis=1).groupby('channel', as_index=False).sum('cost')
daily_budget_agg.columns = ['channel_name', 'cost']
roas_data = pd.merge(all_attribution_models_conversion_result,
daily_budget_agg)
roas_data['channel_weight'] = (roas_data['markov_model'])/
(sum(roas_data['markov_model']))
roas_data['cost_weight'] = (roas_data['cost'])/(sum(roas_
data['cost']))
roas_data['roas'] = (roas_data['channel_weight'])/(roas_
data['cost_weight'])
100
Chapter 4 Interpreting Results from Different Methodologies
roas_data['optimal_budget'] = (roas_data['cost'])*(roas_
data['roas'])
roas_data['optimal_budget_percentage'] = (round((roas_
data['optimal_budget'])/(sum(roas_data['optimal_
budget'])),2))*100
roas_data.head()
[Out]:
101
102
Chapter 4
From the previous output, the team realized that Instagram and online
display channels, while performing well in driving the conversions, were
under-budgeted. They need to be given a higher share of the marketing
budget, which, in this case is 23 percent and 12 percent for Instagram and
online display, respectively.
103
Chapter 4 Interpreting Results from Different Methodologies
Solution:
As the company has access to historical data, it makes sense to
build a machine learning model that can find the traits of employees
fit for promotion. As the goal is to find the list of employees who can be
promoted, it will come under the supervised classification category.
Step 1: Importing the libraries and reading the training and
test data
[In]:
from sklearn.preprocessing import LabelEncoder, StandardScaler,
RobustScaler
from sklearn.model_selection import train_test_split,
StratifiedKFold
from sklearn.linear_model import LogisticRegression
from sklearn.impute import SimpleImputer
from sklearn.metrics import *
import pandas as pd
import numpy as np
[In]:
training_data = pd.read_csv('hr_train.csv')
test_data = pd.read_csv('hr_test.csv')
[In]:
del training_data['employee_id']
del test_data['employee_id']
categorical_columns = [c for c in training_data.columns if
training_data[c].dtypes=='object']
104
Chapter 4 Interpreting Results from Different Methodologies
[In]:
training_data = training_data[training_data.length_of_
service<30]
[In]:
target = training_data.pop('is_promoted')
all_data = pd.concat([training_data, test_data], axis=0)
si_most_frequent = SimpleImputer(strategy= 'most_frequent')
all_data['education'] = si_most_frequent.fit_transform(all_
data.education.values.reshape(-1, 1))
si_mean = SimpleImputer(strategy='mean')
all_data['previous_year_rating'] = si_mean.fit_transform(all_
data.previous_year_rating.values.reshape(-1, 1))
105
Chapter 4 Interpreting Results from Different Methodologies
[In]:
all_data_dummy = pd.get_dummies(all_data)
new_training_data = all_data_dummy.iloc[:len(training_data)]
new_test_data = all_data_dummy.iloc[len(training_data):]
ss = StandardScaler()
new_training_data = ss.fit_transform(new_training_data)
new_test_data = ss.transform(new_test_data)
[In]:
scores = []
probs = np.zeros(len(new_training_data))
y_le = target.values
folds = StratifiedKFold(n_splits=5, shuffle=True, random_
state=42)
106
Chapter 4 Interpreting Results from Different Methodologies
107
Chapter 4 Interpreting Results from Different Methodologies
Conclusion
In this chapter, we went through practical real-world use-case problems
and how they can be solved through different decision intelligence
methodologies. We also saw how the output from the different models can
be used for interpretation and how one can build a decision intelligence
workflow from it. We have specifically focused on some of the most
used mathematical, probabilistic, and AI/ML models, as covering all
methodologies in a single chapter/book is impossible.
108
CHAPTER 5
Augmenting Decision
Intelligence Results
into the Business
Workflow
In today’s rapidly changing business environment, organizations are under
increasing pressure to make informed decisions that drive growth and
competitiveness. Decision intelligence (DI) is a powerful tool that can help
organizations make better decisions by leveraging the power of artificial
intelligence (AI) and data analytics. However, to fully realize the benefits
of DI, it is essential to integrate the outputs of DI models into existing
business workflows.
In this chapter, we will discuss how to effectively integrate DI into
business workflows through the development of user-friendly applications
that connect AI predictions to existing business tools, the importance
of collaboration between DI experts and business teams, and some
of the technical challenges involved in integrating DI into existing
business systems. By successfully integrating DI into business workflows,
organizations can leverage the power of AI to drive better decision-making
and improve business outcomes.
Challenges
Integrating decision intelligence with business workflows can be a
complex process and comes with several challenges. Here are some of the
main challenges organizations may face:
• Data quality and availability: One of the primary
challenges is ensuring that the data used by the DI
process is of high quality and readily available. Data
quality issues, such as missing or incorrect data, can
impact the accuracy and usefulness of the insights
generated by the DI process.
110
Chapter 5 Augmenting Decision Intelligence Results into the Business Workflow
111
Chapter 5 Augmenting Decision Intelligence Results into the Business Workflow
Workflow
Let’s understand the steps involved to ensure DI outputs are properly
ingested into business workflows and overcome the previous challenges.
112
Chapter 5 Augmenting Decision Intelligence Results into the Business Workflow
113
Chapter 5 Augmenting Decision Intelligence Results into the Business Workflow
114
Chapter 5 Augmenting Decision Intelligence Results into the Business Workflow
115
Chapter 5 Augmenting Decision Intelligence Results into the Business Workflow
4. Test and validate the app: Once the app has been
developed, it is important to test and validate it
to ensure that it is working as expected. This may
involve unit testing, integration testing, and user
acceptance testing. The testing phase helps to
identify any bugs or issues that need to be addressed
before the app is deployed.
5. Deploy the app: Once the app has been tested and
validated, it is ready to be deployed to a production
environment. This may involve working with IT
professionals to ensure that the app is secure,
scalable, and reliable.
User-Friendly Interfaces
Designing user-friendly interfaces is essential when integrating decision
intelligence outputs into business workflows. Because the users are
nontechnical, it’s important to develop interfaces that are easy to use and
take actions.
Here are some reasons why a user-friendly interface matters:
116
Chapter 5 Augmenting Decision Intelligence Results into the Business Workflow
117
Chapter 5 Augmenting Decision Intelligence Results into the Business Workflow
ugmenting AI Predictions
A
to Business Workflow
Connecting AI predictions to business tools involves integrating the
AI system with existing business systems, such as enterprise resource
planning (ERP) systems, customer relationship management (CRM)
systems, and business intelligence (BI) tools. Here are the technical steps
to connect AI predictions to business tools:
118
Chapter 5 Augmenting Decision Intelligence Results into the Business Workflow
119
Chapter 5 Augmenting Decision Intelligence Results into the Business Workflow
120
Chapter 5 Augmenting Decision Intelligence Results into the Business Workflow
121
Chapter 5 Augmenting Decision Intelligence Results into the Business Workflow
Conclusion
In this chapter, we discussed how decision intelligence can be integrated
into business workflows through the development of user-friendly
applications that connect AI predictions to existing business tools. We
highlighted the importance of collaboration between DI experts and
business teams to ensure that the outputs of DI models are properly
integrated into business workflows. We also discussed some of the
technical challenges involved in integrating DI into business workflows,
such as connecting to legacy systems and ensuring data security.
To successfully integrate DI into business workflows, it is essential to
develop user-friendly interfaces that make it easy for nontechnical users to
interact with the DI models and understand the outputs. The development
122
Chapter 5 Augmenting Decision Intelligence Results into the Business Workflow
123
CHAPTER 6
126
Chapter 6 Actions, Biases, and Human-in-the-Loop
127
Chapter 6 Actions, Biases, and Human-in-the-Loop
Cognitive Biases
Cognitive biases can also play a significant role in the development and
implementation of artificial intelligence (AI) and machine learning (ML)
algorithms. These biases can arise from a variety of sources, including
the data used to train the algorithms, the assumptions and biases of the
developers and users, and the design of the algorithms themselves.
For example, if the data used to train an AI system is biased, such as
containing gender or racial biases, then the system may produce biased
results. This is because the AI system learns from the data it is trained on,
and if the data contains biased patterns, those patterns can be replicated in
the output of the system.
Another example is the bias in the selection of features used to train
the AI system. If the selected features are not representative of the problem
domain, the AI system may produce inaccurate or biased results.
In addition, cognitive biases of the developers and users can also
influence the design and implementation of AI and ML systems. For
instance, confirmation bias may lead to overlooking important factors in
the development process, while anchoring bias may result in over-reliance
on certain data or features.
128
Chapter 6 Actions, Biases, and Human-in-the-Loop
129
Chapter 6 Actions, Biases, and Human-in-the-Loop
Types
Several types of biases can occur in AI and ML algorithms. Here are some
of the most common types:
130
Chapter 6 Actions, Biases, and Human-in-the-Loop
131
Chapter 6 Actions, Biases, and Human-in-the-Loop
132
Chapter 6 Actions, Biases, and Human-in-the-Loop
Bias Detection
Detecting bias in AI and ML algorithms can be challenging, but there are
several approaches that can be taken to identify and mitigate bias.
133
Chapter 6 Actions, Biases, and Human-in-the-Loop
134
Chapter 6 Actions, Biases, and Human-in-the-Loop
135
Chapter 6 Actions, Biases, and Human-in-the-Loop
136
Chapter 6 Actions, Biases, and Human-in-the-Loop
137
Chapter 6 Actions, Biases, and Human-in-the-Loop
Overall, HITL systems are a powerful tool for improving the accuracy,
transparency, and adaptability of AI and ML systems and can help
organizations ensure that their algorithms are making fair and ethical
decisions.
138
Chapter 6 Actions, Biases, and Human-in-the-Loop
139
Chapter 6 Actions, Biases, and Human-in-the-Loop
140
Chapter 6 Actions, Biases, and Human-in-the-Loop
Conclusion
In this chapter, we discussed how cognitive biases are a prevalent issue
in AI and ML and can have significant negative impacts on organizations
and individuals. To address this problem, human-in-the-loop systems
can be implemented to incorporate human input and feedback into the
decision-making process of algorithms. HITL systems can help detect and
mitigate biases, improve the accuracy and fairness of AI and ML systems,
141
Chapter 6 Actions, Biases, and Human-in-the-Loop
and ensure that they align with the values and goals of the organization.
Building an HITL system involves identifying the problem, choosing
the right algorithm, defining the HITL process, developing the user
interface, collecting and incorporating human feedback, and continuously
monitoring and refining the system. By using HITL systems, organizations
can make more informed and ethical decisions that benefit both the
organization and its stakeholders.
142
CHAPTER 7
Case Studies
This chapter will explore how decision intelligence can be integrated into
organizations through a series of case studies. We will delve into various
methodologies and examine how they can produce actionable insights for
decision-makers, both independently and when used in conjunction with
other methods.
While we have already covered many methodologies in prior chapters
and demonstrated how they can be applied to decision intelligence, it
is uncommon to find a single methodology that can effectively solve a
decision intelligence problem. The problems are often so intricate that
employing a combination of methodologies is necessary to achieve the
desired outcome.
Let’s explore how AI/ML along with other advanced techniques can
help in decision-making through two case studies: one classification and
another regression.
Solution:
The AI team proposes a hybrid solution to solve the given problem.
The plan is to first build a machine learning model that takes historical
customer details such as account information, demographics, and
services used, along with churn status. The model output will be used to
find potential customers who are likely to churn in the coming time. The
team also proposes a counterfactual generation engine that can provide
various scenarios wherein the predicted outcomes change. For example, if
a customer is likely to churn and their churn probability is 90 percent, the
counterfactual engine can generate change in input features that might
bring the churn probability for the given customer to maybe 40 percent.
This change in the input parameters can be used as part of their retention
strategy. A third component of a what-if analysis solution can help
decision-makers tweak the counterfactual suggestions based on certain
constraints and check whether those changes can still retain customers.
The AI team suggests following benefits of using the proposed hybrid
solution:
144
Chapter 7 Case Studies
145
Chapter 7 Case Studies
Dataset Details:
The dataset on customer churn pertains to a hypothetical telecom
business that operated in California during the third quarter and
encompasses information on 7,043 customers who had either churned,
retained, or acquired the company’s services. The dataset further features
various crucial demographic variables for each customer.
Demographics:
146
Chapter 7 Case Studies
Services:
147
Chapter 7 Case Studies
Source: https://community.ibm.com/community/user/
businessanalytics/blogs/steven-macko/2019/07/11/telco-customer-
churn-1113
148
Chapter 7 Case Studies
techniques and ML algorithms are available, we will use the ones that give
satisfactory results to ensure we are spending more efforts toward the goal,
i.e., building a decision intelligence system.
[In]:
import dice_ml
import numpy as np
import pandas as pd
from sklearn.preprocessing import LabelEncoder
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import RandomizedSearchCV,
train_test_split
from sklearn.metrics import accuracy_score, precision_score,
recall_score, f1_score
[In]:
churn_data_all = pd.read_csv('telco_churn.csv')
[In]:
churn_data_all.info()
[Out]:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 7043 entries, 0 to 7042
Data columns (total 21 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 customerID 7043 non-null object
149
Chapter 7 Case Studies
1 gender 7043 non-null object
2 SeniorCitizen 7043 non-null int64
3 Partner 7043 non-null object
4 Dependents 7043 non-null object
5 tenure 7043 non-null int64
6 PhoneService 7043 non-null object
7 MultipleLines 7043 non-null object
8 InternetService 7043 non-null object
9 OnlineSecurity 7043 non-null object
10 OnlineBackup 7043 non-null object
11 DeviceProtection 7043 non-null object
12 TechSupport 7043 non-null object
13 StreamingTV 7043 non-null object
14 StreamingMovies 7043 non-null object
15 Contract 7043 non-null object
16 PaperlessBilling 7043 non-null object
17 PaymentMethod 7043 non-null object
18 MonthlyCharges 7043 non-null float64
19 TotalCharges 7032 non-null float64
20 Churn 7043 non-null object
dtypes: float64(2), int64(2), object(17)
memory usage: 1.1+ MB
[In]:
churn_data_all[churn_data_all['TotalCharges'].isnull()].head()
[Out]:
150
customerID gender SeniorCitizen Partner Dependents tenure Phone MultipleLines Total Churn
Service Charges
151
Case Studies
Chapter 7 Case Studies
(Some columns are not shown in the previous table to fit within the
viewable window.)
From the previous table, we find that the TotalCharges column is null
when the tenure is 0. This means the customers who have joined recently
and haven’t even completed 1 month with the telecom operator will have
their TotalCharges as null. Let’s convert the null value to 0, as that would
be the most appropriate value.
[In]:
churn_data_all['TotalCharges'] = np.where(churn_
data_all['TotalCharges'].isnull(), 0, churn_data_
all['TotalCharges'])
[In]:
churn_data_all['SeniorCitizen'] = np.where(churn_data_all.
SeniorCitizen == 1,"Yes","No")
We create a list of column names based on their type and use that.
[In]:
all_columns = [x for x in churn_data_all.drop('customerID',
axis = 1).columns]
id_column = ['customerID']
target_column = ['Churn']
categorical_columns = [y for y in churn_data_all.
drop('customerID', axis = 1).select_dtypes(include = [object]).
columns]
numeric_columns = [z for z in all_columns if z not in
categorical_columns]
[In]:
152
Chapter 7 Case Studies
get_dummies = []
label_encoding = []
for i in categorical_columns:
print('Column Name:', i, ', Unique Value Counts:',
len(churn_data_all[i].unique()), ', Values:', churn_data_
all[i].unique())
if len(churn_data_all[i].unique()) > 2:
get_dummies.append(i)
else:
label_encoding.append(i)
[Out]:
Column Name: gender , Unique Value Counts: 2 , Values:
['Female' 'Male']
Column Name: SeniorCitizen , Unique Value Counts: 2 , Values:
['No' 'Yes']
Column Name: Partner , Unique Value Counts: 2 , Values:
['Yes' 'No']
Column Name: Dependents , Unique Value Counts: 2 , Values:
['No' 'Yes']
Column Name: PhoneService , Unique Value Counts: 2 , Values:
['No' 'Yes']
Column Name: MultipleLines , Unique Value Counts: 3 , Values:
['No phone service' 'No' 'Yes']
Column Name: InternetService , Unique Value Counts: 3 , Values:
['DSL' 'Fiber optic' 'No']
Column Name: OnlineSecurity , Unique Value Counts: 3 , Values:
['No' 'Yes' 'No internet service']
Column Name: OnlineBackup , Unique Value Counts: 3 , Values:
['Yes' 'No' 'No internet service']
Column Name: DeviceProtection , Unique Value Counts: 3 ,
Values: ['No' 'Yes' 'No internet service']
153
Chapter 7 Case Studies
We can see that some categorical columns have two unique values,
whereas some have more than two. To apply appropriate techniques, we
have split the columns.
We apply dummy variable creation techniques to columns having
more than two unique values.
[In]:
churn_data_all_dl = pd.get_dummies(churn_data_all, prefix=get_
dummies, columns=get_dummies)
mappings = {}
for col in label_encoding:
le = LabelEncoder()
154
Chapter 7 Case Studies
churn_data_all_dl[col] = le.fit_transform(churn_data_all_
dl[col])
mappings[col] = dict(zip(le.classes_,range(len(le.
classes_))))
mappings
[Out]:
{'gender': {'Female': 0, 'Male': 1},
'SeniorCitizen': {'No': 0, 'Yes': 1},
'Partner': {'No': 0, 'Yes': 1},
'Dependents': {'No': 0, 'Yes': 1},
'PhoneService': {'No': 0, 'Yes': 1},
'PaperlessBilling': {'No': 0, 'Yes': 1},
'Churn': {'No': 0, 'Yes': 1}}
Step 5: Modeling
We split the dataset for training and inference.
[In]:
X = churn_data_all_dl.drop(['customerID', 'Churn'], axis=1)
y = churn_data_all_dl['Churn']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_
size = 0.2, stratify=y, random_state = 0)
Hyperparameter Tuning
The process of hyperparameter tuning entails identifying the best
hyperparameter combination for a learning algorithm, which can be
employed to optimize its performance on any given dataset. By minimizing
a prespecified loss function, the selected hyperparameters can reduce
errors and improve the model’s results.
155
Chapter 7 Case Studies
[In]:
n_estimators = [int(x) for x in np.linspace(start = 100,
stop = 2100, num = 6)]
feature_name = list(X_test.columns)
max_depth = [int(x) for x in np.linspace(10, 100, num = 5)]
max_depth.append(None)
min_samples_split = [2, 5, 10]
min_samples_leaf = [1, 2, 4, 6, 8, 10]
random_grid = {'n_estimators':n_estimators,
'max_depth': max_depth,
'min_samples_split': min_samples_split,
'min_samples_leaf': min_samples_leaf}
print(random_grid)
rf = RandomForestClassifier()
rf_random = RandomizedSearchCV(estimator = rf, param_
distributions = random_grid, n_iter = 10, cv = 2, verbose=2,
random_state=42, n_jobs = -1)
rf_random.fit(X_train[feature_name], y_train)
print(rf_random.best_params_)
[Out]:
{'n_estimators': [100, 500, 900, 1300, 1700, 2100], 'max_
depth': [10, 32, 55, 77, 100, None], 'min_samples_split':
[2, 5, 10], 'min_samples_leaf': [1, 2, 4, 6, 8, 10]}
156
Chapter 7 Case Studies
We see that for the random forest model (the algorithm of choice in
this case), the best combination of hyperparameters is as follows:
• n_estimators = 100
• min_samples_split = 2
• min_samples_leaf = 8
• max_depth = 10
[In]:
feature_name = list(X_test.columns)
churn_classifier=RandomForestClassifier(n_estimators=100,min_
samples_split=2,min_samples_leaf=8,max_depth=10)
churn_classifier.fit(X_train[feature_name],y_train)
[Out]:
RandomForestClassifier(bootstrap=True, ccp_alpha=0.0, class_
weight=None,
criterion='gini', max_depth=10, max_
features='auto',
max_leaf_nodes=None, max_samples=None,
min_impurity_decrease=0.0, min_impurity_
split=None,
min_samples_leaf=8, min_samples_split=2,
min_weight_fraction_leaf=0.0,
n_estimators=100,
n_jobs=None, oob_score=False, random_
state=None,
verbose=0, warm_start=False)
Now, we use the trained model for making predictions on the test data
and save them along with the prediction probabilities.
157
Chapter 7 Case Studies
[In]:
pred_df = X_test.copy()
pred_df['Churn'] = y_test
pred_df['pred'] = churn_classifier.predict
(X_test[feature_name])
prediction_of_probability = churn_classifier.predict_proba
(X_test[feature_name])
pred_df['prob_0'] = prediction_of_probability[:,0]
pred_df['prob_1'] = prediction_of_probability[:,1]
[In]:
print("Accuracy: ", (accuracy_score(pred_df['Churn'],
pred_df['pred']))*100)
print("Precision: ", (precision_score(pred_df['Churn'],
pred_df['pred']))*100)
print("Recall: ", (recall_score(pred_df['Churn'], pred_
df['pred']))*100)
print("F1 Score: ", (f1_score(pred_df['Churn'], pred_
df['pred']))*100)
[Out]:
Accuracy: 80.48261178140525
Precision: 67.1280276816609
Recall: 51.87165775401069
F1 Score: 58.521870286576174
158
Chapter 7 Case Studies
Now that we have the model and predictions ready, let’s move on and
start using them for decision-making.
159
Chapter 7 Case Studies
Counterfactual Analysis:
Counterfactuals refer to a type of analysis that involves identifying
the minimal set of changes required to an input instance such that the
machine learning model output changes to a desired outcome. In simpler
terms, counterfactuals are hypothetical examples of inputs that would lead
to a different output from a machine learning model.
Counterfactual analysis can be used to explain the behavior of a
machine learning model and to provide insights into how the model
can be improved as well as what actions can be taken so that favorable
outcomes can be generated. It can also be used for various applications
such as fairness analysis, where the minimal set of changes required to
achieve a desired outcome can be used to identify potential sources of bias
in the model. Additionally, counterfactual analysis can be used for causal
inference, where the minimal set of changes can be used to estimate the
causal effect of a treatment on an outcome.
We will be using the DiCEML Python package for generating
counterfactuals.
DiCELML
DiCEML (Diverse Counterfactual Explanations through Mixed Integer
Linear Programming) is a framework that enables the generation of
counterfactual examples for machine learning models. DiCEML employs
mixed-integer linear programming to find a minimal set of changes to
input instances required to change the model output to a desired outcome.
It is a state-of-the-art method for generating diverse counterfactual
explanations that take into account the constraints and features of the
input data and can be used for various applications such as explainable AI,
fairness analysis, and causal inference.
Step 6: Building a counterfactual explainer object
[In]:
def initialize_counterfactuals(
160
Chapter 7 Case Studies
Args:
train_df (dataframe) : train dataframe
model (object) : input model (to explain)
feature_list (list) : list of features used in model
continuous_features (list) : list of continuous
features
target (str) : target column name
model_type (str) : classification or regression
Returns:
explainer (object) : counterfactual explainer object
feature_range (dict) : dictionary containing
permissible feature ranges for continuous features
"""
df_model = train_df[feature_list + [target]]
161
Chapter 7 Case Studies
for i in continuous_features:
feature_range[i] = [
df_model[i].astype(float).min(),
df_model[i].astype(float).max(),
]
def preprocess_encode(df,mappings,feature_list):
if mappings != None:
encode_df = df[feature_list]
cat_cols = (encode_df.dtypes == object)
cat_cols = list(cat_cols[cat_cols==True].index)
162
Chapter 7 Case Studies
encode_df = df.copy()
if len(cat_cols)>0:
encode_df.update(encode_df[cat_cols].apply(lambda
col: col.map(mappings[col.name])).astype(int))
encode_df[cat_cols] = encode_df[cat_cols].
astype(int)
else:
encode_df = df.copy()
return encode_df
def postprocess_decode(df,mappings):
decoded_output = df.copy()
if mappings != None:
inv_mapping_dict = {cat: {v: k for k, v in map_dict.
items()} for cat, map_dict in mappings.items()}
decoded_output[list(mappings.keys())] = decoded_
output[list(mappings.keys())].astype(int)
decoded_output = decoded_output.replace(inv_
mapping_dict)
return decoded_output
def generate_output_counterfactuals(explainer,feature_
range,query_instance,model_type,model,feature_list,desired_
class_or_range,continuous_features,features_vary='all',num_
cf=3,mappings={}):
"""
Generating the counterfactuals output for a particular
query_instance (record), given various other inputs like
features to vary, etc.
Args:
explainer (object) : Counterfactuals explainer object
163
Chapter 7 Case Studies
Returns:
cf_output (dataframe) : counterfactuals output
dataframe
"""
query_instance[continuous_features] = query_
instance[continuous_features].astype(float).round(4)
query_instance_processed = preprocess_encode(query_
instance,mappings,list(query_instance.columns))
display(query_instance_processed)
if model_type == 'classification':
cf_exp = explainer.generate_counterfactuals(query_
instance_processed, total_CFs=20,desired_class=desired_
class_or_range,permitted_range=feature_range,features_
to_vary=features_vary)
164
Chapter 7 Case Studies
else:
cf_exp = explainer.generate_counterfactuals(query_
instance_processed, total_CFs=num_cf,desired_
range=desired_class_or_range,permitted_range=feature_
range,features_to_vary=features_vary)
cf_exp_df = cf_exp.cf_examples_list[0].final_cfs_df
cf_exp_df = postprocess_decode(cf_exp_df,mappings)
cf_output = cf_ouput_df_fn(cf_exp_df,query_instance)
return cf_output
def cf_ouput_df_fn(df,org_df):
newdf = df.values.tolist()
org = org_df.values.tolist()[0]
for ix in range(df.shape[0]):
for jx in range(len(org)):
if str(newdf[ix][jx]) == str(org[jx]):
newdf[ix][jx] = '-'
else:
newdf[ix][jx] = str(newdf[ix][jx])
return pd.DataFrame(newdf, columns=df.columns,
index=df.index)
train_df = X_train.copy()
train_df["Churn"] = y_train
165
Chapter 7 Case Studies
model_type='classification'
target = 'Churn'
explainer, feature_range = initialize_counterfactuals(
train_df, churn_classifier, features, numeric_columns,
target, model_type
)
[Out]:
continuous features ['tenure', 'MonthlyCharges',
'TotalCharges']
[In]:
test_df = X_test.copy()
test_df["Churn"] = y_test
test_df_churners_input = test_df_churners.drop(['Churn',
'pred', 'prob_0', 'prob_1'], inplace=False, axis=1)
test_df_churners_input_record = test_df_churners_input[61:62]
dice_exp = explainer.generate_counterfactuals(test_df_churners_
input_record, total_CFs=4, desired_class="opposite", features_
to_vary=features_vary)
dice_exp.visualize_as_dataframe()
[Out]:
100%|██████████| 1/1 [00:31<00:00, 31.02s/it]
[In]:
test_df_churners_input_record[features_vary]
[Out]:
167
168
Chapter 7
Paperless Monthly Online Online Device Tech Streaming Streaming Contract_ Contract_
Billing Charges Security_ Backup_Yes Protection_Yes Support_Yes TV_Yes Movies_ One year Two year
Yes Yes
0 101.15 0 0 1 0 1 1 0 0
Case Studies
[In]:
dice_exp.cf_examples_list[0].final_cfs_df[features_vary]
Paperless Monthly Online Online Device Tech Streaming Streaming Contract_ Contract_
Billing Charges Security_Yes Backup_Yes Protection_ Support_ TV_Yes Movies_ One year Two year
Yes Yes Yes
0 55.36 1 0 1 0 1 1 0 0
0 35.86 1 0 1 0 1 1 0 0
0 22.32 1 0 1 0 1 1 0 0
0 67.89 1 0 1 0 1 1 0 0
Chapter 7 Case Studies
From the previous output, we see that the explainer model has
suggested four possible ways to retain the customer.
169
Chapter 7 Case Studies
Options:
[In]:
custom_input = test_df_churners_input_record.copy()
custom_input['MonthlyCharges'] = custom_
input['MonthlyCharges'].replace(101.15, 91)
custom_input['OnlineBackup_Yes'] = custom_
input['OnlineBackup_Yes'].replace(0, 1)
custom_input['OnlineSecurity_Yes'] = custom_
input['OnlineSecurity_Yes'].replace(0, 1)
if churn_classifier.predict(custom_input)==0:
print("Successfully retained the customer")
else:
print("Sorry, customer could not be retained")
print("\nProbability of Churn:",churn_classifier.
predict_proba(custom_input)[0][1].round(2))
[Out]:
Sorry, customer could not be retained
Probability of Churn: 0.57
[In]:
custom_input2 = test_df_churners_input_record.copy()
170
Chapter 7 Case Studies
custom_input2['MonthlyCharges'] = custom_
input2['MonthlyCharges'].replace(101.15, 91)
custom_input2['OnlineBackup_Yes'] = custom_
input2['OnlineBackup_Yes'].replace(0, 1)
custom_input2['OnlineSecurity_Yes'] = custom_
input2['OnlineSecurity_Yes'].replace(0, 1)
custom_input2['Contract_Two year'] = custom_
input2['Contract_Two year'].replace(0, 1)
if churn_classifier.predict(custom_input2)==0:
print("Successfully retained the customer")
else:
print("Sorry, customer could not be retained")
print("\nProbability of Churn:",churn_classifier.
predict_proba(custom_input2)[0][1].round(2))
[Out]:
Successfully retained the customer
Probability of Churn: 0.47
We can see that with the given set of inputs in this option that we
were successful in retaining the customer with a churn probability of the
customer coming down to 47 percent. So, this option can be converted to a
personalized offering to the customer.
Counterfactuals and “what-if” analysis can be used to detect bias in
machine learning models. It involves analyzing counterfactual outputs
or testing the model’s sensitivity to changes in the input data or model
parameters to identify areas where the model may be biased. Let’s see how
bias can be detected using counterfactual analysis + what-if for the same
previously used record, adding demographics SeniorCitizen and gender
into the features to vary the matrix.
171
Chapter 7 Case Studies
[In]:
test_df_churners_bias_inputs = test_df_churners_input[(test_
df_churners_input['SeniorCitizen'] == 1) | (test_df_churners_
input['gender'] == 1)]
features_vary_bias = ['SeniorCitizen', 'gender']
dice_exp_bias = explainer.generate_counterfactuals(test_
df_churners_bias_inputs[100:130], total_CFs=4, desired_
class="opposite", features_to_vary=features_vary_bias)
dice_exp_bias.visualize_as_dataframe()
[In]:
protected_columns = ["gender", "SeniorCitizen"]
target="pred"
for pro_col in protected_columns:
categories = list(pred_df[pro_col].unique())
172
Chapter 7 Case Studies
selection_rate_list = []
for cat in categories:
selection_rate = pred_df[(pred_df[target]==1)&(pred_
df[pro_col]==cat)].shape[0]/pred_df[pred_df[pro_
col]==cat].shape[0]
selection_rate_list.append(np.round(selection_rate,3))
disparate_impact = np.round(min(selection_rate_list)/
max(selection_rate_list),3)
print("Disparate Impact for",pro_col,":",disparate_impact)
[Out]:
Disparate Impact for gender : 0.843
Disparate Impact for SeniorCitizen : 0.438
The disparate impact score for the SeniorCitizen column is quite low,
suggesting a bias toward this feature, while the Gender column has a score
of about 84%, indicating a very fair treatment, which exceeds the threshold
of 80 percent. However, the SeniorCitizen score of about 44 percent is
significantly lower than the threshold value, indicating an unfair bias. It is
important to use multiple fairness metrics in conjunction with each other
to arrive at a conclusion.
173
Chapter 7 Case Studies
forecast prices for new phone models with a high degree of accuracy,
allowing them to optimize their pricing strategy and stay competitive in
the market.
Solution:
The AI team proposes a hybrid solution to solve the given problem.
The plan is to first build a machine learning model that takes historical
mobile details such as screen size, camera quality, processor speed,
battery life, and others along with the price. The model output will be
used to predict the potential price of the handset. The team also proposes
a counterfactual generation engine that can provide various scenarios
wherein the predicted outcomes change as per the expected price range.
For example, if the price of a handset is predicted to be X and if the
manufacturer wants to sell it at a price 10 percent to 15 percent more
than the predicted one, the engine will suggest changes in the phone’s
configuration to the expected price range. This change in the input
parameters can be used as part of product strategy. A third component
of a what-if analysis solution can help the decision-makers to tweak
the counterfactual suggestions based on certain constraints and check
whether those changes can still help them sell the phone at the expected
price range.
The AI team suggests the following benefits of using the proposed
hybrid solution for mobile pricing prediction:
174
Chapter 7 Case Studies
175
Chapter 7 Case Studies
Source: https://www.kaggle.com/datasets/mohannapd/mobile-
price-prediction
Stage 1: AI Model Creation
The goal of this activity is to build a machine learning model that
can fairly predict mobile prices. Although advanced data processing
techniques and ML algorithms are available, we will use the ones that give
satisfactory results to ensure we are spending more efforts toward the goal,
i.e., building a decision intelligence system.
Step 1: Importing the required libraries
[In]:
import pandas as pd
import dice_ml
from dice_ml import Dice
from sklearn.metrics import r2_score
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import train_test_split
[In]:
all_data = pd.read_csv('cellphone_price_data.csv')
all_data.head()
[Out]:
176
Product_ Price Sale weight resolution ppi cpu cpu internal ram RearCam Front_ battery thickness
id core freq mem Cam
177
Case Studies
Chapter 7 Case Studies
[In]:
all_data.info()
[Out]:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 161 entries, 0 to 160
Data columns (total 14 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Product_id 161 non-null int64
1 Price 161 non-null int64
2 Sale 161 non-null int64
3 weight 161 non-null float64
4 resolution 161 non-null float64
5 ppi 161 non-null int64
6 cpu core 161 non-null int64
7 cpu freq 161 non-null float64
8 internal mem 161 non-null float64
9 ram 161 non-null float64
10 RearCam 161 non-null float64
11 Front_Cam 161 non-null float64
12 battery 161 non-null int64
13 thickness 161 non-null float64
dtypes: float64(8), int64(6)
memory usage: 17.7 KB
As we see from the previous details, the dataset does not have any
missing values or any issues related to the data. So, no data preprocessing
is required here, and we can directly move on to the modeling.
178
Chapter 7 Case Studies
Step 4: Modeling
We split the dataset for training and inference.
[In]:
x=all_data.drop(['Price', 'Product_id'],axis=1)
y=all_data['Price']
x_train,x_test,y_train,y_test=train_test_split(x,y,test_
size=0.2,random_state=0)
[In]:
rf = RandomForestRegressor()
rf.fit(x_train,y_train)
[Out]:
RandomForestRegressor()
[In]:
predictions = rf.predict(x_test)
print('R2 score for Training Data: ', rf.score(x_train,
y_train))
print('R2 score for Inference Data: ', r2_score(y_
test,predictions))
[Out]:
R2 score for Training Data: 0.9945696702046988
R2 score for Inference Data: 0.9678002631345382
[In]:
x_test['predicted_price'] = predictions
x_train.info()
[Out]:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 128 entries, 80 to 47
Data columns (total 12 columns):
179
Chapter 7 Case Studies
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Sale 128 non-null int64
1 weight 128 non-null float64
2 resolution 128 non-null float64
3 ppi 128 non-null int64
4 cpu core 128 non-null int64
5 cpu freq 128 non-null float64
6 internal mem 128 non-null float64
7 ram 128 non-null float64
8 RearCam 128 non-null float64
9 Front_Cam 128 non-null float64
10 battery 128 non-null int64
11 thickness 128 non-null float64
dtypes: float64(8), int64(4)
memory usage: 13.0 KB
[In]:
x_train['Price'] = all_data['Price']
[In]:
d_mobile = dice_ml.Data(dataframe=x_train, continuous_
features=['Sale', 'weight', 'resolution', 'ppi', 'cpu core',
'cpu freq', 'internal mem', 'ram', 'RearCam', 'Front_Cam',
'battery', 'thickness'], outcome_name='Price')
m_mobile = dice_ml.Model(model=rf, backend="sklearn", model_
type='regressor')
[In]:
input_data = x_test.drop(['predicted_price'], axis=1)
input_record = input_data[0:1]
input_record.head()
[Out]:
181
182
Chapter 7
Sale weight resolution ppi cpu cpu internal ram RearCam Front_Cam battery thickness
core freq mem
Case Studies
[In]:
x_test[0:1].head()
[Out]:
Sale weight resolution ppi cpu cpu internal mem ram RearCam Front_ battery thickness predicted_
core freq Cam price
For the given record, we see that the predicted price is about
2.9K. Suppose if the manufacturer wants to sell the mobile at a price 10
percent to 15 percent higher than the predicted one, the explainer can be
used to see recommendations in the mobile configuration that can achieve
the objective.
[In]:
predicted_price = x_test[0:1].predicted_price
expected_price_range = [round(float(predicted_price*1.10), 0),
round(float(predicted_price*1.15), 0)]
random_mobile = explainer_mobile.generate_
counterfactuals(input_record, total_CFs=2,
desired_range=expected_price_range)
random_mobile.visualize_as_dataframe(show_only_changes=True)
[Out]:
100%|██████████| 1/1 [00:00<00:00, 1.40it/s]
Query instance (original outcome : 2942)
183
184
Chapter 7
Sale weight resolution ppi cpu cpu internal ram RearCam Front_ battery thickness Price
Case Studies
Sale weight resolution ppi cpu cpu internal ram RearCam Front_ battery thickness Price
core freq mem Cam
From the previous output, we see that the explainer model has suggested
two possible ways to sell the mobile at the expected price range.
[In]:
expected_internal_memory = int(input_
record['internal mem']*2)
expected_battery = int(input_
record['battery']*1.5)
custom_inputs = input_record.copy()
185
Chapter 7 Case Studies
186
Chapter 7 Case Studies
[In]:
expected_internal_memory2 = int(input_
record['internal mem']*4)
expected_battery2 = int(input_
record['battery']*1.5)
custom_inputs2 = input_record.copy()
custom_inputs2['internal mem'] = custom_
inputs2['internal mem'].replace(int(input_
record['internal mem']), expected_internal_
memory2)
custom_inputs2['battery'] = custom_
inputs2['battery'].replace(int(input_
record['battery']), expected_battery2)
print('New price based on updated
configuration: ', rf.predict(custom_inputs2))
if rf.predict(custom_inputs2)>=expected_price_
range[0]:
print("The given configuration helps in
getting the minimum expected price")
else:
print("The given configuration does not
help in getting the minimum expected price
of",expected_price_range[0])
[Out]:
New price based on updated
configuration: [3247.54]
The given configuration helps in getting the
minimum expected price of 3236.0
We can see that the second option gives us the right configuration to
achieve the objective of increasing the handset price by at least 10 percent
of the predicted one.
187
Chapter 7 Case Studies
Conclusion
In this chapter, we saw how decision-making can be supported by applying
AI/ML and other advanced techniques (counterfactuals and what-if
analysis). We saw how organizations not only can predict which customers
are going to churn but also can take proactive measures to avoid the
churn, with the help of counterfactuals and what-if analysis. We also saw
how a combination of machine learning predictions, counterfactuals,
and what-if analysis can help mobile manufacturers design their product
configurations (screen size, RAM, etc.) and get the desired price over the
predicted ones. Through these use cases we covered decision intelligence
for classification and regression problems.
188
Index
A Authority-based decision-
making, 63, 65
Accountability, 126
Autonomous systems, 81
AI-driven tool, 175
AI/ML models, 103, 108
AI-powered decision-making, 12
B
Artificial intelligence (AI), 109
Bayesian inference, 19
advanced technologies, 1
Bayesian networks, 77
challenges, 7, 8
Bias detection
customization, 9
data analysis, 2 auditing, 133
goal, 1 data analysis, 133
integration, 9 expert review, 134
key ethical considerations, 125 testing, 133
accountability, 126 Bias detection tools, 134
bias and fairness, 126 data analysis techniques, 134
human values and fairness metrics, 135
rights, 126 human review, 135
privacy and security, 126 machine learning
transparency and algorithms, 135
explainability, 126 statistical analysis
machine learning techniques, 135
algorithms, 1 Biased decision-making, 132
risk management, 9 Biases, 127
transparency, 9 algorithmic bias, 131
types, 1–5 automation bias, 131
variety of applications, 1 cognitive biases, 129
Attribution model package, 98, 99 confirmation bias, 130
190
INDEX
191
INDEX
H
E Human decision-making
Ethical AI, 125 history, 59
Ethics-based decision-making Human-in-the-loop (HITL)
types, 60 systems, 127, 136–141
Ethics-based/moral-based Human-machine
decision-making, 60 decision-making, 81
advantages, 61 Humans-only decision-making, 58
disadvantages, 61 Hyperparameter tuning, 155
Experience-based Hypothetical telecom business, 146
decision-making, 62
advantages, 62
disadvantages, 63
I, J, K
evidence-based, 62 Individual decision-making, 48
intuition-based, 62 Instagram, 103
rule-based, 62 Instruction/rule-based systems, 74
Explainer counterfactual object, Intuition-based
160, 166, 181 decision-making, 12
F L
Fairness metrics, 135, 172 Linear mathematical models, 90
Feedback through human Linear models, 86, 90
intervention, 136–138 Linear programming, 76
192
INDEX
193
INDEX
S U
Satisfactory model Unsupervised learning, 79
performance, 158 User-friendly interfaces, 112, 116, 117
Single-criterion decision-making User interface, 115
(SCDM), 49 Utilitarianism, 60
Stratified K-fold cross
validation, 106
V
Supervised learning, 79
Virtue ethics, 61
Voting-based decision-making, 66
T
Tactical decision-making, 51 W, X, Y, Z
Threshold-based What-if analysis, 144, 145, 159, 169,
decision-making, 68 171, 174, 180, 185, 188
TotalCharges, 150, 152 Workforce constraints, 87
194