« Previous: Home Next: Getting started »

Overview


At this website, you will find a description of Seldonian algorithms as well as hands-on tutorials for implementing them with the Seldonian Toolkit. Use the navigation buttons at the top of the page to jump between pages, or click the links in the navbar at the top of the page. This page provides an overview of Seldonian algorithms, the Seldonian framework, and this software toolkit. If you are new to these topics, we recommend reading from the top down, but you are welcome to jump ahead using the links below. The content below is organized into the following topics:

  1. The need for safe and fair machine learning
  2. The necessity of probabilistic guarantees
  3. What is a Seldonian algorithm?
  4. What is the Seldonian framework?
  5. What is the Seldonian ML Toolkit?
  6. What are some limitations of this software toolkit?

The need for safe and fair machine learning


Intelligent machines are everywhere, ranging from simple data analysis and pattern recognition tools used across the sciences, to complex systems that achieve superhuman performance on various tasks. Ensuring that these machines are well-behaved—that they do not, for example, harm humans or act in a racist or sexist way—is therefore not a hypothetical problem to be dealt with in the future, but a practical one that must be addressed today.

Already, intelligent systems have caused harm. They have exhibited racist, sexist, and otherwise unfair behaviors that could reinforce existing social inequalities [1, 2, 3, 4, 5, 6, 7] and have produced dangerous behaviors [1], including those that have caused harm and death [1, 2, 3].

Safety is of primary importance in established engineering fields, due to historical disasters that motivated and shaped regulations, education, and professional practice. Though safety is of growing interest in the relatively nascent field of artificial intelligence (AI) and the subfield of machine learning (ML), the primary emphasis in these fields remains on increasing capabilities without sufficient concern for risks, and sometimes without proper scientific evaluation [1]. With the rapid increase of AI and ML applications, the safety and fairness of such systems must become a primary focus if we hope to avoid the historical disasters that shaped established engineering fields.

The necessity of probabilistic guarantees


There are two possible types of safety and fairness guarantees: deterministic and probabilistic (also called stochastic). Deterministic guarantees hold with certainty. A deterministic guarantee that an ML system will not give a medical treatment that results in a patient dying means that the ML system will never give a medical treatment that results in a patient dying. As another example, Asimov's three laws of robotics are three proposed deterministic safety constraints for robots.

Unlike deterministic guarantees, probabilistic guarantees only hold with some probability (typically a "high probability"). This high probability is usually written in math as \(1-\delta\), where \(\delta\in(0,1)\) is a (typically small) constant. Common values of \(\delta\) include 0.1, 0.05, and 0.01, resulting in guarantees that hold with probability 0.9, 0.95, and 0.99, respectively. So, a \(1-\delta\) probability guarantee that an ML system will not give a medical treatment that results in a patient dying means that the probability that the ML system gives a medical treatment that results in the patient dying will be at most \(\delta\).

Obviously, we prefer deterministic guarantees over probabilistic ones. However, often deterministic guarantees are not possible, particularly when an ML system must use data when reasoning about a guarantee. To make this point clear, we provide two examples.

  1. Sepsis treatment. Sepsis is a potentially life-threatening condition that arises when the body's response to infection damages its own tissues. It is responsible for roughly one in five deaths worldwide. When a new strategy for treating sepsis is proposed (by a human or a machine), we should ensure that it is safe before it is used. Ideally, we would like a deterministic guarantee that says "If the new strategy is used, fewer people will die from sepsis." However, such a guarantee is not possible. Instead, trials are run using computer simulations, other animals, and eventually small groups of people in controlled scientific studies called clinical trials. In such a scientific study, one group of people would be treated using the new strategy, and another group would be treated using the current strategy. If more people who were treated with the new strategy survive, then we might aim to conclude that the new strategy is better.

    However, we must be careful not to jump to conclusions prematurely. In the United States, clinical trials begin with roughly 20–80 human participants (see "What are the four phases of clinical trials?" here). What if the new strategy "got lucky," and happened to be tested on the people who would have survived even with the older treatment strategy? In this case, even if the new strategy is significantly worse and would result in far more deaths from sepsis if it replaced the current strategy, it would still appear to be better in the initial clinical trial. So, though we have evidence supporting the conclusion that the new strategy is actually better, we cannot yet be certain of this conclusion. If the initial trial is successful, we might conduct trials with more people to gain more certainty and ensure that the new strategy didn't just "get lucky." In the United States, there are four phases of clinical trials that build up to trials with several hundred to about 3,000 people.

    Imagine that the new strategy was again effective in subsequent trials with a few thousand people. We still cannot be completely certain that the new strategy will be better. It could still be that the new strategy again "got lucky," and that all of the people treated with the new strategy would have survived if treated with the old one. However, with so many people in the study, the new strategy would have to have been very lucky! Notice that no matter how many people are treated with the new strategy, we can always make this argument. So, although we can never be completely certain that the new strategy is actually better, as we obtain increasing amounts of data, we can become increasingly certain about our conclusion that it is better. At some point, we are so certain that we are willing to accept the conclusion. This raises the question: how much data do we need (how many people do we need to experiment with) and how large of a difference in survival rate must we see before we can conclude that the new strategy is better with a reasonable amount of certainty?

    This question has been heavily studied by mathematicians and statisticians. Given the results of a (carefully constructed) study, we can use statistical tools to obtain a confidence interval for the percent of people who will survive if the new strategy is used. In this case, a \(1-\delta\) confidence interval \((l,u)\) indicates that with probability of at least \(1-\delta\) the true percent of people who will survive if the new strategy is used is between \(l\) and \(u\) percent. If \(1-\delta\) is sufficiently large and \(l\) is also sufficiently large (e.g., larger than the percent of people who survive when using the old strategy), then we can accept the conclusion that the new strategy is better and that using the new strategy for other people would be a responsible choice. As we obtain more and more data, the width of the confidence interval (that is, \(u-l\)) typically shrinks as we become increasingly certain about the actual percentage of people who will survive if the new strategy is used.

    In conclusion, notice that here a deterministic guarantee is not possible: We cannot know with absolute certainty that the new strategy for treating sepsis will be an improvement upon the old strategy. However, using data and statistical tools, we can characterize our certainty that the new strategy is superior. That is, we can obtain a \(1-\delta\) confidence guarantee that the new strategy is superior, and with enough data, \(1-\delta\) can become large enough that we are willing to trust the conclusion. This is an example of a probabilistic safety guarantee: a \(1-\delta\) confidence guarantee that the new strategy will be safe.

  2. Loan approval. One commonly discussed use of machine learning is to determine which loan applications should be approved. For this application, it is important that machine learning algorithms do not exhibit racist, sexist, or other such discriminatory behavior. For example, a machine learning algorithm that only approves loans for people of one type or which makes more accurate predictions for people of one type might be considered unfair and could reinforce existing social inequalities.

    One common misconception is that machine learning algorithms that are designed to optimize for the accuracy of their predictions would not produce unfair predictions, since they have no incentive to be unfair. This is, unfortunately, not the case. Machine learning algorithms tend to make unfair predictions unless algorithms are specifically designed to ensure that they are in some way "fair." Though a complete description of this issue is beyond the scope of this document, one core underlying problem is that fairness constraints are typically not perfectly aligned with optimizing for accuracy (or any other standard primary objective). As an analogy, asking a machine learning system to maximize some measure of the accuracy of its predictions while ensuring fairness is like asking you to run down the sidewalk as fast as you can while not stepping on any cracks. While you can run fast while dodging cracks, sometimes you need to slightly modify where your foot lands to avoid a crack, resulting in a slight slowdown. Similarly, the machine learning system may need to slightly modify its predictions to remain fair, resulting in a (typically) slight reduction in accuracy. So, just like how you would tend to step on cracks when only told to run as fast as possible, machine learning algorithms tend to produce unfair predictions when only told to maximize the accuracy of their predictions, since in both cases the primary objective (run fast / make accurate predictions) is not perfectly aligned with the constraint (avoid cracks / make fair predictions). A clear and easily reproduced example of how this happens when considering fairness of machine learning algorithms is provided in Section 2 in the supplementary materials of our Science paper. To access this document, go here, click "Open Access Link", then on the left click "Supplementary Material", then under "Resources" click the "Download" button.

    So, for this example we might aim to ensure that the predictions of a machine learning system enforce some notion of fairness. To do so, we must precisely define what it means for predictions to be fair. This has turned out to be an exceptionally difficult task. Not only are there dozens of different definitions of fairness (see this paper for some common definitions from 2018), but often these definitions are conflicting. That is, often it is not possible for any system (human or machine) to simultaneously satisfy two desired definitions of fairness. This is an issue we ran into when using machine learning to predict students' GPAs in college from their application materials. Any system for making these predictions (in the setting that we studied, which included self-reported binary gender) must either A) produce higher predictions on average for students of one gender, or B) tend to overpredict for one gender and underpredict for the other (particularly bad systems could overpredict for both or underpredict for both, but it would still overpredict or underpredict significantly more for one gender). In this case, we must view either (A) or (B) as being acceptable and not unfair, even though our intuition might suggest that both are unfair.

    Before continuing, we want to make one point abundantly clear: We (the authors of the Science paper), and we (the creators of this software toolkit) are not endorsing or promoting a specific definition of fairness or safety for any application. Instead, our goal is to give data scientists the ability to select the definitions of safety and fairness that are appropriate for the tasks they are faced with. When showing how our system can be used, we use examples of possible definitions of safety and fairness, but these are merely illustrative examples. Moreover, they are not examples of what the "right" definition of safety or fairness is for the problem being studied; rather, they are examples of how someone could enforce one definition of safety or fairness if that is the one that they selected. The appropriate definition of fairness for the loan approval application should not be chosen by individual computer scientists, but by a community of social scientists, fair-machine-learning researchers (to provide insight into what is and is not possible), domain experts, representatives of the relevant communities, and perhaps even lawmakers.

    For now, imagine that we aim to ensure that the machine learning system is "fair" in that for people who would actually repay the loan if it were approved, the system is not more likely to reject their application if they are of one type (e.g., one race or gender) than another. At first glance, it might seem like this is something that we could ensure deterministically, for example, by ensuring that the machine learning system cannot look at the applicant's race, gender, or any other protected attribute. However, this is not the case because race and gender influence almost every piece of information about the person in ways that are subtle and challenging to model. For example, race and gender can be correlated with everything from zip code to income to undergraduate institution. Machine learning systems can therefore still produce unfair behavior (with our chosen definition of fairness) even without explicitly considering the applicant's race or gender. In fact, for most fairness definitions it is critical that fair machine learning algorithms have access to protected attributes like race and gender in order to ensure that they are fair!

    How then can we ensure that a loan system is fair? One way is to use available data about whether people repaid loans in the past. We can use our machine learning system to predict whether these people would repay their loans and then compare the system's predictions to what actually happened. If we then only consider the data from people who did repay their loans, we can check how often the system predicts that someone will not repay the loan given that they are of each type of interest (race, gender, etc.). If these rates are significantly different, then we might conclude that the system is unfair.

    However, this runs into the exact same issue we faced in the sepsis example! What if the system appears to be perfectly fair on the data that we use to test it, but this is because it "got lucky" and happened to be shown applicants for which it makes fair predictions? Given enough data, it would have to be extremely lucky, and so we might aim to use enough data to ensure that we are sufficiently certain that the system is actually fair (and not just that it happened to get lucky in terms of the data used to test it). This can be achieved using the same statistical techniques described in the sepsis example, providing a \(1-\delta\) confidence guarantee that the machine learning system is fair. Though we can never be absolutely certain that the system is fair, with sufficient data we should be able to obtain sufficiently large confidence for the machine learning system to be responsibly used in the future.

In summary, most safety and fairness guarantees cannot be ensured deterministically. However, fairness and safety can usually be tested using data. These tests can sometimes be wrong, but the chance that they are wrong tends to shrink as we obtain more and more data. Using statistical techniques, we can quantify the probability that these tests will cause us to draw the wrong conclusion, and so we can obtain probabilistic guarantees about safety and fairness. That is, guarantees that hold with probability at least \(1-\delta\). Returning to our earlier example of Asimov's three laws of robotics, the first law states that "A robot may not injure a human being, or through inaction, allow a human being to come to harm." Notice that this law is impossible for any system to satisfy, as nothing (no human or machine) can be absolutely certain that none of its actions will cause a human to be harmed in the future. Instead, real safety guarantees of this sort must be probabilistic, requiring the robot to have sufficient confidence that its actions will not cause harm to a human.

What is a Seldonian algorithm?


Seldonian algorithms are machine learning algorithms that provide high-confidence guarantees that they will not produce undesirable behavior. To make this statement more precise, we will define notation and then convert the English statement into a mathematical statement.

Notation:

A Seldonian algorithm ensures that for all \(i \in \{1,2,\dotsc,n\}\): $$\Pr(g_i(a(D))\leq 0)\geq 1-\delta_i.$$ That is, a Seldonian algorithm \(a\) ensures that for each of the \(n\) behavioral constraints, the probability that it outputs a solution that produces undesirable behavior as defined by \(g_i\) is at most \(\delta_i\). In other words, a Seldonian algorithm \(a\) returns, with high probability, a solution that does not break any of the behavioral constraints. An algorithm is quasi-Seldonian if it relies on reasonable but possibly false assumptions regarding the data being analyzed. These assumptions often appeal, for instance, to the central limit theorem, common in scientific research. More precisely, Seldonian algorithms often rely on concentration inequalities like Hoeffding's inequality (which makes no distributional assumptions other than boundedness), while quasi-Seldonian algorithms often rely on confidence intervals from Student's \(t\)-test or Efron's bootstrap methods.

As discussed in the next section, the data scientist applying a Seldonian algorithm is free to select the appropriate definition of undesirable behavior for the application at hand. One consequence of giving the data scientist this freedom is that they can ask the impossible. That is, they can ask the algorithm to satisfy constraints that are impossible to satisfy (such as conflicting fairness constraints), or they can ask for very strong and very high-confidence constraints given very little data. In these cases, a Seldonian algorithm needs a way to say, "I cannot do that." This capability is provided by including a special solution, "No Solution Found" (NSF), within \(\Theta\) (the set of possible solutions) and by defining \(g(\text{NSF})=0\) so that it is always safe for a Seldonian algorithm to return NSF, alerting the data scientist that it was unable satisfy the provided constraints.

What is the Seldonian framework?


The Seldonian framework provides guidance for the creation of useful Seldonian algorithms. The most critical points are:

What is the Seldonian ML Toolkit?


We developed the Seldonian Toolkit to provide:

To get started using the Seldonian Toolkit, we recommend starting with the tutorials. These start with how to install the libraries in the Seldonian Toolkit (if you already have Python, it should be a simple pip install command!), and then provide examples of how the libraries can be used to solve real problems of interest.

What are some limitations of this software toolkit?


This toolkit, and Seldonian algorithms in general, have important limitations, several of which are listed below.

« Previous: Home Next: Tutorials »