<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Responsible AI</title>
	<atom:link href="https://www.relataly.com/category/data-science/responsible-ai/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.relataly.com/category/data-science/responsible-ai/</link>
	<description>The Business AI Blog</description>
	<lastBuildDate>Mon, 07 Aug 2023 19:02:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://www.relataly.com/wp-content/uploads/2023/04/cropped-AI-cat-Icon-White.png</url>
	<title>Responsible AI</title>
	<link>https://www.relataly.com/category/data-science/responsible-ai/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">175977316</site>	<item>
		<title>Building a Virtual AI Assistant (aka Copilot) for Your Software Application: Harnessing the Power of LLMs like ChatGPT</title>
		<link>https://www.relataly.com/building-a-digital-ai-assistant-for-your-software-application/14056/</link>
					<comments>https://www.relataly.com/building-a-digital-ai-assistant-for-your-software-application/14056/#comments</comments>
		
		<dc:creator><![CDATA[Florian Follonier]]></dc:creator>
		<pubDate>Wed, 05 Jul 2023 12:45:27 +0000</pubDate>
				<category><![CDATA[ChatBots]]></category>
		<category><![CDATA[Finance]]></category>
		<category><![CDATA[Generative AI]]></category>
		<category><![CDATA[Healthcare]]></category>
		<category><![CDATA[Insurance]]></category>
		<category><![CDATA[Language Generation]]></category>
		<category><![CDATA[Logistics]]></category>
		<category><![CDATA[Natural Language Processing]]></category>
		<category><![CDATA[OpenAI]]></category>
		<category><![CDATA[Responsible AI]]></category>
		<category><![CDATA[Retail]]></category>
		<category><![CDATA[Telecommunications]]></category>
		<category><![CDATA[Vector Databases]]></category>
		<category><![CDATA[AI in E-Commerce]]></category>
		<category><![CDATA[AI in Finance]]></category>
		<category><![CDATA[Deep Learning]]></category>
		<category><![CDATA[Intermediate Tutorials]]></category>
		<guid isPermaLink="false">https://www.relataly.com/?p=14056</guid>

					<description><![CDATA[<p>Welcome to the dawn of a new era in digital interaction! With the advent of Generative AI, we&#8217;re witnessing a remarkable revolution that&#8217;s changing the very nature of how we interact with software and digital services. This change is monumental. Leading the charge are the latest generation of AI-powered virtual assistants, aka &#8220;AI copilots&#8221;. Unlike ... <a title="Building a Virtual AI Assistant (aka Copilot) for Your Software Application: Harnessing the Power of LLMs like ChatGPT" class="read-more" href="https://www.relataly.com/building-a-digital-ai-assistant-for-your-software-application/14056/" aria-label="Read more about Building a Virtual AI Assistant (aka Copilot) for Your Software Application: Harnessing the Power of LLMs like ChatGPT">Read more</a></p>
<p>The post <a href="https://www.relataly.com/building-a-digital-ai-assistant-for-your-software-application/14056/">Building a Virtual AI Assistant (aka Copilot) for Your Software Application: Harnessing the Power of LLMs like ChatGPT</a> appeared first on <a href="https://www.relataly.com">relataly.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">Welcome to the dawn of a new era in digital interaction! With the advent of <a href="https://www.relataly.com/openai-gpt-chatgpt-in-a-business-context-whats-the-value-proposition/12282/" target="_blank" rel="noreferrer noopener">Generative AI</a>, we&#8217;re witnessing a remarkable revolution that&#8217;s changing the very nature of how we interact with software and digital services. This change is monumental. Leading the charge are the latest generation of AI-powered virtual assistants, aka &#8220;AI copilots&#8221;. Unlike traditional narrow AI models, these are capable of understanding user needs, intents, and questions expressed in plain, natural language. </p>



<p class="wp-block-paragraph">We are talking about nothing less but the next evolution in software design and user experience that is driven by recent advances in generative AI and Large Language Models (LLMs) like <a href="https://openai.com/" target="_blank" rel="noreferrer noopener">OpenAI&#8217;s ChatGPT</a>, <a href="https://bard.google.com/?hl=en" target="_blank" rel="noreferrer noopener">Google Bard</a>, or <a href="https://www.anthropic.com/index/introducing-claude" target="_blank" rel="noreferrer noopener">Anthrophic&#8217;s Claude</a>. </p>



<p class="wp-block-paragraph">Thanks to LLMs user interactions are no longer bound by the constraints of a traditional user interface with forms and buttons. Whether it&#8217;s creating a proposal in Word, editing an image, or opening a claim in an insurance app, users can express their needs in natural language &#8211; a profound change in our interactions with software and services. </p>



<p class="wp-block-paragraph">Despite the hype about these new virtual ai assistants, our understanding of how to build an LLM-powered virtual assistant remains scant. So, if you wonder how to take advantage of LLMs and build a virtual assistant for your app, this article is for you. This post will probe into the overarching components needed to create a virtual AI assistant. We will look at the architecture and its components including LLMs, Knowledge store, Cache, Conversational Logic, and APIs.</p>



<p class="wp-block-paragraph"><strong>Also: </strong></p>



<ul class="wp-block-list">
<li><a href="https://www.relataly.com/business-use-cases-for-openai-gpt-models-chatgpt-davinci/12200/" target="_blank" rel="noreferrer noopener">9 Business Use Cases of OpenAI’s ChatGPT</a></li>



<li><a href="https://www.relataly.com/eliminating-friction-how-openais-gpt-streamlines-online-experiences-and-reduces-the-need-for-google-searches/13171/" target="_blank" rel="noreferrer noopener">Using LLMs (OpenAI’s ChatGPT) to Streamline Digital Experiences</a></li>



<li><a href="https://www.relataly.com/mastering-prompt-engineering-for-chatgpt-a-practical-guide-for-businesses/13134/" target="_blank" rel="noreferrer noopener">ChatGPT Prompt Engineering Guide: Practical Advice for Business Use Cases</a></li>
</ul>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="1016" height="924" data-attachment-id="13898" data-permalink="https://www.relataly.com/?attachment_id=13898#main" data-orig-file="https://www.relataly.com/wp-content/uploads/2023/07/Flo7up_several_pilots_standing_in_front_of_an_airplane_colorful_b9c1a19e-5c8b-497a-b3d5-c3eddc25f4e2-min.png" data-orig-size="1016,924" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Flo7up_several_pilots_standing_in_front_of_an_airplane_colorful_b9c1a19e-5c8b-497a-b3d5-c3eddc25f4e2-min" data-image-description="" data-image-caption="" data-large-file="https://www.relataly.com/wp-content/uploads/2023/07/Flo7up_several_pilots_standing_in_front_of_an_airplane_colorful_b9c1a19e-5c8b-497a-b3d5-c3eddc25f4e2-min.png" src="https://www.relataly.com/wp-content/uploads/2023/07/Flo7up_several_pilots_standing_in_front_of_an_airplane_colorful_b9c1a19e-5c8b-497a-b3d5-c3eddc25f4e2-min.png" alt="Image of human pilots standing in front of an airplane, symbolizing the role of AI Copilots in shaping our interaction with software and its design." class="wp-image-13898" srcset="https://www.relataly.com/wp-content/uploads/2023/07/Flo7up_several_pilots_standing_in_front_of_an_airplane_colorful_b9c1a19e-5c8b-497a-b3d5-c3eddc25f4e2-min.png 1016w, https://www.relataly.com/wp-content/uploads/2023/07/Flo7up_several_pilots_standing_in_front_of_an_airplane_colorful_b9c1a19e-5c8b-497a-b3d5-c3eddc25f4e2-min.png 300w, https://www.relataly.com/wp-content/uploads/2023/07/Flo7up_several_pilots_standing_in_front_of_an_airplane_colorful_b9c1a19e-5c8b-497a-b3d5-c3eddc25f4e2-min.png 512w, https://www.relataly.com/wp-content/uploads/2023/07/Flo7up_several_pilots_standing_in_front_of_an_airplane_colorful_b9c1a19e-5c8b-497a-b3d5-c3eddc25f4e2-min.png 768w" sizes="(max-width: 1016px) 100vw, 1016px" /><figcaption class="wp-element-caption">The new generation of virtual ai assistants inspires a profound change in the way we interact with software and digital services.</figcaption></figure>
</div>
</div>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<h2 class="wp-block-heading">Virtual AI Assistants at the Example of Microsoft M365 Copilot</h2>



<p class="wp-block-paragraph">Advances in virtual AI assistants are closely linked to ChatGPT and other LLMs from US-based startup OpenAI. Microsoft has forged a partnership with OpenAI to bring the latest advances in AI to their products and services. Microsoft has announced these &#8220;Copilots&#8221; across major applications, including M365 and the Power Platform. </p>



<p class="wp-block-paragraph">Here are some capabilities of these Copilots within M365:</p>



<ul class="wp-block-list">
<li>In <strong>PowerPoint</strong>, Copilot allows users to create presentations based on a given context, such as a Word document, for example by stating &#8220;<em>Create a 10-slide product presentation based on the following product documentation.</em>&#8220;</li>



<li>In <strong>Word</strong>, Copilot can adjust the tone of writing a text or transform a few keywords into a complete paragraph. Simply type something like &#8220;<em>Create a proposal for a 3-month contract for customer XYZ based on doc ADF</em>.&#8221;</li>



<li>In <strong>Excel</strong>, Copilot helps users with analyzing datasets, as well as with creating or modifying them. For example, it can summarize a dataset in natural langue and describe trends. </li>



<li>Let&#8217;s not forget <strong>Outlook</strong>! Your new AI Copilot helps you organize your emails and calendar. It assists you in crafting email responses, scheduling meetings, and even provides summaries of key points from the ones you missed.</li>
</ul>



<p class="wp-block-paragraph">If you want to learn more about Copilot in M365, this youtube video provides an excellent overview. However, these are merely a handful of examples: <a href="https://www.youtube.com/watch?v=VlM9a469LE0" target="_blank" rel="noreferrer noopener">Microsoft 365 Copilot Explained: How Microsoft Just Changed the Future of Work</a>. The potential of AI copilots extends far beyond the scope of Office applications and can elevate any software or service to a new level. No wonder, large software companies like <a href="https://www.reuters.com/technology/sap-ceo-huge-growth-potential-generative-ai-2023-06-28/" target="_blank" rel="noreferrer noopener">SAP</a>, and Adobe, have announced plans to upgrade their products with copilot features.</p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<figure class="wp-block-image size-full"><img decoding="async" width="982" height="848" data-attachment-id="13892" data-permalink="https://www.relataly.com/?attachment_id=13892#main" data-orig-file="https://www.relataly.com/wp-content/uploads/2023/06/image-7.png" data-orig-size="982,848" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="image-7" data-image-description="" data-image-caption="" data-large-file="https://www.relataly.com/wp-content/uploads/2023/06/image-7.png" src="https://www.relataly.com/wp-content/uploads/2023/06/image-7.png" alt="Microsoft has announced a whole series of copilots for its products, ranging from digital assistants in M365 office apps to its Azure cloud platform." class="wp-image-13892" srcset="https://www.relataly.com/wp-content/uploads/2023/06/image-7.png 982w, https://www.relataly.com/wp-content/uploads/2023/06/image-7.png 300w, https://www.relataly.com/wp-content/uploads/2023/06/image-7.png 512w, https://www.relataly.com/wp-content/uploads/2023/06/image-7.png 768w" sizes="(max-width: 982px) 100vw, 982px" /><figcaption class="wp-element-caption">Microsoft has <a href="https://blogs.microsoft.com/blog/2023/03/16/introducing-microsoft-365-copilot-your-copilot-for-work/" target="_blank" rel="noreferrer noopener">announced a whole fleet of virtual AI assistants</a> for its products. These range from copilots in M365 office apps to services of its Azure cloud platform.</figcaption></figure>
</div>
</div>



<h2 class="wp-block-heading" id="h-how-llms-enable-a-new-generation-of-virtual-ai-assistants">How LLMs Enable a New Generation of Virtual AI Assistants</h2>



<p class="wp-block-paragraph">Virtual AI assistants are nothing but new. Indeed, their roots can be traced back to innovative ventures such as the paperclip assistant, <a href="https://en.wikipedia.org/wiki/Office_Assistant" target="_blank" rel="noreferrer noopener">Clippy, from Microsoft Word</a> &#8211; a pioneering attempt at enhancing user experience. Later on, this was followed by the introduction of conventional chatbots.</p>



<p class="wp-block-paragraph">Nonetheless, these early iterations had their shortcomings. Their limited capacity to comprehend and assist users with tasks outside of their defined parameters hampered their success on a larger scale. The inability to adapt to a wider range of user queries and requests kept these virtual ai assistants confined within their initial scope, restricting their growth and wider acceptance. So if we talk about this next generation of virtual ai assistants, what has truly revolutionized the scene? In essence, the true innovation lies in the emergence of LLMs such as OpenAI&#8217;s GPT4.</p>



<h3 class="wp-block-heading">LLMs &#8211; A Game Changer for Conversational User Interface Design</h3>



<p class="wp-block-paragraph">Over time, advancements in machine learning, natural language processing, and vast data analytics transformed the capabilities of AI assistants. Modern AI models, like GPT-4, can understand context, engage in more human-like conversations, and offer solutions to a broad spectrum of queries. Furthermore, the integration of AI assistants into various devices and platforms, along with the increase in cloud computing, expanded their reach and functionality. These technological shifts have reshaped the scene, making AI assistants more adaptable, versatile, and user-friendly than ever before.</p>



<p class="wp-block-paragraph">Take, for example, an AI model like GPT. A user might instruct, &#8220;Could you draft an email to John about the meeting tomorrow?&#8221; Not only would the AI grasp the essence of this instruction, but it could also produce a draft email seamlessly.</p>



<p class="wp-block-paragraph">Yet, it&#8217;s not solely their adeptness at discerning user intent that sets LLMs apart. They also exhibit unparalleled proficiency in generating programmatic code to interface with various software functions. Imagine directing your software with, &#8220;Generate a pie chart that visualizes this year&#8217;s sales data by region,&#8221; and witnessing the software promptly fulfilling your command.</p>



<h3 class="wp-block-heading">A Revolution in Software Design and User Experience</h3>



<p class="wp-block-paragraph">The advanced language understanding offered by LLMs unburdens developers from the painstaking task of constructing every possible dialog or function an assistant might perform. Rather, developers can harness the generative capabilities of LLMs and integrate them with their application&#8217;s API. This integration facilitates a myriad of user options without the necessity of explicitly designing them.</p>



<p class="wp-block-paragraph">The outcome of this is far-reaching, extending beyond the immediate relief for developers. It sets the stage for a massive transformation in the software industry and the broader job market, affecting how developers are trained and what skills are prioritized. Furthermore, it alters our everyday interaction with technology, making it more intuitive and efficient. </p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<h2 class="wp-block-heading">Components of a Modern Virtual AI Assistant áka AI Copilot</h2>



<p class="wp-block-paragraph">By now you should have some idea of what modern virtual AI assistants are. Next, let&#8217;s look at the technical components that need to come together. </p>



<p class="wp-block-paragraph">The illustration below displays the main components of an LLM-powered virtual AI assistant:</p>



<ul class="wp-block-list">
<li>A &#8211; Conversational UI for providing the user with a chat experience</li>



<li>B &#8211; LLMs such as GPT-3.5 or GPT-4 </li>



<li>C &#8211; Knowledge store for grounding your bot in enterprise data and dynamically providing few-shot examples. </li>



<li>D &#8211; Conversation logic for intent recognition and tracking conversations. </li>



<li>E &#8211; Application API as an interface to trigger and perform application functionality. </li>



<li>F &#8211; Cache for maintaining an instant mapping between often encountered user intents and structured LLM responses. </li>
</ul>



<p class="wp-block-paragraph">Let&#8217;s look at these components in more detail.</p>



<figure class="wp-block-image size-full"><img decoding="async" width="3531" height="2753" data-attachment-id="14173" data-permalink="https://www.relataly.com/building-a-digital-ai-assistant-for-your-software-application/14056/virtual-assistant-architecture-components-1/#main" data-orig-file="https://www.relataly.com/wp-content/uploads/2023/08/virtual-assistant-architecture-components-1.png" data-orig-size="3531,2753" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="virtual-assistant-architecture-components-1" data-image-description="" data-image-caption="" data-large-file="https://www.relataly.com/wp-content/uploads/2023/08/virtual-assistant-architecture-components-1.png" src="https://www.relataly.com/wp-content/uploads/2023/08/virtual-assistant-architecture-components-1.png" alt="" class="wp-image-14173" srcset="https://www.relataly.com/wp-content/uploads/2023/08/virtual-assistant-architecture-components-1.png 3531w, https://www.relataly.com/wp-content/uploads/2023/08/virtual-assistant-architecture-components-1.png 300w, https://www.relataly.com/wp-content/uploads/2023/08/virtual-assistant-architecture-components-1.png 512w, https://www.relataly.com/wp-content/uploads/2023/08/virtual-assistant-architecture-components-1.png 768w, https://www.relataly.com/wp-content/uploads/2023/08/virtual-assistant-architecture-components-1.png 1536w, https://www.relataly.com/wp-content/uploads/2023/08/virtual-assistant-architecture-components-1.png 2048w, https://www.relataly.com/wp-content/uploads/2023/08/virtual-assistant-architecture-components-1.png 2475w" sizes="(max-width: 1237px) 100vw, 1237px" /></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%"></div>
</div>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<h3 class="wp-block-heading">A) Conversational Application Frontend</h3>



<p class="wp-block-paragraph">Incorporating virtual AI assistants into a software application or digital service often involves the use of a conversational user interface, typically embodied in a chat window that showcases previous interactions. The seamless integration of this interface as an intrinsic part of the application is vital.</p>



<p class="wp-block-paragraph">A lot of applications employ a standard chatbot methodology, where the virtual AI assistant provides feedback to users in natural language or other forms of content within the chat window. Yet, a more dynamic and efficacious approach is to merge natural language feedback with alterations in the traditional user interface (UI). This dual approach not only enhances user engagement but also improves the overall user experience.</p>



<p class="wp-block-paragraph">Microsoft&#8217;s M365 Copilot is a prime example of this approach. Instead of simply feeding responses back to the user in the chat window, the virtual assistant also manipulates elements in the traditional UI based on user input. It may highlight options, auto-fill data, or direct the user&#8217;s attention to certain parts of the screen. This combination of dynamic UI manipulation and natural language processing creates a more interactive and intuitive user experience, guiding the user toward their goal in a more efficient and engaging way.</p>



<figure class="wp-block-image size-full"><img decoding="async" width="926" height="292" data-attachment-id="13999" data-permalink="https://www.relataly.com/?attachment_id=13999#main" data-orig-file="https://www.relataly.com/wp-content/uploads/2023/07/image-5.png" data-orig-size="926,292" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="image-5" data-image-description="" data-image-caption="" data-large-file="https://www.relataly.com/wp-content/uploads/2023/07/image-5.png" src="https://www.relataly.com/wp-content/uploads/2023/07/image-5.png" alt="Sample Copilot chat window in M365 Office" class="wp-image-13999" srcset="https://www.relataly.com/wp-content/uploads/2023/07/image-5.png 926w, https://www.relataly.com/wp-content/uploads/2023/07/image-5.png 300w, https://www.relataly.com/wp-content/uploads/2023/07/image-5.png 512w, https://www.relataly.com/wp-content/uploads/2023/07/image-5.png 768w" sizes="(max-width: 926px) 100vw, 926px" /><figcaption class="wp-element-caption">M365 Copilot chat window in M365 Office </figcaption></figure>



<p class="wp-block-paragraph">When designing the UI for a virtual AI assistant, there are several key considerations. Firstly, the interface should be intuitive, ensuring users can easily navigate and understand how to interact with the AI. Secondly, the AI should provide feedback in a timely manner, so the user isn&#8217;t left waiting for a response. Thirdly, the system should be designed to handle errors gracefully, providing helpful error messages and suggestions when things don&#8217;t go as planned. Finally, the AI should keep the human in the loop and assist him in using AI in a safe way. </p>



<p class="wp-block-paragraph">Also: <a href="https://www.relataly.com/step-by-step-guide-to-building-your-own-chatgpt-on-a-custom-knowledge-base-in-python-leveraging-mongo-db-and-embeddings/13687/" target="_blank" rel="noreferrer noopener">Building “Chat with your Data” Apps using Embeddings, ChatGPT, and Cosmos DB for Mongo DB vCore</a></p>



<h3 class="wp-block-heading">B) Large Language Model</h3>



<p class="wp-block-paragraph">At the interface between users and assistant sits the large language mode. It translates users&#8217; requests and questions into code, actions, and responses that are shown to the user. Here, we are talking about foundational models like GPT-3.5-Turbo or GPT-4. In addition, if you are working with extensive content, you may use an embedding LLM that converts text or images into mathematical vectors as part of your knowledge store. An example, of such an embedding model, is ada-text-embeddings-002.</p>



<p class="wp-block-paragraph">It&#8217;s important to understand that the user is not directly interacting with the LLM. Instead, you may want to put some control logic between the user and the LLM that steers the conversation. This logic can enrich prompts with additional data from the knowledge store or an online search API such as Google or Bing. This process of injecting data into a prompt depending on the user input is known as <a href="https://arxiv.org/abs/2005.11401" target="_blank" rel="noreferrer noopener">Retrieval Augmented Generation</a>. </p>



<p class="wp-block-paragraph">Typical tasks performed by the LLM: </p>



<ul class="wp-block-list">
<li>Generating natural language responses based on the user’s query and the retrieved data from the knowledge store.</li>



<li>Recognizing and classifying user intent.</li>



<li>Generating code snippets (or API requests) that can be executed by the application or the user to achieve a desired outcome in your application.</li>



<li>Converting content into embeddings to retrieve relevant information from a vector-based knowledge store.</li>



<li>Generating summaries, paraphrases, translations, or explanations of the retrieved data or the generated responses.</li>



<li>Generating suggestions, recommendations, or feedback for the user to improve their experience or achieve their goals.</li>
</ul>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%"></div>
</div>



<h3 class="wp-block-heading">C) Knowledge Store</h3>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">Let&#8217;s dive into the &#8220;Knowledge Store&#8221; and why it&#8217;s vital. You might think feeding a huge prompt explaining app logic to your LLM, like ChatGPT, would work, but that&#8217;s not the case. As of June 2023, LLMs have context limits. For instance, GPT-3 can handle up to 4k tokens, roughly three pages of text. This limitation isn&#8217;t just for input, but output too. Hence, cramming everything into one prompt isn&#8217;t efficient or quick.</p>



<p class="wp-block-paragraph">Instead, pair your LLM with a knowledge store, like a vector database (more on this in our article on <a href="https://www.relataly.com/vector-databases-the-rising-star-in-generative-ai-infrastructure/13599/" target="_blank" rel="noreferrer noopener">Vector Databases</a>). Essentially, this is your system&#8217;s information storage, which efficiently retrieves data. Whichever storage you use, a search algorithm is crucial to fetch items based on user input. For vector databases, the typical way of doing this is by using similarity search.</p>



<p class="wp-block-paragraph"><strong>Token Limitations</strong></p>



<p class="wp-block-paragraph">Curious about GPT models&#8217; token limits? Here&#8217;s a quick breakdown:</p>



<ul class="wp-block-list">
<li><strong>GPT-3.5-Turbo Model (4,000 tokens):</strong> About 7-8 DIN A4 pages</li>



<li><strong>GPT-4 Standard Model (8,000 tokens):</strong> Around 14-16 DIN A4 pages</li>



<li><strong>GPT-3.5-Turbo-16K Model (16,000 tokens):</strong> Approximately 28-32 DIN A4 pages</li>



<li><strong>GPT-4-32K Model (32,000 tokens):</strong> Estimated at 56-64 DIN A4 pages</li>
</ul>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<p class="wp-block-paragraph"></p>
</div>
</div>



<h3 class="wp-block-heading">D) Conversation Control Logic</h3>



<p class="wp-block-paragraph">Finally, the conversation needs a conductor to ensure it stays in harmony and doesn&#8217;t veer off the rails. This is the role of the conversation logic. An integral part of your app&#8217;s core software, the conversation logic bridges all the elements to deliver a seamless user experience. It includes several subcomponents. Meta prompts, for instance, help guide the conversation in the desired direction and provide some boundaries to the activities of the assistant. For example, the meta prompt may include a list of basic categories for intents that help the LLM with understanding what the user wants to do. </p>



<p class="wp-block-paragraph">Another subcomponent is the connection to the knowledge store that allows the assistant to draw from a vast array of data to augment prompts handed over to the large language model. Moreover, the logic incorporates checks on the assistant&#8217;s activities and its generated content. These checks act like safety nets, mitigating risks and preventing unwanted outcomes. It&#8217;s akin to a quality control mechanism, keeping the assistant&#8217;s output in check and safeguarding against responses that might derail the user&#8217;s experience or even break the application.</p>



<h3 class="wp-block-heading">E) Application API</h3>



<p class="wp-block-paragraph">Users expect their commands to initiate actions within your application. To fulfill these expectations, the application needs an API that can interact with various app functions. Consider the API as the nerve center of your app, facilitating access to its features and user journey. This API enables the AI assistant to guide users to specific pages, fill in forms, execute tasks, display information, and more. Tools like Microsoft Office even have their own language for this, while Python code, SQL statements, or generic REST requests usually suffice for most applications. </p>



<p class="wp-block-paragraph">Applications based on a microservice architecture have an edge in this regard, as APIs are inherent to their design. If your application misses some APIs, remember, there&#8217;s no rush to provide access to all functions from the outset. You can start by supporting basic functionalities via chat and gradually expand over time. This allows you to learn from user interactions, continuously refine your offering, and ensure your AI assistant remains a useful and efficient tool for your users.</p>



<p class="wp-block-paragraph">So, now that we&#8217;ve laid down the foundation, let&#8217;s buckle up and take a journey through the workflow of a modern virtual assistant. Trust me, it&#8217;s a fascinating trip ahead!</p>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<h3 class="wp-block-heading">F) Cache</h3>



<p class="wp-block-paragraph">Implementing a cache into your virtual AI assistant can significantly boost performance and decrease response times. Particularly useful for frequently recurring user intents, caching stores the outcomes of these intents for quicker access in future instances. However, a well-designed cache shouldn&#8217;t directly store specific inputs as there is too much variety in the human language. Instead, caching could be woven into the application&#8217;s logic in the mid-layers of your OpenAI prompt flow. </p>



<p class="wp-block-paragraph">This strategy ensures frequently repeated intents are handled more swiftly, enhancing user experience. It&#8217;s critical to remember that cache integration is application-specific, and thoughtful design is vital to avoid unintentionally inducing inefficiencies.</p>



<p class="wp-block-paragraph">While a well-implemented cache can speed up responses, it also introduces additional complexity. Effective cache management is crucial for avoiding resource drains, requiring strategies for data storage duration, updates, and purging.</p>



<p class="wp-block-paragraph">The exact impact and efficiency of this caching strategy will depend on your application specifics, including the distribution and repetition of user intents. In the upcoming articles, we&#8217;ll explore this topic further, discussing efficient cache integration in AI assistant systems.</p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<figure class="wp-block-image size-full"><img decoding="async" width="467" height="156" data-attachment-id="14076" data-permalink="https://www.relataly.com/building-a-digital-ai-assistant-for-your-software-application/14056/image-11-14/#main" data-orig-file="https://www.relataly.com/wp-content/uploads/2023/07/image-11.png" data-orig-size="467,156" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="image-11" data-image-description="" data-image-caption="" data-large-file="https://www.relataly.com/wp-content/uploads/2023/07/image-11.png" src="https://www.relataly.com/wp-content/uploads/2023/07/image-11.png" alt="" class="wp-image-14076" srcset="https://www.relataly.com/wp-content/uploads/2023/07/image-11.png 467w, https://www.relataly.com/wp-content/uploads/2023/07/image-11.png 300w" sizes="(max-width: 467px) 100vw, 467px" /><figcaption class="wp-element-caption">An example of a caching technology would be <a href="https://redis.com/docs/caching-at-scale-with-redis/?utm_source=google&amp;utm_medium=cpc&amp;utm_term=cache&amp;utm_campaign=why_re-land_caching-cacheonly-emea-20125229738&amp;utm_content=why_re-eb-caching_at_scale_with_redis&amp;gclid=CjwKCAjwqZSlBhBwEiwAfoZUIIR30kfBaYLKfRO1ab0cxKcUB2og6UbR22oyogPcrj087B0CSp3TZRoC11gQAvD_BwE" target="_blank" rel="noreferrer noopener">Redis</a>.</figcaption></figure>
</div>
</div>



<h2 class="wp-block-heading">Considerations on the Architecture of Virtual AI Assistants</h2>



<p class="wp-block-paragraph">Designing an virtual AI assistant is an intricate process that blends cutting-edge technology with a keen understanding of user behavior. It&#8217;s about creating an efficient tool that not only simplifies tasks and optimizes workflows but also respects and preserves user autonomy. This section of our article will delve into the key considerations that guide the architecture of a virtual AI assistant. We&#8217;ll discuss the importance of user control, the strategic selection and use of GPT models, the benefits of starting simple, and the potential expansion as you gain confidence in your system&#8217;s stability and efficiency. As we journey through these considerations, remember the ultimate goal: creating a virtual AI assistant that augments user capabilities, enhances user experience, and breathes new life into software applications.</p>



<h3 class="wp-block-heading">Keep the User in Control</h3>



<p class="wp-block-paragraph">At the heart of any virtual AI assistant should be the principle of user control. While automation can optimize tasks and streamline workflows, it is crucial to remember that your assistant is there to assist, not usurp. Balancing AI automation with user control is essential to crafting a successful user experience.</p>



<p class="wp-block-paragraph">Take, for instance, the scenario of a user wanting to open a support ticket within your application. In this situation, your assistant could guide the user to the correct page, auto-fill known details like the user&#8217;s name and contact information, and even suggest possible problem categories based on the user&#8217;s descriptions. By doing so, the virtual AI assistant has significantly simplified the process for the user, making it quicker and less burdensome.</p>



<p class="wp-block-paragraph">However, the user retains control throughout the process, making the final decisions. They can edit the pre-filled details, choose the problem category, and write the issue description in their own words. They&#8217;re in command, and the virtual AI assistant is there to assist, helping to avoid errors, speed up the process, and generally make the experience smoother and more efficient.</p>



<p class="wp-block-paragraph">This balance between user control and AI assistance is not only about maintaining a sense of user agency; it is also about trust. Users need to trust that the AI is there to help them, not to take control away from them. If the AI seems too controlling or makes decisions that the user disagrees with, this can erode trust and hinder user acceptance.</p>



<h3 class="wp-block-heading">Mix and Match Models</h3>



<p class="wp-block-paragraph">Another crucial consideration is the use of different GPT models. Each model comes with its own set of strengths, weaknesses, response times, costs, and token limits. It&#8217;s not just about capabilities. Sometimes, it&#8217;s unnecessary to deploy a complex GPT-4 model for simpler tasks in your workflow. Alternatives like ADA or GPT 3.5 Turbo might be more suitable and cost-effective for functions like intent recognition.</p>



<p class="wp-block-paragraph">Reserve the heavy-duty models for tasks requiring an extended token limit or dealing with complex operations. One such task is the final-augmented prompt that creates the API call. If you&#8217;re working with a vector database, you&#8217;ll also need an embedding model. Be mindful that these models come with different vector sizes, and once you start building your database with a specific size, it can be challenging to switch without migrating your entire vector content.</p>



<h3 class="wp-block-heading">Think Big but Start Simple </h3>



<p class="wp-block-paragraph">It&#8217;s always a good idea to start simple &#8211; maybe with a few intents to kick things off. As you gain experience and confidence in building virtual assistant apps, you can gradually integrate additional intents and API calls. And don&#8217;t forget to keep your users involved! Consider incorporating a feedback mechanism, allowing users to report any issues and suggest improvements. This will enable you to fine-tune your prompts and database content effectively.</p>



<p class="wp-block-paragraph">As your application becomes more comprehensive, you might want to explore model fine-tuning for specific tasks. However, this step should be considered only when your virtual AI assistant functionality has achieved a certain level of stability. Fine-tuning a model can be quite costly, especially if you decide to change the intent categories after training.</p>



<h2 class="wp-block-heading">Digital LLM-based Assistants &#8211; A Major Business Opportunity</h2>



<p class="wp-block-paragraph">From a business standpoint, upgrading software products and services with LLM-powered virtual AI assistants presents a significant opportunity to differentiate in the market and even innovate their business model. Many organizations are already contemplating the inclusion of virtual assistants as part of subscription packages or premium offerings. As the market evolves, software lacking a natural language interface may be perceived as outdated and struggle to compete.</p>



<p class="wp-block-paragraph">AI-powered virtual assistants are likely to inspire a whole new generation of software applications and enable a new wave of digital innovations. By enhancing convenience and efficiency in user inputs, virtual assistants unlock untapped potential and boost productivity. Moreover, they empower users to fully leverage the diverse range of features offered by software applications, which often remain underutilized.</p>



<p class="wp-block-paragraph">I strongly believe that LLM-driven virtual AI assistants are the next milestone in software design and will revolutionize software applications across industries. And remember, this is just the first generation of virtual assistants. The future possibilities are virtually endless and we can&#8217;t wait to see what&#8217;s next! Indeed, the emergence of natural language interfaces is expected to trigger a ripple effect of subsequent innovations, for example, in areas such as standardization, workflow automation, and user experience design.</p>



<h2 class="wp-block-heading">Summary</h2>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">In this article, we delved into the fascinating world of virtual AI assistants, powered by LLMs. We started by exploring how the advanced language understanding of LLMs is revolutionizing software design, easing the workload of developers, and reshaping user experiences with technology.</p>



<p class="wp-block-paragraph">Next, we provided an overview of the key architectural components of a modern virtual AI assistant: the <strong>Conversational Application Frontend</strong>, <strong>Large Language Model</strong>, <strong>Knowledge Store</strong>, and <strong>Conversation Control Logic</strong>. We also introduced the concept of an <strong>Application API </strong>and the novel idea of a <strong>Cache </strong>for storing and quickly retrieving common user intents. Each component was discussed in the context of their roles and how they work together to create a seamless, interactive, and efficient user experience.</p>



<p class="wp-block-paragraph">We then discussed architecture considerations, emphasizing the necessity of maintaining user control while leveraging the power of AI automation. We talked about the judicious use of different GPT models based on task requirements, the advantages of starting with simple implementations and progressively scaling up, and the benefits of user feedback in continuously refining the system.</p>



<p class="wp-block-paragraph">This journey of &#8216;AI in Software Applications&#8217;, from concept to reality, isn&#8217;t just about innovation. It&#8217;s about unlocking &#8216;Innovative Business Models with AI&#8217; and boosting user engagement and productivity. As we continue to ride the wave of &#8216;Natural Language Processing for Software Automation&#8217;, the opportunities for harnessing the power of virtual AI assistants are endless. Stay tuned as we explore the workflows further in the next article.</p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<figure class="wp-block-image size-large"><img decoding="async" width="512" height="289" data-attachment-id="14071" data-permalink="https://www.relataly.com/building-a-digital-ai-assistant-for-your-software-application/14056/flo7up_a_mechanic_looking_at_the_engine_of_an_airplane_colorful_fd860957-d8af-48f4-a207-deb0ea13230d-min-1/#main" data-orig-file="https://www.relataly.com/wp-content/uploads/2023/07/Flo7up_a_mechanic_looking_at_the_engine_of_an_airplane_colorful_fd860957-d8af-48f4-a207-deb0ea13230d-min-1.png" data-orig-size="1426,806" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="Flo7up_a_mechanic_looking_at_the_engine_of_an_airplane_colorful_fd860957-d8af-48f4-a207-deb0ea13230d-min-1" data-image-description="" data-image-caption="" data-large-file="https://www.relataly.com/wp-content/uploads/2023/07/Flo7up_a_mechanic_looking_at_the_engine_of_an_airplane_colorful_fd860957-d8af-48f4-a207-deb0ea13230d-min-1.png" src="https://www.relataly.com/wp-content/uploads/2023/07/Flo7up_a_mechanic_looking_at_the_engine_of_an_airplane_colorful_fd860957-d8af-48f4-a207-deb0ea13230d-min-1-512x289.png" alt="A mechanic working on an airplace engine" class="wp-image-14071" srcset="https://www.relataly.com/wp-content/uploads/2023/07/Flo7up_a_mechanic_looking_at_the_engine_of_an_airplane_colorful_fd860957-d8af-48f4-a207-deb0ea13230d-min-1.png 512w, https://www.relataly.com/wp-content/uploads/2023/07/Flo7up_a_mechanic_looking_at_the_engine_of_an_airplane_colorful_fd860957-d8af-48f4-a207-deb0ea13230d-min-1.png 300w, https://www.relataly.com/wp-content/uploads/2023/07/Flo7up_a_mechanic_looking_at_the_engine_of_an_airplane_colorful_fd860957-d8af-48f4-a207-deb0ea13230d-min-1.png 768w, https://www.relataly.com/wp-content/uploads/2023/07/Flo7up_a_mechanic_looking_at_the_engine_of_an_airplane_colorful_fd860957-d8af-48f4-a207-deb0ea13230d-min-1.png 1426w" sizes="(max-width: 512px) 100vw, 512px" /><figcaption class="wp-element-caption">In this article, we have gone through the components of an LLM-powered virtual assistant aka &#8220;AI copilot&#8221;. In the next article, we will dive deeper into the processing logic and follow a prompt into the engine of an intelligent assistant. </figcaption></figure>
</div>
</div>



<h2 class="wp-block-heading">Sources and Further Reading</h2>



<ul class="wp-block-list">
<li><a href="https://arxiv.org/pdf/2306.03460.pdf" target="_blank" rel="noreferrer noopener">Natural Language Commanding via Program Synthesis</a></li>



<li><a href="https://en.wikipedia.org/wiki/Office_assistant" target="_blank" rel="noreferrer noopener">Wikipedia.org/Office Assistant</a></li>



<li><a href="https://blogs.microsoft.com/blog/2023/03/16/introducing-microsoft-365-copilot-your-copilot-for-work/" target="_blank" rel="noreferrer noopener">Microsoft Blogs &#8211; Introducing Microsoft 365 Copilot</a></li>



<li><a href="https://www.reuters.com/technology/sap-ceo-huge-growth-potential-generative-ai-2023-06-28/" target="_blank" rel="noreferrer noopener">Reuters &#8211; Sap CEO Huge Growth Potential in Generative AI</a></li>



<li><a href="https://news.microsoft.com/source/features/ai/microsoft-outlines-framework-for-building-ai-apps-and-copilots-expands-ai-plugin-ecosystem/" target="_blank" rel="noreferrer noopener">Microsoft Outlines Framework for Building AI Apps and Copilots, Expands AI Plugin Ecosystem</a></li>



<li><a href="https://workspace.google.com/blog/product-announcements/generative-ai?hl=en" target="_blank" rel="noreferrer noopener">Google Announces Digital Assistants in their Worksuite</a></li>



<li><a href="https://www.youtube.com/watch?v=B2-8wrF9Okc" target="_blank" rel="noreferrer noopener">Youtube, Microsoft Mechanics &#8211; How Microsoft 365 Copilot works</a></li>



<li><a href="https://www.youtube.com/watch?v=VlM9a469LE0" target="_blank" rel="noreferrer noopener">Youtube, Lisa Crosby &#8211; Microsoft 365 Copilot Explained: How Microsoft Just Changed the Future of Work</a></li>
</ul>
<p>The post <a href="https://www.relataly.com/building-a-digital-ai-assistant-for-your-software-application/14056/">Building a Virtual AI Assistant (aka Copilot) for Your Software Application: Harnessing the Power of LLMs like ChatGPT</a> appeared first on <a href="https://www.relataly.com">relataly.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.relataly.com/building-a-digital-ai-assistant-for-your-software-application/14056/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">14056</post-id>	</item>
		<item>
		<title>Using Fairlearn to Build Fair Machine Machine Learning Models with Python: Step-by-Step Towards More Responsible AI</title>
		<link>https://www.relataly.com/building-fair-machine-machine-learning-models-with-fairlearn/12804/</link>
					<comments>https://www.relataly.com/building-fair-machine-machine-learning-models-with-fairlearn/12804/#comments</comments>
		
		<dc:creator><![CDATA[Florian Follonier]]></dc:creator>
		<pubDate>Thu, 09 Mar 2023 23:45:16 +0000</pubDate>
				<category><![CDATA[Data Science]]></category>
		<category><![CDATA[Decision Trees]]></category>
		<category><![CDATA[Fairlearn]]></category>
		<category><![CDATA[Hyperparameter Tuning]]></category>
		<category><![CDATA[Responsible AI]]></category>
		<category><![CDATA[Grid Search]]></category>
		<guid isPermaLink="false">https://www.relataly.com/?p=12804</guid>

					<description><![CDATA[<p>As we enter an era where intelligent systems are increasingly relied upon to make key decisions, responsible AI has become more critical than ever before. It&#8217;s not enough to simply rely on data-driven decision-making; we must also ensure that these systems are fair and just. But how can we do this when the same bias ... <a title="Using Fairlearn to Build Fair Machine Machine Learning Models with Python: Step-by-Step Towards More Responsible AI" class="read-more" href="https://www.relataly.com/building-fair-machine-machine-learning-models-with-fairlearn/12804/" aria-label="Read more about Using Fairlearn to Build Fair Machine Machine Learning Models with Python: Step-by-Step Towards More Responsible AI">Read more</a></p>
<p>The post <a href="https://www.relataly.com/building-fair-machine-machine-learning-models-with-fairlearn/12804/">Using Fairlearn to Build Fair Machine Machine Learning Models with Python: Step-by-Step Towards More Responsible AI</a> appeared first on <a href="https://www.relataly.com">relataly.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">As we enter an era where intelligent systems are increasingly relied upon to make key decisions, responsible AI has become more critical than ever before. It&#8217;s not enough to simply rely on data-driven decision-making; we must also ensure that these systems are fair and just. But how can we do this when the same bias and unfairness that exists in our society is reflected in these very algorithms? </p>



<p class="wp-block-paragraph">The consequences of biased algorithms are far-reaching and can be devastating. They can perpetuate discriminatory practices, deny individuals opportunities or services, and lead to a range of negative outcomes. It&#8217;s no longer just a moral obligation to avoid perpetuating inequalities; it&#8217;s a necessity to prevent negative consequences such as reputational damage and legal repercussions.</p>



<p class="wp-block-paragraph">This article aims to drive home the importance of fairness in AI and provide practical tips for ensuring that algorithms are unbiased and free from discrimination. We will delve into the fairlearn library, a powerful open-source toolkit, to assess and mitigate bias in machine learning. Using fairlearn, we will implement a classification model in Python to predict income on the adult consensus set and evaluate its fairness.</p>



<p class="wp-block-paragraph">Think about it: just as we strive to ensure fairness in our daily lives, we must also do the same with AI. We must do our best to eliminate bias and discrimination from our algorithms, just as we work to eliminate these issues from our society. By using fairlearn, we can ensure that our models are as fair and unbiased as possible, minimizing the risk of perpetuating discrimination and inequality. We can take steps to ensure that our algorithms are not influenced by factors such as race, gender, or age, and that they are making predictions based on merit alone.</p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<div class="wp-block-kadence-infobox kt-info-box_d5a753-ee"><span class="kt-blocks-info-box-link-wrap info-box-link kt-blocks-info-box-media-align-top kt-info-halign-left"><div class="kt-blocks-info-box-media-container"><div class="kt-blocks-info-box-media kt-info-media-animate-none"><div class="kadence-info-box-icon-container kt-info-icon-animate-none"><div class="kadence-info-box-icon-inner-container"><span class="kb-svg-icon-wrap kb-svg-icon-fe_alertCircle kt-info-svg-icon"><svg viewBox="0 0 24 24"  fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"  aria-hidden="true"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12" y2="16"/></svg></span></div></div></div></div><div class="kt-infobox-textcontent"><h5 class="kt-blocks-info-box-title">What is Responsible AI?</h5><p class="kt-blocks-info-box-text">Responsible AI is an approach that emphasizes fairness, transparency, accountability, and ethical considerations in the development and deployment of AI systems. It involves identifying potential sources of bias in AI and taking steps to address them proactively. To ensure responsible AI, organizations must develop policies and processes that prioritize fairness, transparency, and accountability throughout the AI development lifecycle. </p></div></span></div>
</div>
</div>



<h2 class="wp-block-heading">How Real-World Bias Manifests in Biased Data</h2>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">As we continue to develop increasingly sophisticated AI models like GPT-4, it is crucial to acknowledge that real-world data is not always objective and unbiased. Training models on biased data can lead to the perpetuation and even amplification of existing biases and disparities. Failing to address these issues can cement and exacerbate existing inequalities, with far-reaching consequences for society and individuals alike.</p>



<p class="wp-block-paragraph">Bias in AI models often stems from the data they are trained on. Historical data, social norms, and cultural practices can all introduce bias into datasets, which AI models may then unwittingly learn and propagate. This can lead to AI systems making biased decisions, producing biased content, or perpetuating stereotypes and prejudices.</p>



<h3 class="wp-block-heading">Ways in which AI systems can be biased</h3>



<p class="wp-block-paragraph">There are many ways in which AI systems can be biased and thus behave unfairly, including the following:</p>



<ul class="wp-block-list">
<li><strong>Gender Bias in Hiring</strong>: The data used by companies to train their hiring algorithms may be biased against certain genders or demographics. As a result, these algorithms may perpetuate existing gender inequalities by disproportionately rejecting female candidates.</li>



<li><strong>Racial Bias in Healthcare</strong>: Medical data may be biased against certain racial or ethnic groups, which can lead to misdiagnosis, mistreatment, or under-treatment of certain populations. For instance, studies have shown that Black patients are less likely to receive appropriate pain management than white patients.</li>



<li><strong>Economic Bias in Credit Scoring</strong>: Financial data used to determine credit scores may be biased against low-income individuals or marginalized communities, making it harder for them to access credit or loans. The result is a cycle of poverty, where individuals cannot access credit and are thus unable to build wealth.</li>



<li><strong>Age Bias in <a href="https://www.relataly.com/predicting-crimes-in-san-francisco-creatingsf-crime-map-using-xgboost/2960/" target="_blank" rel="noreferrer noopener">Predictive Policing</a></strong>: Predictive policing algorithms may be biased against certain age groups, such as younger people, who may be more likely to be falsely flagged as potential criminals. This can lead to increased surveillance and potential harassment of certain populations.</li>
</ul>



<p class="wp-block-paragraph">These examples highlight the importance of identifying and addressing bias in real-world data. By doing so, we can ensure that our models and algorithms are fair, just, and equitable for all individuals, regardless of their background or demographic.</p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<figure class="wp-block-image size-large"><img decoding="async" width="512" height="512" data-attachment-id="12913" data-permalink="https://www.relataly.com/women-in-construction-fairness-machine-learning-relataly-midjourney-ai-min/" data-orig-file="https://www.relataly.com/wp-content/uploads/2023/03/women-in-construction-fairness-machine-learning-relataly-midjourney-ai-min.png" data-orig-size="1024,1024" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="women in construction fairness machine learning relataly midjourney ai-min" data-image-description="" data-image-caption="" data-large-file="https://www.relataly.com/wp-content/uploads/2023/03/women-in-construction-fairness-machine-learning-relataly-midjourney-ai-min.png" src="https://www.relataly.com/wp-content/uploads/2023/03/women-in-construction-fairness-machine-learning-relataly-midjourney-ai-min-512x512.png" alt="" class="wp-image-12913" srcset="https://www.relataly.com/wp-content/uploads/2023/03/women-in-construction-fairness-machine-learning-relataly-midjourney-ai-min.png 512w, https://www.relataly.com/wp-content/uploads/2023/03/women-in-construction-fairness-machine-learning-relataly-midjourney-ai-min.png 300w, https://www.relataly.com/wp-content/uploads/2023/03/women-in-construction-fairness-machine-learning-relataly-midjourney-ai-min.png 140w, https://www.relataly.com/wp-content/uploads/2023/03/women-in-construction-fairness-machine-learning-relataly-midjourney-ai-min.png 768w, https://www.relataly.com/wp-content/uploads/2023/03/women-in-construction-fairness-machine-learning-relataly-midjourney-ai-min.png 1024w" sizes="(max-width: 512px) 100vw, 512px" /><figcaption class="wp-element-caption">One of many biases is that in many industries, Women still earn less than their male colleagues. Image created with Midjourney. </figcaption></figure>
</div>
</div>



<h3 class="wp-block-heading">Model Fairness and Performance</h3>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">In machine learning models, there is often a delicate balance between fairness and performance. For instance, optimizing a model for high accuracy might inadvertently lead to discrimination against certain groups of people. To avoid these adverse effects, we must actively work to reduce the influence of unfairness and bias in our models.</p>



<p class="wp-block-paragraph">Achieving this balance involves multiple strategies, such as gathering diverse and representative data, identifying and addressing sources of bias within the data, and devising techniques to counteract the effects of bias. Moreover, it&#8217;s essential to consistently monitor and evaluate our models to ensure they maintain fairness and impartiality over time.</p>



<p class="wp-block-paragraph">Conversely, when prioritizing fairness, some degree of accuracy may be sacrificed. Striking the right balance between fairness and performance depends on the specific use case and consideration of the potential consequences of any decisions made. The ultimate goal is to create a model that is both fair and effective in performing the task it was designed for.</p>



<p class="wp-block-paragraph">In summary, to create a well-balanced machine learning model, it&#8217;s crucial to acknowledge the trade-off between fairness and performance. By employing various strategies, such as using diverse data, addressing bias, and continuously monitoring the models, we can work towards developing models that are not only accurate but also fair and equitable for all users.</p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<figure class="wp-block-image size-large"><img decoding="async" width="512" height="512" data-attachment-id="12847" data-permalink="https://www.relataly.com/building-fair-machine-machine-learning-models-with-fairlearn/12804/lgbt-fairness-in-machine-learning-relataly-ai-python-midjourney-min/#main" data-orig-file="https://www.relataly.com/wp-content/uploads/2023/03/LGBT-fairness-in-machine-learning-relataly-ai-python-midjourney-min.png" data-orig-size="1024,1024" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="LGBT-fairness-in-machine-learning-relataly-ai-python-midjourney-min" data-image-description="" data-image-caption="" data-large-file="https://www.relataly.com/wp-content/uploads/2023/03/LGBT-fairness-in-machine-learning-relataly-ai-python-midjourney-min.png" src="https://www.relataly.com/wp-content/uploads/2023/03/LGBT-fairness-in-machine-learning-relataly-ai-python-midjourney-min-512x512.png" alt="Organizations must take the necessary steps to ensure their algorithms are unbiased and not perpetuate the same inequalities plaguing our society. Image created with Midjourney." class="wp-image-12847" srcset="https://www.relataly.com/wp-content/uploads/2023/03/LGBT-fairness-in-machine-learning-relataly-ai-python-midjourney-min.png 512w, https://www.relataly.com/wp-content/uploads/2023/03/LGBT-fairness-in-machine-learning-relataly-ai-python-midjourney-min.png 300w, https://www.relataly.com/wp-content/uploads/2023/03/LGBT-fairness-in-machine-learning-relataly-ai-python-midjourney-min.png 140w, https://www.relataly.com/wp-content/uploads/2023/03/LGBT-fairness-in-machine-learning-relataly-ai-python-midjourney-min.png 768w, https://www.relataly.com/wp-content/uploads/2023/03/LGBT-fairness-in-machine-learning-relataly-ai-python-midjourney-min.png 1024w" sizes="(max-width: 512px) 100vw, 512px" /><figcaption class="wp-element-caption">Organizations must take the necessary steps to ensure their algorithms are unbiased and not perpetuate the same inequalities still plaguing our society. Image created with <a href="http://www.midjourney.com" target="_blank" rel="noreferrer noopener">Midjourney</a>.</figcaption></figure>
</div>
</div>



<h2 class="wp-block-heading">Assessing Model Fairness with the Fairlearn Library</h2>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">Fairlearn is an <a href="https://fairlearn.org/" target="_blank" rel="noreferrer noopener">open-source Python package</a>, developed by <a href="https://www.microsoft.com/en-us/research/publication/fairlearn-a-toolkit-for-assessing-and-improving-fairness-in-ai/" target="_blank" rel="noreferrer noopener">Microsoft,</a> that offers tools for assessing and mitigating unfairness in machine learning models. The library empowers developers and data scientists to pinpoint and address potential sources of bias in their data and models, ensuring that predictions and decisions are made fairly and transparently.</p>



<p class="wp-block-paragraph">Fairlearn encompasses a variety of algorithms and metrics for evaluating and mitigating unfairness, including:</p>



<ul class="wp-block-list">
<li>Group Fairness: This metric measures the difference in a model&#8217;s performance across various subgroups of the population, such as race or gender.</li>



<li>Demographic Parity: This metric works to ensure that the model&#8217;s predictions are distributed fairly across different subgroups of the population.</li>



<li>Equalized Odds: This metric guarantees that the model&#8217;s predictions maintain equal accuracy across different subgroups of the population.</li>
</ul>



<p class="wp-block-paragraph">In addition to these metrics, Fairlearn also offers various techniques for mitigating unfairness. These include reweighing data to balance different subgroups, adjusting the model&#8217;s predictions to meet specific fairness criteria, and enforcing fairness constraints during the training process. By utilizing Fairlearn, developers and data scientists can be confident that their machine learning models are more equitable and unbiased.</p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<figure class="wp-block-image size-full"><img decoding="async" width="431" height="485" data-attachment-id="12879" data-permalink="https://www.relataly.com/building-fair-machine-machine-learning-models-with-fairlearn/12804/magnifier-to-analyze-machine-learning-algorithms-and-prevent-unfairness-in-ai-midjourney-relataly-python-min/#main" data-orig-file="https://www.relataly.com/wp-content/uploads/2023/03/magnifier-to-analyze-machine-learning-algorithms-and-prevent-unfairness-in-ai-midjourney-relataly-python-min.png" data-orig-size="431,485" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="magnifier-to-analyze-machine-learning-algorithms-and-prevent-unfairness-in-ai-midjourney-relataly-python-min" data-image-description="" data-image-caption="" data-large-file="https://www.relataly.com/wp-content/uploads/2023/03/magnifier-to-analyze-machine-learning-algorithms-and-prevent-unfairness-in-ai-midjourney-relataly-python-min.png" src="https://www.relataly.com/wp-content/uploads/2023/03/magnifier-to-analyze-machine-learning-algorithms-and-prevent-unfairness-in-ai-midjourney-relataly-python-min.png" alt="Assessing Model Fairness with the Fairlearn Library. Image created with Midjourney." class="wp-image-12879" srcset="https://www.relataly.com/wp-content/uploads/2023/03/magnifier-to-analyze-machine-learning-algorithms-and-prevent-unfairness-in-ai-midjourney-relataly-python-min.png 431w, https://www.relataly.com/wp-content/uploads/2023/03/magnifier-to-analyze-machine-learning-algorithms-and-prevent-unfairness-in-ai-midjourney-relataly-python-min.png 267w" sizes="(max-width: 431px) 100vw, 431px" /><figcaption class="wp-element-caption">Assessing Model Fairness with the Fairlearn Library. Image created with Midjourney.</figcaption></figure>
</div>
</div>



<h2 class="wp-block-heading">Mitigating Unfairness in Machine Learning</h2>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">There are two options to address unfairness in machine learning models: consider fairness during training or add a post-processing step to mitigate unfairness as an additional layer. Both methods have their merits and drawbacks. The ideal approach depends on the context and objectives of the problem you&#8217;re tackling.</p>



<p class="wp-block-paragraph">Considering fairness during training involves incorporating fairness constraints into the learning process. This approach can lead to more interpretable models, as fairness is embedded from the start. However, it may require specialized algorithms and could result in reduced performance.</p>



<p class="wp-block-paragraph">On the other hand, adding a post-processing step to mitigate unfairness involves adjusting the model&#8217;s predictions after training. This method offers flexibility, as it can be applied to any pre-trained model. It may also preserve performance better. However, it might not provide as much interpretability, as fairness is addressed separately from the original model.</p>



<p class="wp-block-paragraph">Ultimately, the choice depends on your specific goals, the model&#8217;s purpose, and the importance of interpretability versus performance.</p>



<h4 class="wp-block-heading">Considering Fairness during Training with Fairness Constraints</h4>



<p class="wp-block-paragraph">Considering fairness during training involves incorporating fairness constraints or objectives into the model&#8217;s training process. This can be done in different ways: </p>



<ul class="wp-block-list">
<li>by balancing the training dataset to ensure equal representation of different groups. </li>



<li>by adjusting the model&#8217;s loss function to penalize unfair predictions, </li>



<li>or by adding fairness constraints to the optimization problem. </li>
</ul>



<p class="wp-block-paragraph">The main advantage of this approach is that it can lead to models that are inherently fair without requiring any additional post-processing steps. However, it can be challenging to define and operationalize fairness. In addition, the fairness objectives may conflict with other objectives, such as accuracy or generalization.</p>



<p class="wp-block-paragraph">There are several fairness constraints that can be used to ensure that machine learning models and decision-making processes do not discriminate against certain groups. Some of the most commonly used constraints include:</p>



<ul class="wp-block-list">
<li>Demographic Parity: This constraint ensures that the proportion of positive outcomes is equal across different demographic groups.</li>



<li>Equalized Odds: This constraint ensures that the true positive rate and false positive rate are equal across different demographic groups.</li>



<li>Disparate Impact: This constraint ensures that the ratio of positive outcomes to the total number of outcomes is the same across different demographic groups.</li>
</ul>



<p class="wp-block-paragraph">For a full list of constraints, please view the <a href="https://fairlearn.org/v0.7.0/user_guide/mitigation.html#demographic-parity" target="_blank" rel="noreferrer noopener">library documentation</a>. </p>



<p class="wp-block-paragraph">The choice of fairness constraint depends on the specific context and goals of the decision-making process, and the constraints may need to be customized or combined to achieve the desired level of fairness.</p>



<h4 class="wp-block-heading">Fairness Mitigation as a Postprocessing Layer </h4>



<p class="wp-block-paragraph">Another approach is to add a post-processing step to mitigate the unfairness of existing models. This method involves applying a fairness algorithm to the model&#8217;s outputs after training. Examples include reweighting predictions to ensure equal treatment of different groups, calibrating the model&#8217;s scores to remove bias, or using a fairness metric to adjust predictions.</p>



<p class="wp-block-paragraph">The primary advantage of this approach is its applicability to existing models without the need for retraining. However, it might not tackle the root causes of unfairness in the model, and the fairness algorithm could introduce its own biases or trade-offs.</p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<figure class="wp-block-image size-full"><img decoding="async" width="506" height="510" data-attachment-id="12846" data-permalink="https://www.relataly.com/building-fair-machine-machine-learning-models-with-fairlearn/12804/a_scale_where_each_side_represents_a_different_group-relataly-machine-learning-fair-ai-responsible-midjourney-min/#main" data-orig-file="https://www.relataly.com/wp-content/uploads/2023/03/a_scale_where_each_side_represents_a_different_group-relataly-machine-learning-fair-ai-responsible-midjourney-min.png" data-orig-size="506,510" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="a_scale_where_each_side_represents_a_different_group-relataly-machine-learning-fair-ai-responsible-midjourney-min" data-image-description="" data-image-caption="" data-large-file="https://www.relataly.com/wp-content/uploads/2023/03/a_scale_where_each_side_represents_a_different_group-relataly-machine-learning-fair-ai-responsible-midjourney-min.png" src="https://www.relataly.com/wp-content/uploads/2023/03/a_scale_where_each_side_represents_a_different_group-relataly-machine-learning-fair-ai-responsible-midjourney-min.png" alt="We can consider fairness towards sensitive features during the training of a machine learning model, by using the fairness constraints. Image created with Midjourney. " class="wp-image-12846" srcset="https://www.relataly.com/wp-content/uploads/2023/03/a_scale_where_each_side_represents_a_different_group-relataly-machine-learning-fair-ai-responsible-midjourney-min.png 506w, https://www.relataly.com/wp-content/uploads/2023/03/a_scale_where_each_side_represents_a_different_group-relataly-machine-learning-fair-ai-responsible-midjourney-min.png 298w, https://www.relataly.com/wp-content/uploads/2023/03/a_scale_where_each_side_represents_a_different_group-relataly-machine-learning-fair-ai-responsible-midjourney-min.png 140w" sizes="(max-width: 506px) 100vw, 506px" /><figcaption class="wp-element-caption">We can consider fairness towards sensitive features during the training of a machine learning model by using the fairness constraints. Image created with Midjourney. </figcaption></figure>
</div>
</div>



<h2 class="wp-block-heading">Building A More Inclusive Machine Learning Model using FairLearn and Python</h2>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">Let&#8217;s explore building a fair machine learning model using the census dataset, which includes demographic attributes to predict if a person earns more or less than $50k per year. As income prediction is sensitive, we&#8217;ll ensure fairness in our model.</p>



<p class="wp-block-paragraph">We&#8217;ll create an initial fairness-unaware model, evaluate its fairness, and then use grid search to identify alternative models with varying performance and unfairness. This process consists of:</p>



<ol class="wp-block-list">
<li>Load the data: Load the census dataset containing demographic attributes like age, education level, race, and gender.</li>



<li>Initial preprocessing and visualization: Preprocess the data by removing missing values, encoding categorical variables, scaling numerical features, and visualizing the data for insights.</li>



<li>Splitting and scaling the data: Split the data into training and testing sets and scale the features to make them comparable.</li>



<li>Training a fairness-unaware model and assessing fairness: Train a baseline model unaware of unfairness and evaluate its fairness using metrics like disparate impact and statistical parity difference.</li>



<li>Mitigating bias by training fairness-aware models with fairness constraints: Train models using demographic parity as a fairness constraint to mitigate bias and improve fairness.</li>



<li>Comparing the performance of the models: Compare the models&#8217; performance in accuracy, fairness, and other metrics like false positives and false negatives.</li>
</ol>



<p class="wp-block-paragraph">By following these steps, we&#8217;ll build a fair machine learning model that is accurate, equitable, and just.</p>



<p class="wp-block-paragraph">The code is available on the GitHub repository.</p>



<div class="wp-block-kadence-advancedbtn kb-buttons-wrap kb-btns_1343d2-ee"><a class="kb-button kt-button button kb-btn_409929-d9 kt-btn-size-standard kt-btn-width-type-full kb-btn-global-inherit kt-btn-has-text-true kt-btn-has-svg-true wp-block-button__link wp-block-kadence-singlebtn" href="https://github.com/flo7up/relataly-public-python-tutorials/blob/master/300%20Distributed%20Computing%20-%20Analyzing%20Zurich%20Weather%20Data%20using%20PySpark.ipynb" target="_blank" rel="noreferrer noopener"><span class="kb-svg-icon-wrap kb-svg-icon-fe_eye kt-btn-icon-side-left"><svg viewBox="0 0 24 24"  fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"  aria-hidden="true"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg></span><span class="kt-btn-inner-text">View on GitHub </span></a>

<a class="kb-button kt-button button kb-btn_0b81a6-0d kt-btn-size-standard kt-btn-width-type-full kb-btn-global-inherit kt-btn-has-text-true kt-btn-has-svg-true wp-block-button__link wp-block-kadence-singlebtn" href="https://github.com/flo7up/relataly-public-python-API-tutorials" target="_blank" rel="noreferrer noopener"><span class="kb-svg-icon-wrap kb-svg-icon-fa_github kt-btn-icon-side-left"><svg viewBox="0 0 496 512"  fill="currentColor" xmlns="http://www.w3.org/2000/svg"  aria-hidden="true"><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg></span><span class="kt-btn-inner-text">Relataly GitHub Repo </span></a></div>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<figure class="wp-block-image size-full"><img decoding="async" width="506" height="511" data-attachment-id="12983" data-permalink="https://www.relataly.com/building-fair-machine-machine-learning-models-with-fairlearn/12804/responsible-ai-and-fairness-in-machine-learning-will-gain-further-importance-as-the-role-of-this-exsciting-technology-will-continue-to-become-more-important/#main" data-orig-file="https://www.relataly.com/wp-content/uploads/2023/03/responsible-ai-and-fairness-in-machine-learning-will-gain-further-importance-as-the-role-of-this-exsciting-technology-will-continue-to-become-more-important.png" data-orig-size="506,511" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="responsible-ai-and-fairness-in-machine-learning-will-gain-further-importance-as-the-role-of-this-exsciting-technology-will-continue-to-become-more-important" data-image-description="" data-image-caption="" data-large-file="https://www.relataly.com/wp-content/uploads/2023/03/responsible-ai-and-fairness-in-machine-learning-will-gain-further-importance-as-the-role-of-this-exsciting-technology-will-continue-to-become-more-important.png" src="https://www.relataly.com/wp-content/uploads/2023/03/responsible-ai-and-fairness-in-machine-learning-will-gain-further-importance-as-the-role-of-this-exsciting-technology-will-continue-to-become-more-important.png" alt="" class="wp-image-12983" srcset="https://www.relataly.com/wp-content/uploads/2023/03/responsible-ai-and-fairness-in-machine-learning-will-gain-further-importance-as-the-role-of-this-exsciting-technology-will-continue-to-become-more-important.png 506w, https://www.relataly.com/wp-content/uploads/2023/03/responsible-ai-and-fairness-in-machine-learning-will-gain-further-importance-as-the-role-of-this-exsciting-technology-will-continue-to-become-more-important.png 297w, https://www.relataly.com/wp-content/uploads/2023/03/responsible-ai-and-fairness-in-machine-learning-will-gain-further-importance-as-the-role-of-this-exsciting-technology-will-continue-to-become-more-important.png 140w" sizes="(max-width: 506px) 100vw, 506px" /><figcaption class="wp-element-caption">Responsible AI, and fairness in machine learning will gain further importance as the role of this exciting technology continues to become more influential in society.</figcaption></figure>
</div>
</div>



<h3 class="wp-block-heading">Prerequisites</h3>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">Before starting the coding part, make sure that you have set up your <a href="https://www.python.org/downloads/" target="_blank" rel="noreferrer noopener">Python 3</a> environment and required packages. This will ensure a seamless learning experience and prevent any potential roadblocks or issues that may arise due to an improperly configured environment.</p>



<p class="wp-block-paragraph">If you don&#8217;t have an environment, follow&nbsp;<a href="https://www.relataly.com/anaconda-python-environment-machine-learning/1663/" target="_blank" rel="noreferrer noopener">this tutorial</a>&nbsp;to set up the&nbsp;<a href="https://www.anaconda.com/products/individual" target="_blank" rel="noreferrer noopener">Anaconda environment</a>.</p>



<p class="wp-block-paragraph">Make sure you install all required packages. In this tutorial, we will be working with the following packages:&nbsp;</p>



<ul class="wp-block-list">
<li>Pandas</li>



<li>NumPy</li>



<li>Matplotlib</li>



<li>Seaborn</li>



<li>Plotly</li>



<li>Fairlearn</li>
</ul>



<p class="wp-block-paragraph">You can install the Fairlearn library and other packages using console commands:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;null&quot;,&quot;mime&quot;:&quot;text/plain&quot;,&quot;theme&quot;:&quot;3024-day&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Plain Text&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;text&quot;}">pip install &lt;package name&gt;
conda install &lt;package name&gt; (if you are using the anaconda packet manager)</pre></div>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%"></div>
</div>



<h3 class="wp-block-heading">About the Adult Consensus Dataset</h3>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">The Adult Consensus Dataset is a highly regarded and extensively used resource in machine learning and statistics, offering a comprehensive view of over 32,000 individuals across the United States. This invaluable dataset features 14 unique attributes, such as age, education, occupation, work class, marital status, and gender, among others. It also includes a binary target variable, identifying individuals earning over $50,000 annually.</p>



<p class="wp-block-paragraph">However, the dataset presents challenges, as it contains sensitive demographic features like race and gender. If not handled properly, these features may lead to biased predictions and unfair outcomes. As a result, models trained on this dataset require careful design and evaluation to prevent perpetuating or amplifying existing biases and discrimination.</p>



<p class="wp-block-paragraph">Despite its complexities, the Adult Consensus Dataset remains a popular choice for training and testing binary classification models. Its value extends further, serving as an excellent benchmark for testing and showcasing fair AI models. The dataset raises important questions about fairness, bias, and discrimination in machine learning, making it an essential resource for creating ethical and unbiased AI solutions.</p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%"></div>
</div>



<h3 class="wp-block-heading" id="h-step-1-load-preprocess-the-data">Step #1 Load Preprocess the Data</h3>



<p class="wp-block-paragraph">We begin by loading the data using the fetch_openml function, making the necessary imports, and performing some initial preprocessing. The dataset is loaded into two data frames, X_df and y_df, where X_df contains the features and y_df contains the binary target variable, which is income with classes &#8220;&gt;50k&#8221; and &#8220;&lt;=50k&#8221;. The code below encodes these classes with 0 and 1.</p>



<p class="wp-block-paragraph">Assessing model fairness is always done with respect to one or several sensitive variables. Although there are several features in the dataset that could be considered sensitive, optimizing the model to consider all of these features simultaneously would lead to significant complexity and increase training times. Therefore, in this tutorial, we will focus specifically on assessing model fairness with respect to sex and race. The sex feature contains two classes, &#8220;male&#8221; and &#8220;female,&#8221; while the race feature contains classes for &#8220;Black,&#8221; &#8220;White,&#8221; and several further classes. </p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text/x-python&quot;,&quot;theme&quot;:&quot;monokai&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}"># A tutorial for this file will be shortly available at www.relataly.com
# Tested with python 3.9.13, matplotlib 3.6.2, numpy 1.23.3, seaborn=0.12.1, fairlearn=0.8.0, plotly 5.11.0

from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder, StandardScaler
from sklearn import metrics as skm
from fairlearn.metrics import MetricFrame, selection_rate, selection_rate_difference, count, plot_model_comparison
from fairlearn.reductions import DemographicParity, ErrorRate, GridSearch
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
sns.set_style('white', { 'axes.spines.right': False, 'axes.spines.top': False})

# read the adult data
# predict whether income exceeds $50K/yr based on census data. Also known as &quot;Census Income&quot; dataset.
# https://archive.ics.uci.edu/ml/datasets/adult

from sklearn.datasets import fetch_openml
data = fetch_openml(data_id=1590, parser='auto', as_frame=True)

X_df = data.data.copy()
data.target = data.target.replace({' &lt;=50K': 0, ' &gt;50K': 1})
y_df = data.target

# Declare sensitive features
sensitive_variables = [&quot;sex&quot;, 'race']

# join X_df and y_df and name y_df as 'income'
X_df['salary &gt;50k'] = y_df

# show df that contains the target column
X_df.head()</pre></div>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;null&quot;,&quot;mime&quot;:&quot;text/plain&quot;,&quot;theme&quot;:&quot;3024-day&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Plain Text&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;text&quot;}">	age	workclass	fnlwgt	education	race	sex		...		hours-per-week	salary &gt;50k
0	25	4			226802	1			Black	Male	...		40				0
1	38	4			89814	11			White	Male	...		50				0
2	28	2			336951	7			White	Male	...		40				1
3	44	4			160323	15			Black	Male	...		40				1
4	18	0			103497	15			White	Female	...		30				0</pre></div>



<h3 class="wp-block-heading">Step #2 Initial Preprocessing and Visualization</h3>



<p class="wp-block-paragraph">Let&#8217;s continue with some initial preprocessing and data visualization. First, we encode the categorical features in the X_df data frame using the LabelEncoder function from scikit-learn. This is important, as the fairlearn gridsearch technique that we will use in this tutorial only works with numeric features.</p>



<p class="wp-block-paragraph">Next, to simplify the tutorial and reduce model training time, we will filter the dataset to only include people of races &#8220;Black&#8221; and &#8220;White.&#8221; This will result in four sensitive feature permutations:</p>



<ul class="wp-block-list">
<li>Black, Woman</li>



<li>Black, Man</li>



<li>White, Woman</li>



<li>White, Man</li>
</ul>



<p class="wp-block-paragraph">Finally, we create two data frames. The X_df data frame contains the features we will be using to train our model, but it does not contain the target label anymore. The other data frame, df_visu, does contain the target label and will be used for visualization purposes. Finally, we use df_visu to visualize how the target variable is distributed with respect to our sensitive features.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text/x-python&quot;,&quot;theme&quot;:&quot;monokai&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}"># encode the categorical features
X_df['workclass'] = X_df['workclass'].cat.codes
X_df['education'] = X_df['education'].cat.codes
X_df['marital-status'] = X_df['marital-status'].cat.codes
X_df['occupation'] = X_df['occupation'].cat.codes
X_df['relationship'] = X_df['relationship'].cat.codes

# filter some values to reduce tutorial complexity and make it easier to visualize
X_df = X_df.loc[X_df[&quot;race&quot;].astype(str).isin([&quot; White&quot;, &quot; Black&quot;])]
X_df.race = X_df.race.cat.remove_unused_categories()

# ensure that the target column has the same filter applied
y_df = X_df['salary &gt;50k']

# create a copy of the df for visualization
df_visu = X_df.copy()

# drop the target column from X_df
X_df.drop(['salary &gt;50k'], axis=1, inplace=True)

# visualize the distributions of the cateogical variables
fig, ax = plt.subplots(1, 3, figsize=(16, 5))
sns.countplot(x='sex', hue='salary &gt;50k', data=df_visu, ax=ax[0])
sns.countplot(x='race', hue='salary &gt;50k', data=df_visu, ax=ax[1])
sns.kdeplot(x='age', hue='salary &gt;50k', data=df_visu, ax=ax[2])

# rotate x_labels
plt.sca(ax[1])
plt.xticks(rotation=30)</pre></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1336" height="472" data-attachment-id="12964" data-permalink="https://www.relataly.com/building-fair-machine-machine-learning-models-with-fairlearn/12804/image-4-4/#main" data-orig-file="https://www.relataly.com/wp-content/uploads/2023/03/image-4.png" data-orig-size="1336,472" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="image-4" data-image-description="" data-image-caption="" data-large-file="https://www.relataly.com/wp-content/uploads/2023/03/image-4.png" src="https://www.relataly.com/wp-content/uploads/2023/03/image-4.png" alt="Distribution of target label with respect to sex, race and age. Responsible AI, fairlearn, python tutorial, machine learning, relataly." class="wp-image-12964" srcset="https://www.relataly.com/wp-content/uploads/2023/03/image-4.png 1336w, https://www.relataly.com/wp-content/uploads/2023/03/image-4.png 300w, https://www.relataly.com/wp-content/uploads/2023/03/image-4.png 512w, https://www.relataly.com/wp-content/uploads/2023/03/image-4.png 768w" sizes="(max-width: 1237px) 100vw, 1237px" /></figure>



<p class="wp-block-paragraph">All three plots reflect inequality in our society:</p>



<ul class="wp-block-list">
<li>The percentage of women with a yearly income above 50k is much lower than that of men. </li>



<li>With respect to race, this bias is even more extreme, with way more white people earning more than 50k than black people.</li>



<li>Although we won&#8217;t use age as a sensitive label, it is noteworthy that the percentage of people earning more than 50k declines with growing age. </li>
</ul>



<h3 class="wp-block-heading">Step #3 Splitting and Scaling the Data</h3>



<p class="wp-block-paragraph">The code performs several preprocessing steps. First, the data is split into the features (X_df) and the target variable (y_df). Next, the categorical features in X_df are encoded using the LabelEncoder function from scikit-learn. The data is then split into training and test sets. Records are stratified based on the target variable to ensure that the proportion of each class is maintained in both sets.</p>



<p class="wp-block-paragraph">It is important to note that the sensitive variables, sex and race, are included in the splitting process to ensure that the data is divided in a fair manner. Specifically, we create a new data frame A containing only the sensitive variables. We then split the data into training and test sets using the stratify parameter based on Y_encoded (the encoded version of y_df) and A.</p>



<p class="wp-block-paragraph">Finally, the features in X_df are scaled using the StandardScaler function from scikit-learn to ensure that all features are on the same scale. The resulting scaled features are then converted back into a pandas data frame, X_scaled.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text/x-python&quot;,&quot;theme&quot;:&quot;monokai&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}"># create a dataframe with sensitive features
A = X_df[sensitive_variables]
X = X_df.drop(labels=sensitive_variables, axis=1)
X = pd.get_dummies(X)

# Scale the data
sc = StandardScaler()
X_scaled = sc.fit_transform(X)
X_scaled = pd.DataFrame(X_scaled, columns=X.columns)

# Encode the target variable
le = LabelEncoder()
Y_encoded = le.fit_transform(y_df)

# We split the data into training and test sets:
X_train, X_test, Y_train, Y_test, A_train, A_test = train_test_split(
    X_scaled, Y_encoded, A, test_size=0.4, random_state=0, stratify=Y_encoded
)

# Work around indexing bug
X_train = X_train.reset_index(drop=True)
A_train = A_train.reset_index(drop=True)
X_test = X_test.reset_index(drop=True)
A_test = A_test.reset_index(drop=True)</pre></div>



<h3 class="wp-block-heading">Step #4 Train a Fairness-Unaware Model and Assess its Fairness</h3>



<p class="wp-block-paragraph">Now it&#8217;s time to train our first model. This initial model will be entirely fairness unaware, meaning its predictions will reflect any patterns of unfairness present in the data.</p>



<h4 class="wp-block-heading">Model training</h4>



<p class="wp-block-paragraph">We&#8217;ll begin by training a baseline fairness unaware <a href="https://www.relataly.com/category/machine-learning-algorithms/decision-trees/" target="_blank" rel="noreferrer noopener">decision tree classifier</a> with default settings. The model will be trained on the training set (X_train and Y_train) and then tested on the test set (X_test and Y_test).</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text/x-python&quot;,&quot;theme&quot;:&quot;monokai&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}"># Define evaluation metrics for performance and fairness
performance_metric = skm.accuracy_score
fairness_metric = selection_rate_difference

unmitigated_predictor = DecisionTreeClassifier(random_state=0)
unmitigated_predictor.fit(X_train, Y_train)
</pre></div>



<h4 class="wp-block-heading">Evaluation and Visualization </h4>



<p class="wp-block-paragraph">To evaluate the model&#8217;s performance, we&#8217;ll use two crucial metrics: the accuracy score and the &#8220;selection rate difference&#8221;. The latter is a vital fairness metric that measures the difference between selection rates of two distinct groups for a specific outcome or prediction.</p>



<p class="wp-block-paragraph">In machine learning, this metric often helps determine the fairness of a model, especially with sensitive features like race, gender, or age. A selection rate difference of zero indicates that the model is making predictions fairly and without bias, as both groups have equal selection rates.</p>



<p class="wp-block-paragraph">However, we must pay attention to a positive or negative selection rate difference. It implies that the model is favoring one group over the other, which could signal bias or discrimination. Carefully monitoring this metric is critical to ensure the model is performing fairly and justly.</p>



<p class="wp-block-paragraph">Lastly, we&#8217;ll visualize the results in a bar chart using the accuracy and selection rate by group. This visualization will provide a comprehensive view of the model&#8217;s performance and fairness, allowing us to make informed decisions about potential improvements or adjustments needed to strike the right balance between accuracy and fairness.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text/x-python&quot;,&quot;theme&quot;:&quot;monokai&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}">metric_frame = MetricFrame(
    metrics={
        &quot;accuracy&quot;: performance_metric,
        &quot;selection_rate&quot;: fairness_metric,
        &quot;count&quot;: count,
    },
    sensitive_features=A_test,
    y_true=Y_test,
    y_pred=unmitigated_predictor.predict(X_test),
)

# plot the metrics
print(metric_frame.overall)
print(metric_frame.by_group)
metric_frame.by_group.plot.bar(
    subplots=True,
    layout=[1, 3],
    legend=False,
    figsize=[12, 4],
    title=&quot;Accuracy and selection rate by group&quot;,
)
</pre></div>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;null&quot;,&quot;mime&quot;:&quot;text/plain&quot;,&quot;theme&quot;:&quot;3024-day&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Plain Text&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;text&quot;}">accuracy              0.854136
selection_rate        0.197373
count             18579.000000
dtype: float64
                accuracy  selection_rate    count
sex     race                                     
 Female  Black  0.948665        0.053388    974.0
         White  0.921083        0.083873   5246.0
 Male    Black  0.877378        0.161734    946.0
         White  0.813371        0.264786  11413.0
array([[&lt;AxesSubplot: title={'center': 'accuracy'}, xlabel='sex,race'&gt;,
        &lt;AxesSubplot: title={'center': 'selection_rate'}, xlabel='sex,race'&gt;,
        &lt;AxesSubplot: title={'center': 'count'}, xlabel='sex,race'&gt;]],
      dtype=object)</pre></div>



<figure class="wp-block-image size-full"><img decoding="async" width="981" height="516" data-attachment-id="12974" data-permalink="https://www.relataly.com/building-fair-machine-machine-learning-models-with-fairlearn/12804/image-6-3/#main" data-orig-file="https://www.relataly.com/wp-content/uploads/2023/03/image-6.png" data-orig-size="981,516" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="image-6" data-image-description="" data-image-caption="" data-large-file="https://www.relataly.com/wp-content/uploads/2023/03/image-6.png" src="https://www.relataly.com/wp-content/uploads/2023/03/image-6.png" alt="When we look at the selection rate, we can see that the model is intrinsically biased. To be explicit, if this model would go into production, a Black Woman would have a significantly lower chance (5%) to be attributed a +50k income than a White Man (above 25%), even if all other attributes (age, education, and so on) are the same." class="wp-image-12974" srcset="https://www.relataly.com/wp-content/uploads/2023/03/image-6.png 981w, https://www.relataly.com/wp-content/uploads/2023/03/image-6.png 300w, https://www.relataly.com/wp-content/uploads/2023/03/image-6.png 512w, https://www.relataly.com/wp-content/uploads/2023/03/image-6.png 768w" sizes="(max-width: 981px) 100vw, 981px" /></figure>



<p class="wp-block-paragraph">When we look at the selection rate, we can see that the model is intrinsically biased. To be explicit, if this model would go into production, a Black Woman would have a significantly lower chance (5%) to be attributed a +50k income than a White Man (above 25%), even if all other attributes (age, education, and so on) are the same.</p>



<h3 class="wp-block-heading">Step #5 Train Fairness-Aware Models with Gridsearch</h3>



<p class="wp-block-paragraph">We perform a grid search with demographic parity as a fairness constraint to find the best decision tree classifier model that is both accurate and fair. We <a href="https://www.relataly.com/category/data-science/hyperparameter-tuning-for-machine-learning-with-python/" target="_blank" rel="noreferrer noopener">evaluate different models with different hyperparameters</a> for the decision tree classifier. The best predictors with the lowest error rates and lowest disparities (in terms of demographic parity) are selected as the dominant models.</p>



<p class="wp-block-paragraph">We call these models &#8220;dominant&#8221; because they stand out as superior solutions in multi-objective optimization. &#8220;Dominant&#8221; implies that these models outshine others across multiple evaluation metrics without falling short in any of the metrics. Dominant models are preferred for their optimal balance of performance and fairness.</p>



<p class="wp-block-paragraph">During model training, we&#8217;ll incorporate demographic parity as a fairness constraint. Demographic parity seeks to ensure equal proportions of positive outcomes (e.g., being hired, approved for a loan, etc.) across various demographic groups (e.g., gender, race, or age) in a population. In simpler terms, it requires the decision-making process not to discriminate against any group based on their demographic characteristics. Mathematically, it&#8217;s expressed as P(prediction=1|sensitive_feature=0) = P(prediction=1|sensitive_feature=1), where sensitive_feature is a binary variable indicating membership in a specific demographic group. Achieving demographic parity helps reduce discrimination and promote fairness in decision-making processes. However, depending on the context and goals of the decision-making process, demographic parity might not always be the most appropriate fairness constraint.</p>



<p class="wp-block-paragraph">Depending on the hardware you are using, training can take several minutes. </p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text/x-python&quot;,&quot;theme&quot;:&quot;monokai&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}"># Define and run GridSearch with DemographicParity 
sweep = GridSearch(
    DecisionTreeClassifier(random_state=0),
    constraints=DemographicParity(), # DemographicParity() is the default
    grid_size=100, # number of models to evaluate
)
sweep.fit(X_train, Y_train, sensitive_features=A_train)

# The best predictor is the one with the lowest error rate
predictors = sweep.predictors_

errors, disparities = [], []
for p in predictors:
    
    def classifier(X):
        return p.predict(X)

    # Calculate the error rate of the classifier
    error = ErrorRate()
    error.load_data(X_train, pd.Series(Y_train), sensitive_features=A_train)
    errors.append(error.gamma(classifier)[0])

    # Calculate the disparity in the predictions
    disparity = DemographicParity()
    disparity.load_data(X_train, pd.Series(Y_train), sensitive_features=A_train)
    disparities.append(disparity.gamma(classifier).max())

# Consolidate the results into a single dataframe
grid_results = pd.DataFrame(
    {&quot;predictor&quot;: predictors, 
     &quot;error&quot;: errors, 
     &quot;disparity&quot;: disparities}
)

# Loop through the grid and select the relevant models 
non_dominated_models = []
for model in grid_results.itertuples():
    # only select models with lower disparity compared to the other models
    if model.error &lt; grid_results[&quot;error&quot;][grid_results[&quot;disparity&quot;] &lt; model.disparity].min():
        non_dominated_models.append(model.predictor)</pre></div>



<p class="wp-block-paragraph">That&#8217;s it; now we have trained several fairness-aware models. Next, let&#8217;s look at the performance and fairness of these models.</p>



<h3 class="wp-block-heading">Step #6 Comparing Dominant and Unmitigated Models</h3>



<p class="wp-block-paragraph">Finally, we&#8217;ll evaluate and compare our models&#8217; performance. We&#8217;ll assess the dominant models and the unmitigated model using evaluation metrics for performance and fairness. The performance metric we&#8217;ll use is the accuracy score, and for fairness, we&#8217;ll use the selection rate difference. To do this, we&#8217;ll predict on the test data using the unmitigated model, then add predictions for all relevant dominant models.</p>



<p class="wp-block-paragraph">Next, we&#8217;ll create a scatterplot for the models based on their accuracy and selection rate. We&#8217;ll use the x-axis for performance metrics and the y-axis for fairness metrics. We&#8217;ll also include point labels and display the plot. This visualization will help us understand the trade-offs between performance and fairness in our models.</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text/x-python&quot;,&quot;theme&quot;:&quot;monokai&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}"># We can evaluate the dominant models along with the unmitigated model.

# Use the unmitigated model to predict on the test data
predictions = {&quot;unmitigated_model&quot;: unmitigated_predictor.predict(X_test)}

# Add predictions for all relevant dominant models
metric_frames = {&quot;unmitigated_model&quot;: metric_frame}
for i in range(len(non_dominated_models)):
    key = &quot;dominant_model_{0}&quot;.format(i)
    predictions[key] = non_dominated_models[i].predict(X_test)

    metric_frames[key] = MetricFrame(
        metrics={
            &quot;accuracy&quot;: performance_metric,
            &quot;selection_rate&quot;: selection_rate,
            &quot;count&quot;: count,
        },
        sensitive_features=A_test,
        y_true=Y_test,
        y_pred=predictions[key],
    )

# scatterplot for the models along their accuracy and selection rate
plot_model_comparison(
    x_axis_metric=performance_metric,
    y_axis_metric=fairness_metric,
    y_true=Y_test,
    y_preds=predictions,
    sensitive_features=A_test,
    point_labels=True,
    show_plot=True,
)</pre></div>



<figure class="wp-block-image size-full"><img decoding="async" width="666" height="428" data-attachment-id="12980" data-permalink="https://www.relataly.com/building-fair-machine-machine-learning-models-with-fairlearn/12804/image-8-4/#main" data-orig-file="https://www.relataly.com/wp-content/uploads/2023/03/image-8.png" data-orig-size="666,428" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="image-8" data-image-description="" data-image-caption="" data-large-file="https://www.relataly.com/wp-content/uploads/2023/03/image-8.png" src="https://www.relataly.com/wp-content/uploads/2023/03/image-8.png" alt="" class="wp-image-12980" srcset="https://www.relataly.com/wp-content/uploads/2023/03/image-8.png 666w, https://www.relataly.com/wp-content/uploads/2023/03/image-8.png 300w, https://www.relataly.com/wp-content/uploads/2023/03/image-8.png 512w" sizes="(max-width: 666px) 100vw, 666px" /></figure>



<p class="wp-block-paragraph">Upon examination, it becomes apparent that we are presented with multiple dominant models that have a marginal difference in their selection rates as well as accuracy levels. These models, while exhibiting slightly lower accuracy, are less influenced by race or gender than the fairness-unaware model. As such, these models may be considered viable candidates for deployment in the model selection process.</p>



<p class="wp-block-paragraph">It is worth noting, however, that while these models appear to be less prone to bias based on sensitive features, they may still exhibit unfairness towards other features that have not been declared sensitive.</p>



<h2 class="wp-block-heading">Summary</h2>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:66.66%">
<p class="wp-block-paragraph">The significance of responsible AI and fairness in machine learning cannot be overstated. With AI systems becoming increasingly integrated into our lives, it&#8217;s essential that we proactively address issues of bias and discrimination.</p>



<p class="wp-block-paragraph">In this article, we&#8217;ve taken a small but vital step towards a more equitable world by developing machine learning models that are fair with respect to sensitive features. Our efforts have been focused on ensuring that our models are less biased and more equitable, using techniques such as reweighting and threshold optimization.</p>



<p class="wp-block-paragraph">The negative consequences of biased models cannot be ignored. They can lead to discrimination and reputational damage, making it even more important to ensure that our AI systems are fair and just. As AI technology continues to advance, there is an increased need for responsible AI and fairness in AI systems, particularly with the development of more powerful generative models that have the potential to revolutionize various industries.</p>



<p class="wp-block-paragraph">By taking steps to address issues of bias and discrimination in AI systems, we can ensure that these systems promote positive outcomes and benefit everyone equally. We must strive towards a more equitable and just world through responsible AI and fairness in machine learning.</p>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:33.33%">
<figure class="wp-block-image size-large"><img decoding="async" width="512" height="512" data-attachment-id="12972" data-permalink="https://www.relataly.com/building-fair-machine-machine-learning-models-with-fairlearn/12804/if-applied-with-care-then-ai-and-machine-learning-can-contribute-to-building-a-world-that-is-fairer-and-more-just-relataly-midjourney-min/#main" data-orig-file="https://www.relataly.com/wp-content/uploads/2023/03/if-applied-with-care-then-AI-and-machine-learning-can-contribute-to-building-a-world-that-is-fairer-and-more-just-relataly-midjourney-min.png" data-orig-size="1024,1024" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="if-applied-with-care-then-AI-and-machine-learning-can-contribute-to-building-a-world-that-is-fairer-and-more-just-relataly-midjourney-min" data-image-description="" data-image-caption="" data-large-file="https://www.relataly.com/wp-content/uploads/2023/03/if-applied-with-care-then-AI-and-machine-learning-can-contribute-to-building-a-world-that-is-fairer-and-more-just-relataly-midjourney-min.png" src="https://www.relataly.com/wp-content/uploads/2023/03/if-applied-with-care-then-AI-and-machine-learning-can-contribute-to-building-a-world-that-is-fairer-and-more-just-relataly-midjourney-min-512x512.png" alt="When used wisely, AI and machine learning can help create a fairer and more equitable world. Image created with Midjourney." class="wp-image-12972" srcset="https://www.relataly.com/wp-content/uploads/2023/03/if-applied-with-care-then-AI-and-machine-learning-can-contribute-to-building-a-world-that-is-fairer-and-more-just-relataly-midjourney-min.png 512w, https://www.relataly.com/wp-content/uploads/2023/03/if-applied-with-care-then-AI-and-machine-learning-can-contribute-to-building-a-world-that-is-fairer-and-more-just-relataly-midjourney-min.png 300w, https://www.relataly.com/wp-content/uploads/2023/03/if-applied-with-care-then-AI-and-machine-learning-can-contribute-to-building-a-world-that-is-fairer-and-more-just-relataly-midjourney-min.png 140w, https://www.relataly.com/wp-content/uploads/2023/03/if-applied-with-care-then-AI-and-machine-learning-can-contribute-to-building-a-world-that-is-fairer-and-more-just-relataly-midjourney-min.png 768w, https://www.relataly.com/wp-content/uploads/2023/03/if-applied-with-care-then-AI-and-machine-learning-can-contribute-to-building-a-world-that-is-fairer-and-more-just-relataly-midjourney-min.png 1024w" sizes="(max-width: 512px) 100vw, 512px" /><figcaption class="wp-element-caption">When used wisely, AI and machine learning can help create a fairer and more equitable world. Image created with <a href="http://www.midjourney.com" target="_blank" rel="noreferrer noopener">Midjourney</a>.</figcaption></figure>
</div>
</div>



<h2 class="wp-block-heading">Sources and Further Reading</h2>



<ul class="wp-block-list">
<li><a href="https://en.wikipedia.org/wiki/Ethics_of_artificial_intelligence" target="_blank" rel="noreferrer noopener">Wikipedia/AI ethics</a></li>



<li><a href="https://www.microsoft.com/en-us/research/uploads/prod/2020/05/Fairlearn_WhitePaper-2020-09-22.pdf" target="_blank" rel="noreferrer noopener">Fairlearnwhitepaper</a></li>



<li><a href="https://fairlearn.org/" target="_blank" rel="noreferrer noopener">Fairlearn.org</a></li>



<li><a href="https://chat.openai.com/chat" target="_blank" rel="noreferrer noopener">ChatGPT</a> helped me revise this article.</li>



<li><a href="https://github.com/fairlearn/fairlearn" target="_blank" rel="noreferrer noopener">github.com/fairlearn/fairlearn</a></li>



<li>Images created with <a href="http://www.midjourney.com" target="_blank" rel="noreferrer noopener">Midjourney AI</a></li>
</ul>



<h4 class="wp-block-heading"><strong>Books on Responsible AI</strong> <strong>and Applied Machine Learning</strong></h4>



<div style="display: inline-block;">
<iframe sandbox="allow-popups allow-scripts allow-modals allow-forms allow-same-origin" style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="//ws-eu.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&amp;OneJS=1&amp;Operation=GetAdHtml&amp;MarketPlace=DE&amp;source=ss&amp;ref=as_ss_li_til&amp;ad_type=product_link&amp;tracking_id=flo7up-21&amp;language=de_DE&amp;marketplace=amazon&amp;region=DE&amp;placement=0141985410&amp;asins=0141985410&amp;linkId=50db0da536c9bbe81fa2cbfdb899f590&amp;show_border=true&amp;link_opens_in_new_window=true"></iframe>
<iframe sandbox="allow-popups allow-scripts allow-modals allow-forms allow-same-origin" style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="//ws-eu.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&amp;OneJS=1&amp;Operation=GetAdHtml&amp;MarketPlace=DE&amp;source=ss&amp;ref=as_ss_li_til&amp;ad_type=product_link&amp;tracking_id=flo7up-21&amp;language=de_DE&amp;marketplace=amazon&amp;region=DE&amp;placement=026253701X&amp;asins=026253701X&amp;linkId=ec52692a7e2caf19d5c5617cdb476a78&amp;show_border=true&amp;link_opens_in_new_window=true"></iframe>
  <iframe sandbox="allow-popups allow-scripts allow-modals allow-forms allow-same-origin" style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="//ws-eu.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&amp;OneJS=1&amp;Operation=GetAdHtml&amp;MarketPlace=DE&amp;source=ss&amp;ref=as_ss_li_til&amp;ad_type=product_link&amp;tracking_id=flo7up-21&amp;language=de_DE&amp;marketplace=amazon&amp;region=DE&amp;placement=3030181162&amp;asins=3030181162&amp;linkId=669e46025028259138fbb5ccec12dfbe&amp;show_border=true&amp;link_opens_in_new_window=true"></iframe>
<iframe sandbox="allow-popups allow-scripts allow-modals allow-forms allow-same-origin" style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="//ws-eu.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&amp;OneJS=1&amp;Operation=GetAdHtml&amp;MarketPlace=DE&amp;source=ss&amp;ref=as_ss_li_til&amp;ad_type=product_link&amp;tracking_id=flo7up-21&amp;language=de_DE&amp;marketplace=amazon&amp;region=DE&amp;placement=1999579577&amp;asins=1999579577&amp;linkId=91d862698bf9010ff4c09539e4c49bf4&amp;show_border=true&amp;link_opens_in_new_window=true"></iframe>
</div>



<p class="has-contrast-2-color has-base-3-background-color has-text-color has-background wp-block-paragraph"><em>The links above to Amazon are affiliate links. By buying through these links, you support the Relataly.com blog and help to cover the hosting costs. Using the links does not affect the price.</em></p>
<p>The post <a href="https://www.relataly.com/building-fair-machine-machine-learning-models-with-fairlearn/12804/">Using Fairlearn to Build Fair Machine Machine Learning Models with Python: Step-by-Step Towards More Responsible AI</a> appeared first on <a href="https://www.relataly.com">relataly.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.relataly.com/building-fair-machine-machine-learning-models-with-fairlearn/12804/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">12804</post-id>	</item>
	</channel>
</rss>
