#  A Causal Perspective on Loan Pricing
Investigating the Impacts of Selection Bias on Identifying Bid-Response
Functions

Christopher Bockel-Rickermann Faculty of Economics and Business, KU Leuven Sam
Verboven Faculteit Economische en Sociale Wetenschappen en Solvay Business
School, Vrije Universiteit Brussel Tim Verdonck Department of Mathematics,
University of Antwerp - imecDepartment of Mathematics, KU Leuven Wouter
Verbeke11footnotemark: 1

(September, 2023)

###### Abstract

In lending, where prices are specific to both customers and products, having a
well-functioning personalized pricing policy in place is essential to
effective business making. Typically, such a policy must be derived from
observational data, which introduces several challenges. While the problem of
“endogeneity” is prominently studied in the established pricing literature,
the problem of selection bias (or, more precisely, bid selection bias) is not.
We take a step towards understanding the effects of selection bias by posing
pricing as a problem of causal inference. Specifically, we consider the
reaction of a customer to price a treatment effect. In our experiments, we
simulate varying levels of selection bias on a semi-synthetic dataset on
mortgage loan applications in Belgium. We investigate the potential of
parametric and nonparametric methods for the identification of individual bid-
response functions. Our results illustrate how conventional methods such as
logistic regression and neural networks suffer adversely from selection bias.
In contrast, we implement state-of-the-art methods from causal machine
learning and show their capability to overcome selection bias in pricing data.
Keywords: Pricing, OR in banking, Bid selection bias, Causal inference

## 1 Introduction

Pricing loans is a challenging task for banks. A pricing policy must take into
account and balance several risks to be profitable. Prices must be both high
enough to account for operating costs and losses and low enough to match price
sensitivities of customers and to be competitive in the overall market. If a
price is too high, customers may reject it and seek a loan at a competitor.
However, if a price is too low, the bank may not turn the loan into a profit
and possibly suffer losses.

As customers and their preferences are heterogeneous, an optimal price in
terms of revenue or profit maximization is a personalized one (Varian, 1989).
In reality, many pricing policies are lacking systematic and data-driven
personalization. Instead, prices are typically derived from rigid pricing
grids that segment customers into large groups. Individual components, such as
a discount, are typically applied at the discretion of a bank clerk
incentivized by corporate policies (Phillips et al., 2015).

Developing a personalized pricing policy to optimize loan prices is
challenging since a bank must know the individual preferences and
characteristics of a customer. Typically, these characteristics, such as price
sensitivity and willingness to pay, are hidden. Banks must assume or
approximate those characteristics to build well-functioning models Phillips
(2021). These approximations prove complicated as they rely on observational
data of past loan negotiations, introducing several challenges: while the
problems of endogeneity and hidden confoundedness are generally prominently
studied in the established pricing literature (Berry, 1994; Villas-Boas and
Winer, 1999), selection bias (Heckman, 1990) is not. Selection bias (or “bid
selection bias”, as in the context of this work) persists in observational
pricing data due to bias in the established pricing policy. Certain customer
groups might receive preferential treatment in accordance with an established
pricing grid or regulatory requirements (Jain et al., 2016), bank clerks might
suffer from unconscious bias in handling customers and applying discounts, and
customer groups might self-select in choosing which financial products to
purchase.

Our work aims to study the impact of selection bias on learning personalized
pricing models from observational data and builds on identifying methodologies
that overcome potential adverse effects of selection bias. In order to do so,
we propose to frame loan pricing as a problem of causal inference and look at
pricing as a case of treatment and effect. The offered loan price, the “bid”,
is considered to be a continuously-valued treatment, whereas the treatment
effect is the probability of a customer accepting this bid, i.e., the “bid
response”. A model of the individual treatment effect, that is, the individual
bid response, can be used to optimize and personalize pricing. Applications
include decision support for bank clerks, data-driven allocation of
personalized prices, and improved customer segmentation in existing pricing
policies.

To study the effects of bid selection bias, we work with a semi-synthetic
dataset created in collaboration with a bank in Belgium. We apply a set of
machine learning techniques, including novel methods from causal machine
learning, to estimate bid-response curves and evaluate their robustness to
varying levels of selection bias in the training data.

To the best of our knowledge, our study is the first of its kind and adds to
the literature in the following ways:

  * •

we frame the pricing problem as a problem of causal inference;

  * •

we showcase the issue of selection bias in observational pricing data and its
impact on decision making;

  * •

we evaluate the robustness of established and novel machine learning methods
against bid selection bias in observational data.

The remainder of our work is organized as follows: in Section 2, we provide an
overview of the established literature on customized pricing. Section 3
defines pricing as a problem of causal inference and discusses reasons for
selection bias, as well as methods for bid-response estimation. Section 4
describes our experimental evaluation, including the generation of our
dataset. We conclude in Section 5, in which we reflect on results and discuss
potential future research.

## 2 Related Work

Customized pricing: Loan pricing is a case of customized pricing (Phillips,
2012, 2013). Contrary to the pricing of uniform goods (see, e.g., Varian,
2014), in customized pricing, neither goods nor prices are homogeneous across
customers (Phillips, 2021). In loan pricing, customized products and prices
can better meet customers’ financing demands and offer banks a way to manage
and mitigate risks. Customization of the product occurs by varying the
duration, amount, and starting principal of the loan. Additionally, there
typically is no price transparency, as customers cannot observe prices offered
to other individuals. This changes the objective from setting a single best
price for a customer group to setting the optimal price per individual. As a
result, customized pricing is often considered an optimization problem (Oliver
and Oliver, 2014; Sundararajan et al., 2011; Phillips, 2012) that aims to
optimize a certain business objective. We summarize the customized pricing
process as such: after a customer has approached a seller, they request a
price for a product, commonly referred to as a bid. The seller will try to
determine the bid that maximizes a certain objective, for example, revenue or
profit generation per customer, which is facilitated by estimating the
probability that a bid is accepted. The probability of acceptance as a
function of the height of the bid is referred to as the bid-response function.
It differs from the demand curve in microeconomics by representing a
probability concerning a single individual instead of an aggregated demand
over a customer group. Hereby, customized pricing is related to the wider
field of market response modeling, to which an introduction can be found in,
e.g., Hanssens et al. (2003). For the case of loans, we describe an exemplary
loan pricing and sales process in Section 3.1.

Endogeneity in pricing: Traditionally, estimation of the bid response is
approached with parametric and semiparametric methods, assuming a certain
functional form of the bid response (Phillips, 2021; van Ryzin, 2012). This
estimation is subject to various challenges in terms of, for example, the
available information and infrastructure, model complexity, and legal and
regulatory requirements (Phillips, 2012). The most prominent challenge
discussed in the established pricing literature is “endogeneity” in
observational training data (or “hidden confoundedness” in the wider sense).
Endogeneity is present if variables critical to explaining customer
preferences or their actions are unobserved (or not available for modeling)
(Phillips et al., 2012). Reasons for endogeneity are plentiful, stemming, for
example, from interactions between customers and sales representatives that
are not or insufficiently recorded, due to internal and external regulations.
There is a wide body of literature on identifying and handling endogeneity,
both in pricing and more generally in economics and statistics (see, e.g.,
Heckman, 1978; Newey, 1987; Rivers and Vuong, 1988; Kuksov and Villas-Boas,
2008). De facto standard methods are instrumental variable regression (e.g.,
Hausman et al., 2012), and BLP procedures named after the authors of Berry et
al. (1995). More recently, machine learning has been proposed to finding bid-
response models (Lawrence, 2003; Agrawal and Ferguson, 2007; Arevalillo, 2019;
Guelman and Guillén, 2014).

Selection bias in pricing: The impact of selection bias (cf. Section 3.2) on
pricing has received little attention in the literature. There is, however, an
established body of research from other domains on the issue, such as medicine
(Berrevoets et al., 2020), economics (Varian, 2016), market modeling
(Ferkingstad et al., 2011), and maintenance (Vanderschueren et al., 2023).

## 3 Methodology

To showcase the impact of selection bias on customized pricing, we propose a
methodology in four steps. In Section 3.1, we describe the general loan
pricing and sales process and frame it as a problem of causal inference. In
Section 3.2, we build on this framing and introduce selection bias in
observational data and its relevance towards pricing. In Section 3.3, we
discuss the necessary assumptions for the causal identification of bid
responses. Finally, in Section 3.4, we present the methods that we apply to
learn bid-response functions from observational data. Our experimental setup
and results follow in Section 4.

### 3.1 Formalizing the loan pricing and sales process

The general process of a customer taking out a loan is formalized as follows:

  * •

first, a customer approaches a finite number of banks to negotiate a loan;

  * •

second, a bank obtains information about the customer and evaluates whether
and at what conditions it wants to grant the loan;

  * •

third, each bank either rejects the customer or provides loan conditions,
including a prospective price, i.e., the “bid”;

  * •

fourth and finally, the customer evaluates the offers received from the banks
and decides whether to accept any of them, and if so, which. A round of
negotiations might follow after the initial bid is placed. For the purpose of
this study, we do not investigate any negotiations but focus on the first
response of a customer to the first bid only.

For the purpose of our study, we simplify the process and look at it from the
perspective of a single bank. The process reduces to three steps: a customer
approaches the bank, the bank provides a loan offer including a bid for the
price of the loan, and finally a customer decides on acceptance or refusal of
the offer. The simplified process is depicted in Figure 1.

Figure 1: Simplified loan pricing process

Loan price decomposition: In practice, a loan price often consists of multiple
parts, such as a base price and a customer-specific component. The base price
serves to cover risks and costs to the bank and is determined via risk-based
pricing. For risk-based pricing, banks cluster customers into a finite number
of risk bands and determine a price per risk band that covers running costs of
the bank, as well as expected losses (Phillips, 2013). Risk models are
typically proprietary, resulting in price dispersion in the market. The
individual component to a loan price is given by a bank clerk during the sales
process based on their information and personal assessment of the customer.
Discounts might be driven by incentive schemes resulting from corporate
strategy. The impact of such incentive schemes (Garrow et al., 2006; Phillips
et al., 2015) and the risk of principal-agent problems (Berhold, 1971; Ross,
1973) is out of scope in this work. Additionally, we do not take into account
the impacts of negotiations between customers and bank clerks that might
occur.

Loan pricing as a problem of causal inference: We assume that a bank has
records on their historical sales processes available, which are formalized as
such: after a customer $i$ has decided about a specific loan offer, the result
is summarized as a tuple $(\mathbf{x}_{i},b_{i,f},y_{i,f})$. All values are
realizations of random variables $(\mathbf{X},B,Y)$.
$\mathbf{X}\in\mathbb{R}^{d}$ describes the characteristics of the customer,
as well as the specifications of the loan, excluding the bid, and information
on competitor offers111We assume that all information relevant to the customer
decision is known and in $\mathbf{X}$ to satisfy necessary assumptions (cf.
Section 3.3).. $B\in\mathbb{R}$ is the bid made to the customer for the loan
price, i.e., the credit rate in percent of interest per year. $Y\in\\{0,1\\}$
is the decision to accept the offer and take up the loan or not. We assume $Y$
to be a Bernoulli random variable that is dependent on $P\in[0,1]$, the
probability of accepting a loan offer; hence, $Y\sim Bernoulli(P)$.

In framing loan pricing as a problem of causal inference, we adopt the Neyman-
Rubin potential outcome framework (Rubin, 2004, 2005) and assume that for
every realization of a bid $b$ we find a potential outcome $P(b)$ of the
probability of accepting the loan offer and a realization $Y(b)\in\\{0,1\\}$.
All observed data and corresponding probabilities are referred to as
“factual”, including the factual bid $B_{f}$, the factual acceptance
probability $P_{f}=P(B_{f})$, and the factual acceptance $Y_{f}\sim
Bernoulli(P_{f})$. Any potential outcomes to unobserved combinations of a
customer characteristic and a bid are referred to as “counterfactual
outcomes”.

Bid response as a treatment effect: For our study, we assume that a bank is
interested in identifying the individual response of a customer to a certain
bid conditional on the customer’s characteristics and the loan they have
applied for. Such a model could be used for data-driven bid allocations,
improved customer segmentation for risk-based pricing, or to support bank
clerks in defining the optimal discretionary discount to give to a customer to
make a winning bid. To win a customer, two requirements must be met: on the
one hand, a bid cannot exceed the overall willingness-to-pay of the customer,
that is, even without competition, a customer is not willing to pay any price
for the loan. On the other hand, the loan conditions offered (including the
bid) must be more favorable to the customer than those of any of the other
competing banks. We note that there might be situations in which a customer
might not just pick a bank based on loan conditions but based on personal
relations or past experiences. Modeling such a behavior is out of the scope in
our study.

In our experiments, we aim to find an unbiased estimate of the individual bid-
response function, i.e., the probability of accepting a loan conditional on
the bid and customer characteristics:

$\mu(b,\mathbf{x})=\mathbb{E}\left[P(b)|\mathbf{X}=\mathbf{x}\right]$ (1)

To evaluate how a bank could use information about $\mu(b,\mathbf{x})$, we
assume that a bank wants to determine the optimal bid $b^{*}_{i}$ per customer
that maximizes the expected revenue from the loan pricing and sales process.
We expect the revenue $R$ from a loan offer to be proportional to both the
height of the bid $b$ and the decision to take out the loan with respect to
the bid $Y(b)$:

$R(b)\sim b*Y(b)$ (2)

The optimal bid $b_{i}^{*}$ for an individual $i$ is defined as the bid that
maximizes the expected revenue for the customer characteristics
$\mathbf{x}_{i}$:

$\begin{split}b^{*}_{i}&=\underset{b}{\arg\max}\text{
}\mathbb{E}\left[R(b)|\mathbf{X}=\mathbf{x}_{i}\right]\\\
&=\underset{b}{\arg\max}\text{ }b*\mu(b,\mathbf{x}_{i})\end{split}$ (3)

Our formalization of the loan pricing and sales process makes two
simplifications that we want to motivate: first, in reality, a bank is
interested in profit over revenue maximization. Yet, to maximize profit,
further assessments are needed, such as those of risk. These assessments are
beyond the scope of this work. In addition, the bid response might be a
component of assessing risk, thereby motivating this simplification. Second,
we do not take loan negotiation rounds into account. In several markets, loan
pricing and sales processes involve multiple rounds of iterative bidding. We
simplify this process and assume that only one bid is made by the bank, as
stated before.

### 3.2 Selection bias

We are interested in learning $\mu(b,\mathbf{x})$ from observational data.
This, in itself, is an intricate task, as for every observation, one observes
the outcome of a loan pricing and sales process to only the factual bid
$b_{f}$ and not to any other. This is known as the “fundamental problem of
causal inference” (Holland, 1986). Furthermore, for a single customer, there
is only a small number of observations available, as a single individual takes
out only a low number of loans in their lifetime and not necessarily all at
the same bank.

The task is further complicated as the observational data that can be used to
learn $\mu$ are expected to be collected under a specific pricing policy, in
contrast to data collected using predefined experiments, for example,
randomized controlled trials (Rubin, 1974; Angrist and Pischke, 2009; Deaton
and Cartwright, 2018). This established pricing policy introduces selection
bias in the data. Selection bias describes the relationship between the
factually assigned bid (or any intervention more generally) and the
pretreatment covariates of an observation. Figure 2 shows the dependency of
the factual bid and the pretreatment covariates of an observation, as assumed
in the remainder of this manuscript. Running randomized control trials in loan
pricing is infeasible, for example, due to regulation, compliance, ethical
concerns, and costs.

Figure 2: DAG representing the causal dependencies between the variables in
the loan pricing and sales process

The problem of learning effects of an intervention under the presence of
selection bias has been studied for both the case of binary interventions
(Rosenbaum and Rubin, 1983, 1984; Yoon et al., 2018) and continuously-valued
interventions (Imbens, 2000; Imai and Van Dyk, 2004; Hirano and Imbens, 2004;
Bica et al., 2020). Adverse effects of selection bias on traditional
approaches to estimating intervention effects have been studied across fields
(see, e.g., Schwab et al., 2020; Vanderschueren et al., 2023).

We elaborate on three exemplary reasons for bid selection bias in pricing
data:

  1. 1.

Loan offers were made according to an established pricing policy. Hence, some
customer groups are more prone to being assigned a higher or lower bid than
others.

  2. 2.

Bank clerks might have suffered from implicit stereotypes, either offering
higher discretionary discounts to some or even denying loans to certain
customer groups (Cozarenco and Szafarz, 2018).

  3. 3.

Customers might have suffered from various types of self selection, e.g.,
driven by socioeconomic status. Customer groups may have a preference for
certain loan products over others. Other customer groups might not have
applied for a specific loan at all.

### 3.3 Assumptions

In the literature, we find three assumptions that typically underly the
estimation of intervention effects from observational data (Imbens, 2000;
Lechner, 2001). We will discuss these assumptions and their applicability in
pricing:

######  Assumption 1.

Overlap: $\forall b\in\mathbb{R}:\forall\mathbf{x}\in\mathbb{R}^{d}\text{ with
}\mathbb{P}(\mathbf{x})>0:0<\mathbb{P}(b|\mathbf{x})<1$

Overlap requires that for every possible customer characteristic $\mathbf{x}$,
every possible bid $b$ has a nonzero possibility of being offered. In reality,
an established pricing policy might assign specific bids with little to no
deviation to customer groups, resulting in a violation of the overlap
assumption. Overlap might be ensured, however, due to bank clerks assigning
discretionary discounts of sufficient size to their customers. The dispersion
of bids ensures that the true bid response can be estimated for all possible
bid levels for a certain customer.

######  Assumption 2.

Consistency:
$\forall\mathbf{x}\in\mathbb{R}^{d}:Y_{f}=(Y|\mathbf{X}=\mathbf{x})$

Consistency means that the observed outcome is the true potential outcome for
the applied treatment. As Vanderschueren et al. (2023) note, this appears to
be a straightforward assumption. To ensure consistency in pricing, we must
carefully observe any changes in economic sentiment and correct or retrain
models if, e.g., prime rates change. For example, if monetary policy tightens,
the response of a customer to a certain bid $b$ will likely change as well.
For our experiments, we assume that the economic sentiment is stable and that
consistency can be assumed.

######  Assumption 3.

Unconfoundedness: $\left(P(b)|b\in\mathbb{R}\right)\perp\\!\\!\\!\\!\perp
B_{f}|\mathbf{X}$

Unconfoundedness requires that all information that determined the factually
assigned bid is known and available for modeling. In pricing, this assumption
is easily violated, e.g., due to unrecorded interactions between bank clerks
and customers (Phillips et al., 2012), legal bounds on the use of personal
data, and missing information about competitor offers, commonly referred to as
“competitive uncertainty”.

For the purpose of our work, we do not further evaluate the impacts of
violating these assumptions on estimating bid responses. Instead, we assume
the assumptions are met, to isolate the effect of selection bias.

### 3.4 Predicting bid-response curves

We evaluate a total of seven methods to model individual bid responses,
covering parametric models, nonparametric models, and causal and noncausal
methods, as depicted in Table 1. Each method is discussed further below:

Table 1: Models for bid-response prediction

Method | Parametric | Causal
---|---|---
Naïve pricing | n.a. |
Logistic regression |  |
Random Forest |  |
MLP |  |
HIE |  |
VCNets |  |
DRNets |  |

n.a.: not applicable

We consider four noncausal methods for bid-response learning to test their
robustness to selection bias and appropriateness to modeling bid-response
functions: first, naïve pricing is a strategy in which we do not estimate any
dose response but assume that the best bid $b^{*}$ per customer is the
factually assigned bid under the established pricing policy. Second, logistic
regression is a classification method that is widely adopted across scientific
domains and industry applications, such as fraud detection, credit risk
modeling, and churn prediction. It is also the de facto standard in estimating
bid-response models (van Ryzin, 2012) due to its well-suited hypothesis space.
Logistic regression is fully parametric and easy to interpret. Third, we
consider a random forest classifier (Breiman, 2001). The random forest
classifier combines multiple decision trees into an ensemble to improve the
accuracy and reduce the variance of the final model. Random forests can handle
a variety of input variables and are robust to overfitting. Random forests,
and tree-based methods more generally, have found wide adoption in industry
applications of machine learning, motivating our choice to adopt them in our
experiments. Fourth, we fit an artificial neural network, i.e., a multilayer
perceptron (MLP). MLPs are universal function approximators (Hornik et al.,
1989) and are powerful methods for a multitude of prediction tasks, making
them an important benchmark for our experiments.

(a) DRNets

(b) VCNets

Figure 3: Network architectures

Additionally, we implement three causal methods that are meant to handle
selection bias by design, expecting that these methods will show improved
robustness to increasing levels of bid selection bias in pricing data. First,
we implement the Hirano Imbens estimator (“HIE”, Hirano and Imbens, 2004),
which builds on the idea of the generalized propensity score, as proposed by
Imbens (2000). The HIE is an imputation-type estimator. Initially, a model of
the treatment assignment is built. Based on that model, the propensity for
every observation and their factual bid is calculated. Finally, the bid
response is modeled as a function of the bid level and the propensity score.
We follow Schwab et al. (2020) and Bica et al. (2020) in considering a linear
relationship between bid and pretreatment covariates with normally distributed
error terms, as well as a logistic regression on the second-order polynomial
of bid level and propensity score as the final model of the bid response.
Second, we implement DRNets (Schwab et al., 2020). DRNet extends TARNet
(Shalit et al., 2017) for estimating effects of binary interventions to the
continuous case, by training a neural network with $\rho$ individual
prediction heads for observations with different levels of a continuous
intervention. DRNets learn a shared representation of the training
observations, which implicitly have a regularizing effect on overfitting the
training data. Third, we implement VCNets. Nie et al. (2021) propose VCNets as
an extension to DRNets, by proposing a varying coefficient neural network,
where coefficients of the neural network are a function of the continuously
valued intervention, enforcing a continuous dose response function, over the
tendency of DRNets to estimate discontinuous functions. We use the
architecture proposed in Nie et al. (2021). We illustrate the architectures of
DRNets and VCNets in Figure 3. Finally, we would like to motivate our choice
of not including SCIGAN (Bica et al., 2020), another powerful causal machine
learning method for the estimation of continuously valued interventions, in
the experiments. Even though SCIGAN has shown high performance in previous
studies (Bica et al., 2020; Vanderschueren et al., 2023), the set-up of using
generative models for the generation of counterfactuals to learn unbiased
responses is not suited for the case of pricing, as the training data are not
continuous. In our own experiments, SCIGAN performed worse than both DRNets
and all other methods considered.

## 4 Experimental Evaluation

### 4.1 Data

We use a real-life dataset on mortgage loan offers from a bank in Belgium. The
data cover over 12,000 loan offers. Each offer relates to precisely one
customer. In collaboration with the bank, we selected and processed an
anonymized subset of 13 variables for training. The selection of variables was
based on their availability for all customers to ensure no missing data, an
expert assessment of their relevance for estimating price sensitivity.
Categorical variables have been dummy encoded, and all variables have been
standardized. These variables include information on terms and conditions of
the loan (5 variables), financial background of the customer (3 variables),
the socioeconomic background of the customer (4 variables), and the existing
relationship of the customer with the bank (1 variable). The precise
definition of the variables is confidential information that cannot be shared.

As highlighted in Section 3.1, evaluating the correctness of predicted
potential outcomes is challenging. First, we never observe the true bid-
response curve but only the outcome to one bid per customer due to the
fundamental problem of causal inference. Second, estimating the overall
effectiveness of one pricing policy over another over a group of customers is
complicated due to the observational data. Methods designed to estimate such
an aggregate effect, such as the Qini-coefficient (Radcliffe, 2007), require
randomized controlled trial (RCT) data (Angrist and Pischke, 2009) and are
negatively affected by selection bias. Due to compliance, regulation, and the
risks of losses and reputation, such trials cannot be implemented reasonably
in many real-life settings, including banking operations.

To overcome this issue, we make use of semisynthetic data, a common approach
in evaluating potential outcome estimation and to avoid the fundamental
problem of causal inference (Yoon et al., 2018; Berrevoets et al., 2020;
Schwab et al., 2020; Qian et al., 2023). In such a setup, typically, the
explanatory variables in the data are kept as-is, whereas both treatment
variables $B$ and outcomes $P$ and $Y$ are generated from a well-defined and
known ground truth to control factors such as the strength of the selection
bias and the functional form of the potential outcome in relation to
$\mathbf{X}$. We deem the use of semisynthetic data in pricing as particularly
interesting to assess the impacts of selection bias on modeling bid responses.

In the following two subsections, we discuss how we model the underlying
ground-truth bid response (Section 4.1.1) and assignment of factual bids
(Section 4.1.2). For our experiments, we use 70% of the total data for
training, 10% for validation and parameter tuning and 20% for testing.

####  4.1.1 Ground-truth bid response

Based on van Ryzin (2012) and Phillips (2021), we define four requirements
with regards to a synthetic ground-truth bid-response function. In our
experiments, we standardize bids to be in the domain $[0,1]$, with $b=0$ the
lowest observed bid and $b=1$ the highest observed bid:

  * •

At $b=0$, every customer has a unique probability of acceptance,
$p(0,\mathbf{x})\leq 1$.
The probability is $p\leq 1$ but not $p=1$, as even for the lowest observed
bid, a customer might consider the bid to be too high according to their
individual preferences or reject a bid based on their customer experience
during the loan pricing and sales process.

  * •

When $b$ increases, the probability of accepting a loan converges but not
necessarily towards zero, i.e., $p(\infty,\mathbf{x})\geq 0$.
The probability does not necessarily converge to zero, as even for the highest
observed bid, a customer might take out a loan.

  * •

The price sensitivity, that is, $\frac{\text{d}p(b,\mathbf{x})}{\text{d}b}$,
is heterogeneous across customers.
Ceteris paribus, two customers might react differently in terms of their bid
response to an increase of the bid.

  * •

The probability of loan acceptance is monotonically decreasing for an
increasing value of the bid, $b$.

Furthermore, we consider two different ground-truth bid-response curves: a
Richards curve and a stacked sigmoid curve (Figure 4 provides a comparative
visualization of both curves).

(a) Richards curves

(b) Stacked sigmoid curves

Figure 4: Illustrative visualization of bid-response curves

Richards curve: The generalized logistic function or Richards curve (Richards,
1959) is defined as:

$p(b,\mathbf{x})_{RC}=(1-\alpha)-\frac{\beta-\alpha}{1+e^{-\gamma*(\delta-b)}}+\epsilon$
(4)

with $1-\alpha$, the left asymptote (or maximum level of acceptance at the
lowest observed bid $b_{min}$), $1-\beta$, the right asymptote (or minimum
level of acceptance at the highest observed price $b_{max}$), $\gamma$ the
steepness of the curve and $\delta$ the position of the turning point of the
curve. The logistic function has seen various applications across domains and
is often used as a modeling tool for classification tasks (Cramer, 2002).

To condition $p(b,\mathbf{x})_{RC}$ on individual customer characteristics, we
parameterize the function by means of linear combinations of the input
features in $\mathbf{x}$ via:

$\displaystyle\alpha$
$\displaystyle=(0.2\mathbf{w}_{1}^{\intercal}\mathbf{x})$ (5)
$\displaystyle\beta$
$\displaystyle=(0.8+0.2(\mathbf{w}_{2}^{\intercal}\mathbf{x}))$
$\displaystyle\gamma$
$\displaystyle=(0.5+5(\mathbf{w}_{3}^{\intercal}\mathbf{x}))$
$\displaystyle\delta$ $\displaystyle=(\mathbf{w}_{4}^{\intercal}\mathbf{x})$
$\displaystyle\epsilon$ $\displaystyle\sim\mathcal{N}(0,0.1)$

For all $i\in\\{1,2,3,4\\}$, $\mathbf{w}_{i}\sim\mathcal{U}((0,1)^{d\times
1})$, as proposed in Bica et al. (2020).

Stacked sigmoid: To test the performance of models in the case of highly
nonlinear bid-response curves, we evaluate them considering the bid response
as a mixture of two sigmoid curves. We define:

$\displaystyle
p(b,\mathbf{x})_{SS}=\alpha+\beta*\sigma(P/\gamma)+(1-\alpha-\beta)*\sigma((b-\delta)/(1-\delta))+\epsilon$
(6)

$\sigma(x)$ is defined as a sigmoid curve:

$\sigma(x)=1-\frac{1}{1+e^{-20*(0.5-x)}}$ (7)

As before, we condition $p(b,\mathbf{x})_{SS}$ on individual customer
characteristics via:

$\displaystyle\alpha$
$\displaystyle=(0.2\mathbf{w}_{1}^{\intercal}\mathbf{x})$ (8)
$\displaystyle\beta$ $\displaystyle=(0.8\mathbf{w}_{2}^{\intercal}\mathbf{x})$
$\displaystyle\gamma$ $\displaystyle=\mathbf{w}_{3}^{\intercal}\mathbf{x}$
$\displaystyle\delta$ $\displaystyle=\mathbf{w}_{4}^{\intercal}\mathbf{x}$
$\displaystyle\epsilon$ $\displaystyle\sim\mathcal{N}(0,0.1)$

For all $i\in\\{1,2,3,4\\}$, $\mathbf{w}_{i}\sim\mathcal{U}((0,1)^{d\times
1})$.

####  4.1.2 Bid assignment

Next to the simulation of the bid response, we control the levels of selection
bias by sampling the factual bid $b_{f}$ from a beta distribution. The
approach is motivated and detailed in Bica et al. (2020). We model varying
levels of selection bias by assigning to every observation $\mathbf{x}$ a
factual bid:

$b_{f}\sim Beta\left(\theta+1,\frac{\theta}{\phi+(1-\theta)}\right)$ (9)

where $\theta\geq 1$ controls the level of selection bias. $\theta=0$ results
in no selection bias. $\mu$ defines the modal rate, i.e., the most likely
assigned price, and is defined as

$\phi=\mathbf{w}_{5}^{\intercal}\mathbf{X}$ (10)

with $\mathbf{w}_{5}\sim\mathcal{U}((0,1)^{d\times 1})$. Hence, the
distribution of the assigned bids in the dataset depends on $\mathbf{X}$,
thereby introducing selection bias. Different levels of bias are illustrated
in Figure 5.

Finally, in addition to directly controlling the level of selection bias, we
use the observed bid levels from the original dataset to assess the impact of
levels of bid selection bias observed in real-world scenarios.

(a) $\theta=0$

(b) $\theta=5$

(c) $\theta=20$

Figure 5: Visualization of different levels of selection bias $\theta$ for
mode $\mu=0.25$

### 4.2 Evaluation metrics

We evaluate our method using three performance metrics:

Mean Integrated Squared Error (MISE): The MISE evaluates the potential of a
method to predict the true bid response per customer along all observed bid
levels:

$\text{MISE}=\frac{1}{n}\sum_{i=1}^{n}\int_{b_{min}}^{b_{max}}\left(\mu(b,\mathbf{x}_{i})-\hat{\mu}(b,\mathbf{x}_{i})\right)^{2}db$
(11)

with $n$ the number of test observations, $b_{min}$ the lowest bid, and
$b_{max}$ the highest bid observed in the training data222Due to the overlap
assumption (cf. Section 3.3), we only evaluate bids between $b_{min}$ and
$b_{max}$. The MISE was initially proposed for individual continuous treatment
effect estimation by Schwab et al. (2020)333In addition to to evaluating the
bid response, we evaluate the MISE over the expected revenue in accordance
with Equation 3, further referred to as the MISE R. The results can be found
in the Appendix..

Policy error (PE): The PE evaluates how well a method is able to identify the
optimal bid $b^{*}$ and was proposed by Schwab et al. (2020):

$\text{PE}=\frac{1}{n}\sum_{i=1}^{n}\left(b_{i}^{*}-\hat{b_{i}^{*}}\right)^{2}$
(12)

with $n$ the number of test observations, $b_{i}^{*}$ the actually optimal bid
of observation $i$, and $\hat{b_{i}^{*}}$ the estimated optimal bid.

Brier score (BS): Finally, we evaluate each model in terms of their Brier
score (Brier et al., 1950) to assess the potential to estimate the factual
outcome of a loan pricing and sales process. The Brier score informs about a
model’s capacity to estimate the factual response:

$\text{BS}=\frac{1}{n}\sum_{i=1}^{n}\left(y_{i,f}-\hat{\mu}(b_{i,f},\mathbf{x}_{i})\right)^{2}$
(13)

with $y_{i,f}$ the factual outcome of observation $i$ and
$\hat{\mu}(b_{i,f},\mathbf{x}_{i}$ the estimated probability of bid acceptance
of observation $i$ for their factually assigned bid.

### 4.3 Implementation

We implement our experiments in Python 3.9. Neural network-based methods are
implemented in PyTorch (Paszke et al., 2017). Random forest models and
logistic regression are implemented using the SciKit-Learn library (Pedregosa
et al., 2011). HIE is implemented using the statsmodels library (Seabold and
Perktold, 2010). For VCNets, we use the implementation provided in the
original work of Nie et al. (2021). For a list of hyperparameters used to
train each method, we refer to Section B in the Appendix. All code used for
this project is available online at:

$\texttt{https://github.com/christopher-br/Causal\\_Pricing}.$

### 4.4 Experimental results

We apply our data generating process to the data presented in Section 4.1. We
run the process a total of 10 times for each of seven bias strengths
increasing from no bias ($\theta=0$) to heavy bias ($\theta=20)$, as well as
the factual bids. The stated performance metrics are averaged over each of the
10 randomly initialized runs.

The metrics introduced in Section 4.2 enable evaluation of each model in terms
of its capacity to predict the bid response along all observed bids (via the
MISE metric) and its appropriateness for operational decision-making to set an
optimal bid $b^{*}$ (via the PE metric). The Brier score, moreover, evaluates
the ability to estimate the factual outcome of an observation.

Table 2: Mean Integrated Squared Error (MISE) on Richards curve

Ground truth: Richards curve
---
| Bias strength | True bids
2-8 |  |  |  |  |  |  |
Model | 0.0 | 2.5 | 5.0 | 7.5 | 10.0 | 15.0 | 20.0 |
Naïve pricing | n.a. | n.a. | n.a. | n.a. | n.a. | n.a. | n.a. | n.a.
Logistic Regression | 0.115 | 0.095 | 0.096 | 0.097 | 0.100 | 0.104 | 0.112 | 0.141
Random Forest | 0.083 | 0.105 | 0.122 | 0.135 | 0.143 | 0.152 | 0.170 | 0.164
MLP | 0.056 | 0.062 | 0.058 | 0.062 | 0.066 | 0.060 | 0.064 | 0.068
|  |  |  |  |  |  |  |
HIE | 0.118 | 0.120 | 0.122 | 0.124 | 0.124 | 0.125 | 0.126 | 0.126
DRNets | 0.076 | 0.082 | 0.117 | 0.117 | 0.111 | 0.118 | 0.140 | 0.111
VCNets | 0.088 | 0.082 | 0.084 | 0.092 | 0.100 | 0.104 | 0.114 | 0.112

n.a.: not applicable

Note that the stated performances depend on both our data generation process
(cf. Section 4.1) and the operational objective we have set (cf. Section 3.1).

Dose response prediction (MISE, Tables 2 and 3): If the true dose-response
function assumes the shape of a Richards curve (cf. Table 2), the standard
neural network (MLP) achieves the best performance. Second best are standard
logistic regression and VCNets. Contrarily to what we had initially assumed,
logistic regression and the MLP are seemingly least affected by the increase
in selection bias, whereas, e.g., DRNets (a causal method) sees an increase of
almost 100% in MISE from no bias to the strongest bias.

The strong performance of logistic regression is likely explained by its
hypothesis space being closely related to the ground-truth bid response in the
simulation. As the hypothesis spaces are comparable, standard logistic
regression is likely able to find a well-performing model by averaging over
the observed data. Likewise, DRNet is not able to adequately fit the dose
responses. We relate this to the criticism of Nie et al. (2021) on DRNets
being prone to fitting discontinuous functions due to estimating separate head
networks for different bid levels. This can explain why VCNets improve upon
DRNets in the case of the Richard’s curve, as their estimated bid-response
curve is continuous. HIE does not improve upon the nonparametric causal
methods, which might be due to the functional form chosen for modeling the
treatment assignment or bid response.

Table 3: Mean Integrated Squared Error (MISE) on stacked sigmoid

Ground truth: Stacked sigmoid
---
| Bias strength | True bids
2-8 |  |  |  |  |  |  |
Model | 0.0 | 2.5 | 5.0 | 7.5 | 10.0 | 15.0 | 20.0 |
Naïve pricing | n.a. | n.a. | n.a. | n.a. | n.a. | n.a. | n.a. | n.a.
Logistic Regression | 0.110 | 0.125 | 0.134 | 0.143 | 0.147 | 0.154 | 0.155 | 0.119
Random Forest | 0.088 | 0.128 | 0.151 | 0.170 | 0.174 | 0.186 | 0.196 | 0.196
MLP | 0.059 | 0.073 | 0.100 | 0.110 | 0.119 | 0.135 | 0.147 | 0.132
|  |  |  |  |  |  |  |
HIE | 0.087 | 0.101 | 0.109 | 0.122 | 0.121 | 0.149 | 0.157 | 0.176
DRNets | 0.075 | 0.080 | 0.098 | 0.093 | 0.115 | 0.128 | 0.109 | 0.103
VCNets | 0.099 | 0.111 | 0.136 | 0.150 | 0.156 | 0.172 | 0.178 | 0.120

n.a.: not applicable

If we assume higher degrees of nonlinearity in the dose response, i.e., in the
case of a stacked sigmoid ground truth (cf. Table 3), we observe an
increasingly adverse effect of selection bias on estimating the bid response.
The logistic regression model is not able to model the functional shape of the
bid response with an increasing MISE for higher levels of selection bias. The
random forest classifier is again most affected by selection bias, performing
worst of the methods we have applied. As with the Richard’s curve, the MLP
achieves superior performance when no selection bias is present. This time,
when bias increases, the MLP is significantly affected by the selection bias
in the data. In this setting, DRNets exceed the performance of other methods,
generating second-best results for low levels of bias and achieving best
results for bias levels larger than $\theta=2.5$, as well as for the bid
levels observed in the original dataset. DRNets even outperform VCNets,
indicating their applicability to causal effect estimation when the training
data are binary. VCNets appear to be not well suited in these kinds of
settings, as soon as there is a larger degree of nonlinear relations in the
data.

Optimal bid prediction (PE, Tables A1 and A2): In terms of policy error, we
observe similar results as with the MISE. If the true dose response is a
Richards curve (cf. Tabel A1), the best-performing models in terms of PE are
the MLP and logistic regression. The added flexibility of nonparametric
methods, or the use of causal methods, is not sufficient to outperform these
two baseline approaches. Again, the method seemingly most affected by
selection bias is the random forest classifier.

With increased nonlinearity, the causal methods again score better and best.
For moderate levels of bias, VCNets outperform DRNets, likely due to their
continuous estimate of the bid response over the discountinuous function of
DRNets. If the bias increases further, this benefit is not sufficient to
overcome the performance of DRNets, seemingly a more robust estimator.

Factual outcome estimation (BS, Tables 4 and A3): Evaluating each of the
methods in terms of the Brier score illustrates the need to look at pricing
from a causal perspective. If models are solely tested on their predictive
performance within the established pricing mechanism, the results are robust
across all levels of selection bias. Most noteworthy, the random forest
classifier achieves second-best performance under the highest level of
selection bias (cf. Table 4), even though it achieves the lowest performance
in terms of MISE and PE. This finding stresses that the Brier score cannot be
used to evaluate how well a pricing model can generalize across bid levels,
i.e., its generalization power. Hence, testing and selecting models based on
the Brier score might even introduce vicious cycles (see, e.g., Mansoury et
al., 2020; Adam et al., 2020), an important threat that must be further
investigated in the case of banking and lending operations.

Table 4: Brier score (BS) on Richards curve

Ground truth: Richards curve
---
| Bias strength | True bids
2-8 |  |  |  |  |  |  |
Model | 0.0 | 2.5 | 5.0 | 7.5 | 10.0 | 15.0 | 20.0 |
Naïve pricing | n.a. | n.a. | n.a. | n.a. | n.a. | n.a. | n.a. | n.a.
Logistic Regression | 0.355 | 0.366 | 0.371 | 0.377 | 0.372 | 0.372 | 0.372 | 0.342
Random Forest | 0.345 | 0.362 | 0.367 | 0.375 | 0.370 | 0.368 | 0.368 | 0.337
MLP | 0.342 | 0.356 | 0.362 | 0.369 | 0.362 | 0.362 | 0.362 | 0.334
|  |  |  |  |  |  |  |
HIE | 0.356 | 0.381 | 0.389 | 0.396 | 0.394 | 0.392 | 0.389 | 0.345
DRNets | 0.345 | 0.359 | 0.366 | 0.373 | 0.368 | 0.367 | 0.369 | 0.337
VCNets | 0.347 | 0.362 | 0.367 | 0.374 | 0.369 | 0.368 | 0.369 | 0.341

n.a.: not applicable

## 5 Conclusion

In this paper, we explore the use of (causal) machine learning to estimate
models of individual bid-response curves from observational loan pricing data.
We investigate the adverse effects of bid selection bias. In a series of
experiments, we evaluate the impact of varying levels of bid selection bias
using a semisynthetic dataset on mortgage loan applications and test several
data-driven approaches in learning individual bid-response models. Thereby, we
frame pricing as problem of causal inference and, more specifically, of
individual treatment effect estimation.

The presented results show that ensuring robustness to bid selection bias is
crucial in developing a data-driven pricing solution, which potentially is an
overlooked issue and threat both in literature and industry. Failing to adjust
for selection bias may significantly impact bid-response models that are
obtained from observational data and, as such, introduce systematic errors.
This, in turn, might induce vicious feedback cycles in which the effectiveness
of a pricing policy is both overestimated and suboptimal. Tree-based models,
such as random forests, seem especially unable to accurately predict
counterfactual outcomes, even when their performance on estimating the
outcomes of an existing pricing policy might be convincing. The wide adoption
of tree-based methods in the industry makes this a substantial threat that
calls for further research. Finally, we show that approaches from causal
machine learning prove potent in overcoming issues that result from selection
bias, at least when the underlying assumptions discussed in this paper are
satisfied.

We draw two key conclusions from our seminal work:

  1. 1.

The estimation of bid responses from observational data varies from previously
discussed settings of estimating dose responses (Schwab et al., 2020; Bica et
al., 2020; Vanderschueren et al., 2023). In estimating a bid response,
practitioners must infer a continuous function from binary training data. This
significantly complicates the task in comparison with previous applications
with continuous training data. Methodologies such as VCNet have not been able
to show the same level of robustness to selection bias as in preceding
studies, e.g., as in Nie et al. (2021).

  2. 2.

Traditional machine learning methods suffer from increasing levels of bid
selection bias, especially when the degree of nonlinearity in the underlying
ground-truth bid response increases. Causal machine learning methods can help
to overcome this issue but cannot not fully solve it yet.

Having adopted a semisynthetic set of experiments, we want to highlight the
assumptions and limitations of our work: in our data simulation (cf. Section
4.1), we purposefully satisfy both overlap and unconfoundedness, two
assumptions that are deemed critical for the application of causal inference.
Both assumptions might be violated in real-life data. We currently assume that
the decision to accept a certain bid is a function of only the observed
characteristics $\mathbf{X}$ and the bid $B$. This does not hold in reality,
where hidden confounding is likely to occur, as explained in Section 3.1 and
prominently discussed in previous studies on endogeneity in pricing (cf.
Section 2). We see two interlinking components: first, customers compare bid
offers obtained from different banks, which are typically not observed.
Second, some available data are not permitted to be used for business decision
making, for example, under regulation 2016/679 of the European
Parliament444Regulation (EU) 2016/679 of the European Parliament and of the
Council of 27 April 2016 on the protection of natural persons with regard to
the processing of personal data and on the free movement of such data, and
repealing Directive 95/46/EC (General Data Protection Regulation) [2016] OJ L
119/1. (GDPR). Finally, our experiments do not consider any temporal component
in the training data. If economic sentiment changes and average credit rates
decrease, the bid response, $\mu(b,\mathbf{x})$, ceteris paribus, will
certainly shift, but possibly change in form as well.

We conclude with an outlook on future work. First, we believe that developing
and testing causal machine learning methods for business processes such as
pricing is crucial but has not yet been tackled in the established literature.
Specifically, we call for the development of methods that learn an individual
probability estimate as an effect on a continuously valued intervention from
binary training data. This research might advance the application of causal
machine learning in many other fields, such as risk assessment and policy
evaluation. Second, further research should evaluate to what extent violations
of the assumptions in our study impact the performance of causal methods and
to what extent assumptions such as overlap and unconfoundedness are violated
in practice, potentially requiring the development of alternative solutions.
Such research might have critical importance to the adoption of causal machine
learning in practice. We link this stream of future research to Bertsimas and
Kallus (2022) and the notion that for operational decision-making, a true,
unbiased causal model (by the standards of meeting all requirements discussed
in Section 3.3) might not always be needed. Third, we highlight the need for
research in identifying the strength of selection bias in data. While
counterfactual data will never be available for modeling, the strength of
selection bias could be assessed. Such a methodology would be able to inform
decision makers on whether a causal approach must be considered. Finally, our
performance metrics rely on relative performance per customer and do not take
absolute costs and revenues into account. We believe that pricing would
therefore be a promising application of cost-sensitive approaches in causal
inference, such as introduced in Verbeke et al. (2020) and Verbeke et al.
(2023).

## Acknowledgements

The authors want to thank AXA Bank Belgium, Crelan, and the involved project
team who have supported this project throughout by providing feedback, know-
how, and access to the data used for this research project.

This work was supported by the FWO research project G015020N.

## Conflict of interest

The authors state no conflict of interest.

## References

  * Adam et al. (2020) Adam, G.A., Chang, C.H.K., Haibe-Kains, B., Goldenberg, A., 2020\.  Hidden risks of machine learning applied to healthcare: unintended feedback loops between models and future data causing model degradation, in: Machine Learning for Healthcare Conference, PMLR. pp. 710–731.
  * Agrawal and Ferguson (2007) Agrawal, V., Ferguson, M., 2007\.  Bid-response models for customised pricing.  Journal of Revenue and Pricing Management 6, 212–228.
  * Angrist and Pischke (2009) Angrist, J.D., Pischke, J.S., 2009\.  Mostly harmless econometrics: An empiricist’s companion.  Princeton university press.
  * Arevalillo (2019) Arevalillo, J.M., 2019.  A machine learning approach to assess price sensitivity with application to automobile loan segmentation.  Applied Soft Computing 76, 390–399.  URL: https://www.sciencedirect.com/science/article/pii/S1568494618307014, doi:https://doi.org/10.1016/j.asoc.2018.12.012.
  * Berhold (1971) Berhold, M., 1971.  A theory of linear profit-sharing incentives.  The Quarterly Journal of Economics 85, 460–482.
  * Berrevoets et al. (2020) Berrevoets, J., Jordon, J., Bica, I., van der Schaar, M., et al., 2020\.  Organite: Optimal transplant donor organ offering using an individual treatment effect.  Advances in neural information processing systems 33, 20037–20050.
  * Berry (1994) Berry, S.T., 1994.  Estimating discrete-choice models of product differentiation.  The RAND Journal of Economics , 242–262.
  * Berry et al. (1995) Berry, S.T., Levinsohn, J., Pakes, A., 1995.  Automobile prices in market equilibrium.  Econometrica 63, 841–890.  URL: http://www.jstor.org/stable/2171802.
  * Bertsimas and Kallus (2022) Bertsimas, D., Kallus, N., 2022\.  The Power and Limits of Predictive Approaches to Observational Data-Driven Optimization: The Case of Pricing.  INFORMS Journal on Optimization doi:10.1287/ijoo.2022.0077.
  * Bica et al. (2020) Bica, I., Jordon, J., van der Schaar, M., 2020.  Estimating the effects of continuous-valued interventions using generative adversarial networks.  Advances in Neural Information Processing Systems 33, 16434–16445.
  * Breiman (2001) Breiman, L., 2001.  Random forests.  Machine learning 45, 5–32.
  * Brier et al. (1950) Brier, G.W., et al., 1950.  Verification of forecasts expressed in terms of probability.  Monthly weather review 78, 1–3.
  * Cozarenco and Szafarz (2018) Cozarenco, A., Szafarz, A., 2018\.  Gender biases in bank lending: Lessons from microcredit in france.  Journal of Business Ethics 147, 631–650.
  * Cramer (2002) Cramer, J.S., 2002.  The origins of logistic regression .
  * Deaton and Cartwright (2018) Deaton, A., Cartwright, N., 2018\.  Understanding and misunderstanding randomized controlled trials.  Social science & medicine 210, 2–21.
  * Ferkingstad et al. (2011) Ferkingstad, E., Løland, A., Wilhelmsen, M., 2011.  Causal modeling and inference for electricity markets.  Energy Economics 33, 404–412.
  * Garrow et al. (2006) Garrow, L., Ferguson, M., Keskinocak, P., Swann, J., 2006\.  Expert opinions: Current pricing and revenue management practice across us industries.  Journal of revenue and pricing management 5, 237–247.
  * Guelman and Guillén (2014) Guelman, L., Guillén, M., 2014\.  A causal inference approach to measure price elasticity in automobile insurance.  Expert Systems with Applications 41, 387–396.
  * Hanssens et al. (2003) Hanssens, D.M., Parsons, L.J., Schultz, R.L., 2003.  Market response models: Econometric and time series analysis. volume 2.  Springer Science & Business Media.
  * Hausman et al. (2012) Hausman, J.A., Newey, W.K., Woutersen, T., Chao, J.C., Swanson, N.R., 2012.  Instrumental variable estimation with heteroskedasticity and many instruments.  Quantitative Economics 3, 211–255.
  * Heckman (1978) Heckman, J.J., 1978.  Simple statistical models for discrete panel data developed and applied to test the hypothesis of true state dependence against the hypothesis of spurious state dependence, in: Annales de l’INSEE, JSTOR. pp. 227–269.
  * Heckman (1990) Heckman, J.J., 1990.  Selection bias and self-selection.  Econometrics , 201–224.
  * Hirano and Imbens (2004) Hirano, K., Imbens, G.W., 2004\.  The propensity score with continuous treatments.  Applied Bayesian modeling and causal inference from incomplete-data perspectives 226164, 73–84.
  * Holland (1986) Holland, P.W., 1986.  Statistics and causal inference.  Journal of the American statistical Association 81, 945–960.
  * Hornik et al. (1989) Hornik, K., Stinchcombe, M., White, H., 1989.  Multilayer feedforward networks are universal approximators.  Neural networks 2, 359–366.
  * Imai and Van Dyk (2004) Imai, K., Van Dyk, D.A., 2004\.  Causal inference with general treatment regimes: Generalizing the propensity score.  Journal of the American Statistical Association 99, 854–866.
  * Imbens (2000) Imbens, G.W., 2000.  The role of the propensity score in estimating dose-response functions.  Biometrika 87, 706–710.
  * Jain et al. (2016) Jain, P., Gyanchandani, M., Khare, N., 2016.  Big data privacy: a technological perspective and review.  Journal of Big Data 3, 1–25.
  * Kuksov and Villas-Boas (2008) Kuksov, D., Villas-Boas, J.M., 2008\.  Endogeneity and individual consumer choice.  Journal of Marketing Research 45, 702–714.
  * Lawrence (2003) Lawrence, R.D., 2003.  A machine-learning approach to optimal bid pricing, in: Computational modeling and problem solving in the networked world. Springer, pp. 97–118.
  * Lechner (2001) Lechner, M., 2001.  Identification and estimation of causal effects of multiple treatments under the conditional independence assumption.  Springer.
  * Mansoury et al. (2020) Mansoury, M., Abdollahpouri, H., Pechenizkiy, M., Mobasher, B., Burke, R., 2020.  Feedback loop and bias amplification in recommender systems, in: Proceedings of the 29th ACM international conference on information & knowledge management, pp. 2145–2148.
  * Newey (1987) Newey, W.K., 1987.  Efficient estimation of limited dependent variable models with endogenous explanatory variables.  Journal of econometrics 36, 231–250.
  * Nie et al. (2021) Nie, L., Ye, M., Liu, Q., Nicolae, D., 2021.  Vcnet and functional targeted regularization for learning causal effects of continuous treatments.  arXiv preprint arXiv:2103.07861 .
  * Oliver and Oliver (2014) Oliver, B.V., Oliver, R.M., 2014\.  Optimal roe loan pricing with or without adverse selection.  Journal of the Operational Research Society 65, 435–442.
  * Paszke et al. (2017) Paszke, A., Gross, S., Chintala, S., Chanan, G., Yang, E., DeVito, Z., Lin, Z., Desmaison, A., Antiga, L., Lerer, A., 2017\.  Automatic differentiation in pytorch, in: NIPS-W.
  * Pedregosa et al. (2011) Pedregosa, F., Varoquaux, G., Gramfort, A., Michel, V., Thirion, B., Grisel, O., Blondel, M., Prettenhofer, P., Weiss, R., Dubourg, V., Vanderplas, J., Passos, A., Cournapeau, D., Brucher, M., Perrot, M., Duchesnay, E., 2011\.  Scikit-learn: Machine learning in Python.  Journal of Machine Learning Research 12, 2825–2830.
  * Phillips (2012) Phillips, R., 2012.  Customized Pricing, in: The Oxford Handbook of Pricing Management. Oxford University Press.  URL: https://doi.org/10.1093/oxfordhb/9780199543175.013.0021, doi:10.1093/oxfordhb/9780199543175.013.0021.
  * Phillips (2013) Phillips, R., 2013.  Optimizing prices for consumer credit.  Journal of Revenue and Pricing Management 12, 360–377.
  * Phillips (2021) Phillips, R., 2021.  Pricing and revenue optimization.  Second edition ed., Stanford Business Books, Stanford, California.
  * Phillips et al. (2012) Phillips, R., Simsek, A.S., Van Ryzin, G., 2012.  Endogeneity and price sensitivity in customized pricing.  Columbia University Center for Pricing and Revenue Management Working Paper 4.
  * Phillips et al. (2015) Phillips, R., Şimşek, A.S., Van Ryzin, G., 2015.  The effectiveness of field price discretion: Empirical evidence from auto lending.  Management Science 61, 1741–1759.
  * Qian et al. (2023) Qian, Z., Cebere, B.C., van der Schaar, M., 2023.  Synthcity: facilitating innovative use cases of synthetic data in different data modalities.  arXiv preprint arXiv:2301.07573 .
  * Radcliffe (2007) Radcliffe, N., 2007.  Using control groups to target on predicted lift: Building and assessing uplift model.  Direct Marketing Analytics Journal , 14–21.
  * Richards (1959) Richards, F., 1959.  A flexible growth function for empirical use.  Journal of experimental Botany 10, 290–301.
  * Rivers and Vuong (1988) Rivers, D., Vuong, Q.H., 1988\.  Limited information estimators and exogeneity tests for simultaneous probit models.  Journal of econometrics 39, 347–366.
  * Rosenbaum and Rubin (1983) Rosenbaum, P.R., Rubin, D.B., 1983\.  The central role of the propensity score in observational studies for causal effects.  Biometrika 70, 41–55.
  * Rosenbaum and Rubin (1984) Rosenbaum, P.R., Rubin, D.B., 1984\.  Reducing bias in observational studies using subclassification on the propensity score.  Journal of the American statistical Association 79, 516–524.
  * Ross (1973) Ross, S.A., 1973.  The economic theory of agency: The principal’s problem.  The American economic review 63, 134–139.
  * Rubin (1974) Rubin, D.B., 1974.  Estimating causal effects of treatments in randomized and nonrandomized studies.  Journal of educational Psychology 66, 688.
  * Rubin (2004) Rubin, D.B., 2004.  Direct and indirect causal effects via potential outcomes.  Scandinavian Journal of Statistics 31, 161–170.
  * Rubin (2005) Rubin, D.B., 2005.  Causal inference using potential outcomes: Design, modeling, decisions.  Journal of the American Statistical Association 100, 322–331.
  * van Ryzin (2012) van Ryzin, G.J., 2012.  Models of Demand, in: The Oxford Handbook of Pricing Management. Oxford University Press.  URL: https://doi.org/10.1093/oxfordhb/9780199543175.013.0018, doi:10.1093/oxfordhb/9780199543175.013.0018.
  * Schwab et al. (2020) Schwab, P., Linhardt, L., Bauer, S., Buhmann, J.M., Karlen, W., 2020.  Learning counterfactual representations for estimating individual dose-response curves, in: Proceedings of the AAAI Conference on Artificial Intelligence, pp. 5612–5619.
  * Seabold and Perktold (2010) Seabold, S., Perktold, J., 2010\.  statsmodels: Econometric and statistical modeling with python, in: 9th Python in Science Conference.
  * Shalit et al. (2017) Shalit, U., Johansson, F.D., Sontag, D., 2017.  Estimating individual treatment effect: generalization bounds and algorithms, in: International Conference on Machine Learning, PMLR. pp. 3076–3085.
  * Sundararajan et al. (2011) Sundararajan, R., Bhaskar, T., Sarkar, A., Dasaratha, S., Bal, D., Marasanapalle, J.K., Zmudzka, B., Bak, K., 2011\.  Marketing optimization in retail banking.  Interfaces 41, 485–505.
  * Vanderschueren et al. (2023) Vanderschueren, T., Boute, R., Verdonck, T., Baesens, B., Verbeke, W., 2023.  Optimizing the preventive maintenance frequency with causal machine learning.  International Journal of Production Economics 258, 108798.
  * Varian (1989) Varian, H.R., 1989.  Price discrimination.  Handbook of industrial organization 1, 597–654.
  * Varian (2014) Varian, H.R., 2014.  Intermediate microeconomics with calculus: a modern approach.  WW norton & company.
  * Varian (2016) Varian, H.R., 2016.  Causal inference in economics and marketing.  Proceedings of the National Academy of Sciences 113, 7310–7315.
  * Verbeke et al. (2020) Verbeke, W., Olaya, D., Berrevoets, J., Verboven, S., Maldonado, S., 2020.  The foundations of cost-sensitive causal classification.  10.48550/arXiv.2007.12582 .
  * Verbeke et al. (2023) Verbeke, W., Olaya, D., Guerry, M.A., Van Belle, J., 2023\.  To do or not to do? cost-sensitive causal classification with individual treatment effect estimates.  European Journal of Operational Research 305, 838–852.
  * Villas-Boas and Winer (1999) Villas-Boas, J.M., Winer, R.S., 1999\.  Endogeneity in brand choice models.  Management science 45, 1324–1338.
  * Yoon et al. (2018) Yoon, J., Jordon, J., Van Der Schaar, M., 2018.  Ganite: Estimation of individualized treatment effects using generative adversarial nets, in: International Conference on Learning Representations.  URL: https://openreview.net/forum?id=ByKWUeWA-.

##  Appendix A Experimental results

Table A1: Policy Error (PE) on Richards curve Ground truth: Richards curve
---
| Bias strength | True bids
2-8 |  |  |  |  |  |  |
Model | 0.0 | 2.5 | 5.0 | 7.5 | 10.0 | 15.0 | 20.0 |
Naïve pricing | 0.307 | 0.212 | 0.190 | 0.182 | 0.176 | 0.171 | 0.170 | 0.228
Logistic Regression | 0.049 | 0.044 | 0.043 | 0.043 | 0.046 | 0.047 | 0.051 | 0.057
Random Forest | 0.083 | 0.121 | 0.166 | 0.188 | 0.208 | 0.221 | 0.258 | 0.281
MLP | 0.023 | 0.022 | 0.018 | 0.020 | 0.022 | 0.018 | 0.022 | 0.024
|  |  |  |  |  |  |  |
HIE | 0.074 | 0.071 | 0.071 | 0.070 | 0.071 | 0.071 | 0.076 | 0.076
DRNets | 0.051 | 0.071 | 0.160 | 0.167 | 0.096 | 0.093 | 0.156 | 0.176
VCNets | 0.049 | 0.043 | 0.043 | 0.050 | 0.056 | 0.059 | 0.065 | 0.060
Table A2: Policy Error (PE) on stacked sigmoid Ground truth: Stacked sigmoid
---
| Bias strength | True bids
2-8 |  |  |  |  |  |  |
Model | 0.0 | 2.5 | 5.0 | 7.5 | 10.0 | 15.0 | 20.0 |
Naïve pricing | 0.350 | 0.294 | 0.285 | 0.289 | 0.279 | 0.291 | 0.292 | 0.417
Logistic Regression | 0.245 | 0.173 | 0.150 | 0.153 | 0.154 | 0.162 | 0.145 | 0.270
Random Forest | 0.090 | 0.142 | 0.200 | 0.238 | 0.249 | 0.256 | 0.282 | 0.325
MLP | 0.079 | 0.118 | 0.139 | 0.170 | 0.203 | 0.205 | 0.220 | 0.235
|  |  |  |  |  |  |  |
HIE | 0.092 | 0.121 | 0.143 | 0.167 | 0.187 | 0.295 | 0.276 | 0.324
DRNets | 0.090 | 0.109 | 0.127 | 0.109 | 0.122 | 0.122 | 0.142 | 0.137
VCNets | 0.132 | 0.093 | 0.124 | 0.129 | 0.130 | 0.192 | 0.157 | 0.151
Table A3: Brier score (BS) on stacked sigmoid

Ground truth: Stacked sigmoid
---
| Bias strength | True bids
2-8 |  |  |  |  |  |  |
Model | 0.0 | 2.5 | 5.0 | 7.5 | 10.0 | 15.0 | 20.0 |
Naïve pricing | n.a. | n.a. | n.a. | n.a. | n.a. | n.a. | n.a. | n.a.
Logistic Regression | 0.418 | 0.465 | 0.473 | 0.475 | 0.476 | 0.476 | 0.477 | 0.447
Random Forest | 0.411 | 0.460 | 0.469 | 0.472 | 0.473 | 0.473 | 0.474 | 0.442
MLP | 0.408 | 0.459 | 0.468 | 0.472 | 0.473 | 0.473 | 0.474 | 0.439
|  |  |  |  |  |  |  |
HIE | 0.413 | 0.467 | 0.476 | 0.478 | 0.479 | 0.480 | 0.480 | 0.450
DRNets | 0.410 | 0.460 | 0.470 | 0.473 | 0.473 | 0.474 | 0.475 | 0.442
VCNets | 0.415 | 0.463 | 0.471 | 0.474 | 0.475 | 0.476 | 0.476 | 0.443

n.a.: not applicable

Table A4: Mean Integrated Squared Error over expected revenue (MISE R) on
Richards curve

Ground truth: Richards curve
---
| Bias strength | True bids
2-8 |  |  |  |  |  |  |
Model | 0.0 | 2.5 | 5.0 | 7.5 | 10.0 | 15.0 | 20.0 |
Naïve pricing | n.a. | n.a. | n.a. | n.a. | n.a. | n.a. | n.a. | n.a.
Logistic Regression | 0.063 | 0.054 | 0.055 | 0.055 | 0.058 | 0.060 | 0.065 | 0.089
Random Forest | 0.049 | 0.069 | 0.081 | 0.093 | 0.097 | 0.106 | 0.116 | 0.125
MLP | 0.036 | 0.041 | 0.042 | 0.043 | 0.046 | 0.043 | 0.045 | 0.049
|  |  |  |  |  |  |  |
HIE | 0.063 | 0.065 | 0.066 | 0.068 | 0.067 | 0.069 | 0.071 | 0.071
DRNets | 0.041 | 0.047 | 0.074 | 0.084 | 0.060 | 0.062 | 0.088 | 0.074
VCNets | 0.048 | 0.050 | 0.053 | 0.059 | 0.065 | 0.068 | 0.073 | 0.067

n.a.: not applicable

Table A5: Mean Integrated Squared Error over expected revenue (MISE R) on
stacked sigmoid

Ground truth: Stacked sigmoid
---
| Bias strength | True bids
2-8 |  |  |  |  |  |  |
Model | 0.0 | 2.5 | 5.0 | 7.5 | 10.0 | 15.0 | 20.0 |
Naïve pricing | n.a. | n.a. | n.a. | n.a. | n.a. | n.a. | n.a. | n.a.
Logistic Regression | 0.067 | 0.080 | 0.086 | 0.091 | 0.093 | 0.098 | 0.098 | 0.074
Random Forest | 0.057 | 0.096 | 0.113 | 0.129 | 0.128 | 0.139 | 0.148 | 0.165
MLP | 0.033 | 0.049 | 0.076 | 0.081 | 0.093 | 0.104 | 0.103 | 0.109
|  |  |  |  |  |  |  |
HIE | 0.048 | 0.061 | 0.070 | 0.085 | 0.084 | 0.114 | 0.122 | 0.144
DRNets | 0.043 | 0.046 | 0.050 | 0.055 | 0.053 | 0.070 | 0.064 | 0.067
VCNets | 0.056 | 0.070 | 0.090 | 0.097 | 0.096 | 0.110 | 0.109 | 0.092

n.a.: not applicable

##  Appendix B Hyperparameters

All models trained for the experiments in this manuscript have been trained on
a set of different hyperparameters, as described below.

Table A6: Hyperparameters Random Forest Parameter | Values
---|---
Number of trees | $\\{100,500\\}$
Criterion | $\\{Gini\\}$
Maximal depth per tree | $\\{None,10\\}$
Table A7: Hyperparameters MLP Parameter | Values
---|---
Number of hidden layers | $\\{2\\}$
Nodes per hidden layer | $\\{32,48\\}$
Batch size | $\\{64,128\\}$
Number of steps | $\\{1000,2000\\}$
Learning rate | $\\{0.01,0.05\\}$
Table A8: Hyperparameters DRNet Parameter | Values
---|---
Dosage strata | $\\{10\\}$
Number of representation layers | $\\{2\\}$
Number of inference layers | $\\{2\\}$
Nodes per hidden layer | $\\{32,48\\}$
Batch size | $\\{64,128\\}$
Number of steps | $\\{1000,2000\\}$
Learning rate | $\\{0.01,0.05\\}$


# A low-cost and reliable laser shutter interlock using a software-command
interface

Joshua P. Rogers, Andrew J. Murray  Photon Science Institute, School of
Physics & Astronomy, University of Manchester, Manchester M13 9PL, United
Kingdom

(August 27, 2024)

###### Abstract

A simple and low-cost laser interlock is presented that operates via software
commands issued by an ESP32 microcontroller. The architecture of the device is
constructed to ensure the laser output is shut off in the event of either an
open circuit on the interlock signal line from the laser enclosure or loss of
power to the device. Unintentional exposure to the laser beam is prevented by
overruling local controls (such as a keypad), until both the enclosure is re-
interlocked and the user actively intervenes. The device presented is designed
to close the mechanical shutter of a Spectra-Physics Millennia Pro pump laser
while it continues to operate internally. The hardware and coding are
versatile enough to be deployed on any instrument that receives software
commands via a serial interface.

##  I Introduction

Laser safety in a working research laboratory is extremely important. In the
UK in recent years, many laser users have had to suspend activities for weeks
or months to make improvements in laser safety measures following inspections
by the Health and Safety Executive. In the hierarchy of controls for the
safety of workers Chase (2019), engineered containment of a hazard is
preferred over both administrative controls and personal protective equipment
(PPE). Containment is superseded only by elimination or substitution of the
hazard. Many laser laboratories use high power class 3B and 4 lasers, which
exceed maximum permissible exposure irradiance limits to the eye and often
also to the skin. If it cannot be eliminated, the laser emission hazard
therefore requires robust containment infrastructure to protect all laboratory
occupants and reduce reliance on PPE, such as laser goggles and gloves.
Ideally, all laser beams are always fully enclosed and inaccessible to all lab
users. However, a door or curtain interlock is an essential component in these
safety measures, particularly when the room itself becomes the laser enclosure
while open-beam work is in progress. This situation occurs during manual
alignment of the optical path, or when adjusting a laser cavity to optimize
its output.

The ideal interlock is ‘fail-safe’, such that not only a discontinuity in the
enclosure but also power or component failure in the interlock itself will
immediately halt laser emission. Interlocks therefore typically employ a
switching circuit that is closed only when the enclosure is shut. Depending on
the type of laser system that is used, the interlock may directly shut off
power to the source of emission or it may mechanically obstruct the beam using
a shutter. Whereas cutting off the power to the laser will definitively remove
the hazard, consideration must also be given to whether this is practicable
under research conditions. This is particularly true if the laser or
downstream components in the optical chain could be damaged by sudden loss of
power. Strategically positioned mechanical shutters are therefore often more
appropriate in these situations as they are less disruptive to research
activity while providing the same degree of protection to users.

The interlock system described here has been designed to interface with the 15
$\mathrm{W}$ Spectra-Physics Millennia Pro laser, which is used to pump
several tuneable laser systems in our laboratory. This laser features an
electrical interlock interface in series with its power supply, which ensures
that emission stops immediately when the laser enclosure interlock circuit is
opened. Once the enclosure interlock switch is re-engaged the laser must then
be restarted and the warming-up procedure to reach full power and stability
can be implemented. This can introduce significant delay and disruption to
research activity, particularly when frequent access to the laser enclosure is
required. Despite being highly dependable, this is not a practicable method
for interlocking the laser system to its enclosure. Although interlock
overrides are often used to circumvent this problem, disabling a safety
system, even temporarily, increases the probability of accidental exposure to
the hazard.

The Millennia also features a gravity-fed mechanical shutter inside the laser
head, operated by a handheld controller. The shutter is normally-closed and,
rather than interrupting power to the laser head, merely physically obstructs
the beam, keeping it within the Millenia’s housing. The shutter can also be
actuated by software commands via an RS232 interface on the rear of the power
supply. Since shutting the shutter ensures complete containment of the beam
while maintaining stable laser operating conditions internally, it is clearly
preferable to use this method to eliminate the hazard when the enclosure is
opened during open-beam work.

In this design note a simple and low-cost interlock solution is presented that
satisfies the requirements of being fail-safe, reliable and practicable. This
solution utilises an ESP32 microprocessor on a commercial development board
that interfaces with the Millennia’s software command interface to actuate its
mechanical shutter. The ESP32 continuously monitors the status of both the
interlock and the shutter and will shut off the laser beam if the enclosure is
opened. The laser power supply therefore remains operational throughout so
that the long term stability of the laser is not disturbed.

An interlock that utilises software commands can have more potential points of
failure compared to a simple hardware interlock. It is therefore important to
ensure that it is fail-safe under all operating conditions. The ESP32
microcontroller serves this purpose well because it is a robust device that
operates independently of an operating system and does not need to interface
to a network. The code that has been written for the microcontroller only
performs the dedicated task of monitoring the interlock status and writing
commands to the RS232 interface. This ensures continuous, reliable and safe
operation once installed and does not require the user to override its
function.

##  II Methods

The principle of the interlock is a basic state machine, the logic of which is
shown in Fig. 1. If the enclosure interlock switch opens, a serial command is
sent to the laser to immediately shut the mechanical shutter if it is open.
When the enclosure interlock is re-engaged, a physical reset button on the
interlock box must be pressed before the laser shutter will open again. This
ensures that the user is active in controlling the safety aspects of the
system. A 20 $\mathrm{ms}$ loop that continuously checks the status of the
enclosure interlock was chosen over interrupt logic due to severe bouncing in
the interlock switch signal. This loop duration is long enough to prevent
rapid repeated actuation of the shutter due to this switch bounce. It is also
short enough to act on the same time scale as the motion of the shutter and
appear instantaneous to the user; including the transmission of the serial
data, the shutter will always begin to close within 32 $\mathrm{ms}$ of the
enclosure interlock switch opening.

Figure 1: A flow diagram showing the logic of the state machine coded on the
ESP32.

The ESP32 development board that controls the interlock sits in a small box
and is mounted on a bespoke PCB that delivers +5 $\mathrm{V}$ DC power and
breakout connections. It is wired to both the enclosure interlock switch and
the laser power supply RS232 interface. A schematic of the interlock circuit
is shown in Fig. 2 and the values for the components are listed in Table 1.
The ESP32 monitors the status of the enclosure interlock via two of its
general-purpose input/output (GPIO) pins. For a ‘passive’ normally-open
circuit, switch SW1 shorts to ground when the enclosure interlock is shut. The
GPIO pin 12 monitors this switch and is set to use an internally enabled pull-
up resistor, so that the input is high when the curtain is open and is low
when the switch SW1 is closed. A 1N4148 diode (D2) protects this input from
any accidental positive voltage input up to 100 $\mathrm{V}$. If an ‘active’
enclosure interlock system is used (with a range from +5VDC to +24VDC), then
this is input via a separate socket (see Fig. 3). This active interlock
voltage is monitored by GPIO pin 26, which is protected by a 4.7 $\mathrm{V}$
Zener diode (D3) as shown. The 10 $\mathrm{k\SIUnitSymbolOhm}$ resistor R3
limits the current from the interlock supply while ensuring the Zener diode is
switched on.

Pin 13 is configured as an output and provides a signal to an indicator LED
(LED1) on the side of the box that illuminates when the shutter is open.

Pin 27 monitors the ESP32 power supply. If it is pulled low (eg by a +5
$\mathrm{V}$ DC power supply failure), the 1 $\mathrm{mF}$ capacitor (C1)
across the power input holds enough charge to ensure that a final command can
be sent to close the shutter before the ESP32 stops operating. This feature
ensures that the interlock is fail-safe against accidental loss of power.

Pin 14 is set with the pull-up resistor enabled and is used to interrupt the
code loop to indicate when the reset button is pressed. This interrupt flag
ensures that open beam work cannot resume until the user intervenes directly.
The software allows the handheld laser controller to be used normally while
the enclosure interlock is shut, however the ESP32 system overrides the manual
controller to ensure the shutter remains closed while the enclosure is open.

Figure 2: The electrical schematic of the interlock. The dotted grey boundary represents the box containing the ESP32, MAX3232 IC, bespoke PCB and panel connectors. Both varieties of enclosure interlock circuit (passive and active) are shown with their respective switches on the left. The thick grey arrow on the bottom right represents the RS232 cable connected to the Millennia Pro power supply. The values for the components are listed in Table 1. component | value
---|---
R1 | 150 $\mathrm{\SIUnitSymbolOhm}$
R2 | 10 $\mathrm{k\SIUnitSymbolOhm}$
R3 | 1 $\mathrm{k\SIUnitSymbolOhm}$
C1 | 1 $\mathrm{mF}$
D1 | RR264M-400TR
D2 | 1N4148W-7-F
D3 | MMSZ4688T1G
LED1 | 703-0090
Table 1: Values for the components in Fig. 2.

Pins 22 and 23 are assigned respectively to receive and transmit serial data.
The serial interface of the ESP32 operates on normal transistor-transistor
logic (TTL) levels. The Millennia communicates over RS232, which uses inverted
high and low logic levels in the range $\pm 3-15$ $\mathrm{V}$ Shawn (2020).
The serial communication protocol of the Millennia power supply operates at
9600 baud, with no parity bit, 8 data bits, 1 stop bit and no hardware flow
control (config SERIAL_8N1) Mil (2005). To translate between the TTL and RS232
protocols, a MAX3232 IC is used as shown in Fig. 2.

It is important to note that there are several ESP32 development boards
available that use different pin-outs. The bespoke PCB in this interlock is
compatible with the 38-pin NodeMCU ESP32 board. Its design is shown in Fig. 3
(a), together with images of the finished interlock box (b). The ESP32 is
mounted onto the PCB on two rows of header sockets, which serve to breakout
the GPIO pins to Molex KK 254 series connectors. This modular design ensures
that if the board, the ESP32 or a port on the box fails, replacements can be
inserted easily. The bill of materials (10.48420/20037140), ESP32 software
(10.48420/20037176) and PCB design files (10.48420/20037185) are all available
online at their respective DOIs.

Figure 3: (a) The bespoke PCB front (red) and back (blue) planes. (b) Pictures
of the finished interlock box, measuring 9 $\times$ 6 $\times$ 4
$\mathrm{cm}$.

##  III Discussion

The interlock system described in this design note was built to ensure
versatility, reliability and modularity. It features two physical input ports
for the enclosure interlock switch, depending on whether the external circuit
is active or passive. If active, the system can accept any voltage between 5 -
24$\mathrm{V}$. The ESP32 platform is simple, robust and low maintenance, with
only periodic functionality checks being required. Components are easily
swapped in case of failure. Although the software code is written specifically
for the Millennia Pro pump laser, simple edits are all that are required for
it to be deployed on any instrument that is controlled by serial software
commands. The interlock system described here costs around £75 per unit,
including the bespoke PCB manufactured at a prototyping fabricator.

##  IV Conclusions

Operational safely is the first priority in any laboratory that uses high
power laser systems. Engineered solutions that are reliable, cost-effective
and practicable are therefore essential for maximising uptime and project
resources. The interlock system described here can be implemented with only a
small degree of prior experience in electronics, or it can even be used as an
exercise to develop the necessary skills in this area. These principles are
also easily configurable to enable hardware-triggered automation in any
similar laboratory device that uses an RS232 interface.

##  V Acknowledgements

This work was supported by the Engineering and Physical Sciences Research
Council (EPSRC), United Kingdom, through research grant EP/V027689/1. Thanks
are also given to Derrick Bradshaw in the PCB fabrication lab of the
University of Manchester Department of Engineering for manufacturing the
bespoke boards.

## References

  * Chase (2019) Wes Chase, “Non-beam to the extreme!” in  _International Laser Safety Conference_ (Laser Institute of America, 2019).
  * Shawn (2020) Shawn, “RS232 vs TTL: Beginner guide to serial communication,” https://www.seeedstudio.com/blog/2019/12/11/rs232-vs-ttl-beginner-guide-to-serial-communication (2020), accessed 20/05/2022.
  * Mil (2005) _Millennia Pro s-Series Diode-Pumped, CW Visible Laser Systems_, Spectra-Physics, 1335 Terra Bella Avenue, Mountain View, CA 94043 (2005).