How do **young actuaries get ready** for the brave new data world? One sure way is to keep learning pace even after qualification. After all, it is a choice; either you equip yourself to ride the disruption wave everyone seems to be speaking about (but have no clue how), or you go under the wave, like hoi polloi.

The **traditional learning from data** in the actuarial field is with the statistical rigor of the era, not long ago, but with limited capability to wrangle data as we can today. The A/E of experience studies in the life & health insurance and run-off tringles in general insurance are the main ways (or likely the only way, given the legacy data systems) of learning feedback loop. As the sector starts digitally interacting with other enabling platforms, the way we learn from data will evolve too.

This blog covers the learning approaches and Bayesian Decision theory; note the very recent AI/ML learning paradigms. Actuaries aren’t new to Bayes Decision Theory, but we haven’t been consciously leveraging the capabilities. The actuarial control cycle and our pricing approaches do reflect the active feedback, but the underlying wonder of the Baysian method gets missed in the processes and practice standards.

Read for a different perspective than the actuarial course perspective, specifically, how decisions are made based on the **likelihood ratio**.

his is part of the learning log from the 3rd module, Machine Learning Basics for Real-World, from the certification course on Digital Health and Imaging. Links to the module learnings are below:

- Class 1 – Machine Learning – An actuary’s learning log
- Class 2 – ML Log – Learning Methods & Bayesian Decision insights
- Class 3 – ML Log – Rigorous explanation of Supervised Learning Approach
- Class 4 – ML Log – Pseudo-inverse estimator and gradient descent approaches to Linear Regression
- Class 5 & 6 – ML Log – Likelihoods and Bayesian Philosophy in Machine Learning

**Learning Summary – Class 2; 26 June 2022:**

Part 1 – What is **learning **in Machine Learning? – Classification of Learning Approaches

- Learn by exploring data:
*Supervised learning includes classification (Linear Regression, Regression Trees, Non-Linear Regression, Bayesian Linear Regression, and Polynomial Regression) and regression (Random Forest, Decision Trees, Logistic Regression, and Support Vector Machines)*.*Unsupervised learning*includes*clustering, association/density estimation, visualization, projection (Principal Component Analysis)* - Learn from data; in more challenging circumstances –
*Semi-supervised Learning, Domain adaptation, Active Learning* - Learn by interacting with an environment –
*Reinforcement learning,*Multi-armed Bandits - Very recent challenging AI paradigms –
*Zero/One/Few-shot Learning,*Transfer Learning,*Multi-agent reinforcement learning*

**Part – 2: Bayesian Decision Theory**

- Review of probability terms
- Bayesian Decision Theory
- Error Analysis
- Generalizing the Bayesian Decision Theory
- A two-category Classification and selection threshold
- Loss functions – zero-one threshold

The second class on Sunday afternoon was overwhelming. The professor briefly explained the learning methods. Since I already had acquainted with some of these methods, I had to revise to get clarity and link those hazy ideas into this new structure. The Bayesian decision method triggered almost another panic attack, the probability theory is really elusive. If one takes a long break from the theory, it breeds probabilistic doubts in the mind about how much was actually retained!

**What is learning in Machine Learning?**

It is hard to define learning in a universal sense precisely. We can learn to solve some problems deterministically where a hardcoded logical solution is feasible, like sorting an array or finding the area given the perimeter descriptions. However, Real-world is usually a more complex interaction of many simpler processes, needing an iterative algorithm relying on past observations and getting better as more data is observed. With increased computing capabilities, AI/ML methods enable more such algorithms to be conceived and developed.

Actuaries, in a sense, work in this iterative way by default. The pricing of risks or managing in-force risk portfolios has adapted to the actuarial feedback loop approach. The portfolios are subject to complex interactions of influencers varying in nature from demographic, economic, man-made, or natural hazards. It isn’t surprising to see many common mathematical and statistical concepts between the actuarial and emerging AI/ML fields.

**Classification of Learning Approaches**

The context of learning in machine learning is acquiring skills or knowledge from experience or equivalently synthesizing useful concepts from historical data. Some typical classifications describe whole subfields of the study comprised of many different types of algorithms, such as supervised learning. One way to classify the learning methods is based on how we interact with the data to solve the problems of predictions.

**1 Learn by exploring data **

** Supervised learning** involves models that learn a mapping between input examples and the target variable. The training data includes the input vectors and their corresponding result/ground truth vectors. In this case, learning is discovering an algorithm or a mapping that predicts the results on new examples beyond the training set.

Learning is ** supervised **as the algorithms learn from the target

**being provided; in that sense, the target labels in the learning data monitor the algorithm to predict better. Supervised learning can be split into**

*y***, which involves predicting a class label, and**

*Classification***which consists of predicting a numerical label. The problems may have one or more input variables, and input variables may be any data type.**

*Regression*Regression algorithms are used if we know a relationship between the input and output variables. For example, it is used to predict continuous variables, such as weather forecasting, market trends, etc. Some popular Regression algorithms under supervised learning are *Linear Regression, Regression Trees, Non-Linear Regression, Bayesian Linear Regression, and Polynomial Regression*.

Classification algorithms are used for categorical variables, meaning there are two classes: Yes-No, Male-Female, True-false, etc. *Random Forest, Decision Trees, Logistic Regression, and Support Vector Machines* are some examples of classification algorithms. An excellent example of a classification problem is separating spam from regular emails or recognizing handwritten digits 0-9.

Some algorithms may be specifically designed for both types of problems with minor modifications (such as *artificial neural networks*).

Advantages of Supervised learning:

- The algorithms use prior experiences,
- We get to know the classes of objects,
- has helped to solve fraud detection, spam filtering, etc.

Disadvantages of supervised learning:

- Not suitable for handling complex tasks,
- prediction on new data may be poor if test data is different from the training dataset,
- Training requires lots of computation times.
- knowledge about the classes of objects is needed

** Unsupervised learning** learns only the input data without outputs or target variables; the algorithms must learn to make sense of the data without knowing the ground truth. The input to the unsupervised learning models is likely to be unstructured and may contain noisy data, missing values, or unknown data. Two main classes in unsupervised learning are

**and**

*clustering*

*association/density estimation.***Clustering **groups the objects into clusters, objects in a group will have the most similarities and have less or no similarities with the things of another group. Clustering is about finding statistical commonalities between the data objects.

**Association** is a rule-based technique attempting to find useful relations between variables in a large database in the form of probability distributions. For example, the algorithms track the items that tend to occur together, such as people buying bread are also likely to purchase butter or jam.

** Visualization **involves graphing/plotting data in different ways; an example of a visualization technique is creating a scatter plot matrix for each pair of variables in the dataset.

*P**methods involve reducing the dimensionality of the data by creating lower-dimensional representations of data.*

**rojection****uses the projection method to summarize a dataset in terms of eigenvalues and eigenvectors, with linear dependencies removed.**

*Principal Component Analysis*Some popular unsupervised learning algorithms are *K-means clustering, KNN (k-nearest neighbors), Hierarchal clustering, Anomaly detection, Neural Networks, Principle Component Analysis, Independent Component Analysis, Apriori algorithm, and Singular value decomposition*.

Advantages of Unsupervised Learning:

- Can be used for more complex tasks,
- is preferable as it is easier to get unlabelled data than labeled data.

Disadvantages of Unsupervised Learning:

- Intrinsically more complex,
- The results may be less accurate as algorithms do not know the exact output in advance.

**2 Learn from data; in more challenging circumstances**

** Semi-supervised Learning** is learning with the middle ground between supervised and unsupervised learning algorithms. The training data will have very few labeled and many unlabelled examples; this way, the learning effectively uses all available data. Even the labels may not be very accurate truths. The abundant unlabelled data provides clues to discover groups or patterns. Then the supervised methods can be used to label the unlabelled examples or use the learning to make the predictions.

Problems from the fields with less labeled data like computer vision (image data), natural language processing (text data), and automatic speech recognition (audio data) benefit from semi-supervised learning. They cannot be easily handled using standard supervised learning methods.

Machine learning performance depends on the dataset it is trained on; imperfections in the data affect the models. One type of problem is domain shift, where a model trained to learn one dataset may not be able to perform the same task on even a slightly different dataset. For example, a model trained to detect dogs in outdoor settings might fail to detect dogs indoors because the backgrounds are different.

** Domain adaptation** applies an algorithm trained in one source domain to a different (but related) target domain. The source and target domains have the same feature space (but different distributions). Domain adaptation is a subcategory of transfer learning; transfer learning includes broader cases where the target domain’s feature space differs.

Domains are the combination of an input space ** X**, an output space

**, and an associated probability distribution**

*Y***. Two domains can be called different if they differ in these characteristics. The common approaches to the domain adaptation method follow an adversarial approach. Adversarial machine learning aims to trick machine learning models by providing deceptive input, including the generation and detection of adversarial examples.**

*p*** Active Learning** prioritizes the data which needs to be labeled to have the highest impact on training a supervised model. The learning algorithm can interactively query and label new input data points to better the model fit. In statistics literature, it is referred to as optimal experimental design. Active learning is used when the amount of data is too large to be labeled, and labeling takes effort and cost.

**3 Learn by interacting with an environment **

*Reinforcement learning, **supervised learning*, and *unsupervised learning *are three ML paradigms. Reinforcement Learning enables an agent to learn in an interactive environment by trial and error using feedback from its actions and experiences. Instead of the fixed training dataset, there is a goal or set of the goals that the learning agent is required to achieve, actions they may perform, and the related performance feedback. Basic reinforcement learning is modeled as a Markov decision process.

Some examples are *Q-learning, temporal-difference learning, and deep reinforcement learning.* Due to its generality, reinforcement learning is studied in many disciplines, such as game theory, control theory, operations research, information theory, simulation-based optimization, multi-agent systems, swarm intelligence, and statistics.

**Multi-armed Bandits** problems are some of the simplest reinforcement learning problems. A player is faced with k slot machines or bandits (because historically, casinos set them up so that players get a raw deal!), each with a different reward distribution. The player is trying to maximize his cumulative reward based on trials. The trade-off he faces at each trial is between betting on the machines he knows to have the highest expected payoff and trying out the other machines that may provide even better gains.

**4 Very recent challenging AI paradigms**

** Zero/One/Few-shot Learning**: Few-Shot Learning is about classifying new data using supervised information with only a few training samples. FSL is a young area that needs more research and refinement. However, it has been successful in computer vision tasks, for example, categorizing bone illnesses via x-ray photos, where enough images aren’t available. Zero-Shot Learning tries to classify unseen classes without any training examples but with the general idea of an object, its appearance, properties, and functionality.

In general, the input volume comes with the cost, time, pre-processing, computational, etc., costs; companies can reduce data analysis/machine learning (ML) costs.

A model trained on one task is re-purposed on a second related task in** Transfer Learning**. Reusing a previously learned model on a new problem is particularly popular in deep learning as a tool to train deep neural networks with a small amount of data.

In the deep neural networks trained on images, the early layers of the network learn low-level features like detecting edges, colors, variations of intensities, etc. These low-level features appear not specific to a particular dataset or a task. Low-level features learned are hence transferable between tasks. As a result, it is now uncommon to see whole convolutional neural networks being trained from scratch; pre-trained models trained on various images in a similar task are used instead.

** Multi-agent reinforcement learning** focuses on studying the behavior of multiple agents that coexist in a shared environment. Each agent is motivated by its rewards and does actions to advance its own interests; these interests may be opposed to the interests of other agents, resulting in complex group dynamics. Multi-agent reinforcement learning is closely related to game theory and especially repeated games. More importantly, its study combines the pursuit of finding ideal algorithms that maximize rewards with a more sociological set of concepts.

**Bayesian Decision Theory**

Bayesian decision theory is a statistical approach to the problem of pattern classification. It is considered the ideal pattern classifier because its decision rule automatically minimizes its loss function. The approach *quantifies the trade-offs* between various classification decisions using probability and minimizes the costs of such decisions. The underlying assumption is that the decision can be made in probabilistic terms; this requires that all the relevant probability values are known.

**Review of probability terms**

Some terms need reiterating to understand the Bayesian way. I found looking at the below frequency table helpful in connecting to the concepts.

** Joint probability** calculates the probability of two events occurring together at the same time:

** P(A and B)** or

**or**

*P(A, B)***.**

*P(A ∩ B)*So, for example, the probability of finding a female football lover in the table is 0.05. Note this is specific to this group that answered queries on their preferences.

**Marginal probability** is the one usually referred to as the probability of an event; it is the probability of an event irrespective of any other event/circumstance. Interestingly, these are the probabilities *found in the margins *of the table above. For example, the probability of being a male in the surveyed group above is 0.54, irrespective of the sports preference. Similarly, the probability of finding a cricket fan is 0.39, regardless of gender. It is denoted by **P(A) **and read as “** probability of A**“.

**Conditional Probability** is a bit tricky to handle. It is the probability of one event occurring given that another event has happened (by assumption, presumption, assertion, or evidence). Alternatively, it is the probability of occurrence of an event ** A** when another event

**has already occurred. It is denoted by**

*B***and read as “probability of A given B”.**

*P(A|B)*In our table, how do we estimate from our table the probability that a person is a football lover when we know it is a female respondent? The fact that we know the respondent is a woman reduces the overall cohort that we are looking for. So now we are looking for a subset of 500 respondents or responses from 230 women to decide the chances that a particular woman respondent is a football lover.

So, we have 25 football lovers out of 230 women; hence the required probability is 25/230 or about **0.11** (note this is different from the number 0.05 in the table). To get the overall perspective of the survey, let us divide the numerator and denominator by the total number of responses. This mathematical trick provides an interesting and intuitive link to the overall survey.

Hence a formal definition of conditional probability is:

This insight results in **two useful formulas** we need for navigating the Bayes world.

The first one is; by multiplying both sides of the equation above by ** P(B)**; we get

*P(A and B) = P(A | B) P(B)*From this equation you also can see that to calculate ** P(A and B)**, instead of using the

**operator, we can use the product of two probabilities.**

*&***is the probability of A occurring given that event B has occurred multiplied by the probability of event B happening. Pay close attention; you can**

*P(A|B) P(B)***A and B.**

*interchange*Let us consider the table again. First, note how you can consider taking column as the event happened (you know gender first and then decide to check the sports preferred). Equivalently you can ascertain sports preferred first, then check the proportion of males. Both will yield the **same proportion of the total surveyed**; as you can see, the row or the column totals* cancel out* in the equation.

P(Male and Cricket Lover) = P(Cricket Lover | Male) * P(Male)

= 120 / 270 * 270 / 500 = 120/500**Or equivalently**

P(Male and Cricket Lover) = P(Male | Cricket Lover) * P(Cricket Lover)

= 120 / 195 * 195 / 500 = 120/500

This intuition leads us straight to **Bayes’ Theorem:**

*P(A and B) = P(A|B) P(B)*

*= P(B|A)***and hence**

*P(A)*If this looks like mathematical jugglery and you feel lost, don’t worry, you are not alone! The next sections hopefully will relieve that uneasy feeling.

The second insight we get from the conditional probability equation above is ** the law of total probability**.

*P(A) = P(B1 and A) + P(B2 and A)*

The total probability of event A is the sum of two possibilities. Either the events ** B1** and

**occur together, OR events**

*A***and A occur together. Here we assume that**

*B2***and**

*B1***are:**

*B2*- Mutually exclusive, only one of them can be true, and
- Collectively exhaustive, one of them must be true.

Going back to our table, the probability that the gender is male can be seen as the sum of proportions of the cricket, football, and other male sports lovers, proportions taken over **all** fans.

Or the probability that a person loves football is the proportion of males and females who love football, proportions taken over the total survey number.

The second one we need is ** the law of total probability**.

*P(A) = P(B1 and A) + P(B2 and A)*

The total probability of event A is the sum of two possibilities. Either the events ** B1** and

**occur together, OR events**

*A***and A occur together. Here we assume that**

*B2***and**

*B1***are:**

*B2*- Mutually exclusive, only one of them can be true, and
- Collectively exhaustive, one of them must be true.

Going back to our table, the probability that a person loves football (A) is the proportion of males (B1) and females (B2) who love football, proportions taken over the total survey number.

Or the probability that the gender is male (A) can be seen as the sum of proportions of the cricket (B1), football (B2), and other (B3) male sports lovers, proportions taken over **all** fans.

**A subtle difference between being likable and predictable (difference between Likelihood and Probability!)**

The distinction between probability and likelihood is fundamentally important; Probability attaches to possible results; likelihood attaches to hypotheses.

Possible results/outcomes are mutually exclusive and exhaustive. For example, predicting the outcome of each of 10 tosses of a coin has only 11 possible results (0 to 10 correct predictions). The actual result will always be one and only one of the possible results. Thus, the probabilities attached to the possible results must sum to 1.

But the hypotheses do not have these properties. The set of beliefs to which we attach likelihoods is limited only by our capacity to dream them up. In practice, we can rarely be confident that we have imagined all the possible hypotheses. All we can do is make calls about which theory is more ‘likely’ than the other.

Take an example of an actuarial exam (we will refer to this more later); we can make two hypotheses, one assumes that it takes an average of 200 hours of study to pass an SP level exam, and the other assumes that it takes 400 hours. Now, if you observe out of 100 students who have passed, 60 students state that they studied about 450 hours (can’t really trust them you know, but still!), then our second hypothesis appears more likely.

**Now to Bayesian Decision Theory:**

Adapted from Bayesian Decision Theory (hacettepe.edu.tr)

As mentioned earlier, Bayesian decision theory is a statistical approach to pattern classification. It tries to quantify the trade-offs between classifications using probabilities and costs of decisions. A fundamental assumption is that we know all the probabilities needed for decision-making are known.

Let us consider the simplistic two-class classification problem. For two classes, ** ω_{1}** and

**, let prior probabilities for an unknown new observation be:**

*ω*_{2}: the new observation belongs to*P(ω*_{1})*class 1*: the new observation belongs to*P(ω*_{2})*class 2**P(ω*_{1}) + P(ω_{2}) = 1

The textbook example considers a fisherman trying to classify his catch between Sea bass ** P(ω1) **and Salmon

**. These chances he knows from his experience, like in a given season there is a more probability of catching sea bass or in a particular area probability of getting salmon is more. It helps to specify the structure of the problems.**

*P(ω2)***State of nature**Two classes or states fully represent the state space; they are exclusive & exhaustive: e.g.,*ω:*for sea bass,*ω*_{1}for salmon as in the problems.*ω*_{2}**Priors –**Probabilitiesand*P(ω*_{1}): These probabilities reflect our prior knowledge of how likely we will expect a specific state of nature*P(ω*_{2}). For example, how likely we hope to catch a sea bass or a salmon.__before we actually observe the state__

**Decision Rule from only priors**: Our **decision rule** when no feature on the new object is available:

Classify as class 1 ifP(ω_{1})>P(ω_{2})

The above decision rule appears reasonable if all our information were only priors!

- But we will always choose the same fish (or always predict failure in the exam, no more actuaries!)
- If the priors have equal probabilities (or uniform), then we will make poor decisions
- But under the given assumptions, no other rule can do better!

We can also look at errors; remember, Bayes decision rule objective is to minimize the errors. Therefore, we always choose the state that has the maximum probability. Since there are only two classes, we can quantify the error as the smaller of the probabilities. Hence

*P(error) = min[P(ω _{1}) + P(ω_{2})]*

So far, good; now let us see how Bayes theorem gets in the picture. We saw features and feature space in first class. *A feature is an observable variable* *of the state*; for example, the length, width, location of the dorsal fin, or weight are all observable variables for the fish problem above. Now suppose we have access to one of these features, and we have observed frequency information. For example, we have noted down the weights of each fish and if the fish is seabass or salmon.

We can put these observations into a histogram by counting them into suitable groups and then draw an approximation of their probability distributions. The probability distribution curves represent the continuous approximation of the frequency tables. Since the observations are made for each class (of fish), these are class conditional probability densities.

Suppose the conditional distributions are as below. *(Remember, this is additional information we have observed, nothing to do with our priors yet)*.

Now we are introducing a new term, the ** likelihoods**. The class conditional probabilities are called likelihoods because these probabilities represent how likely a fish caught weighing 12 on the x-axis is to be a seabass or salmon. The thing to be noted here is that this is purely based on our observations and has nothing to do with the prior beliefs.

These likelihoods provide another rule for deciding:

Decide ω_{1}if P(x|ω_{1}) > P(x|ω_{2}) ; ω_{2}otherwise

But this likelihood rule doesn’t consider any prior knowledge (or priors) considered above. The Bayesian formulation helps combine prior knowledge and class conditional probabilities into a single rule. Let us start from the joint probability of finding a pattern in the category ** ω_{j}** (from the prior) and has the feature value of

**. As we have seen above, we can write the joint probability density**

*x***in two ways.**

*p(ω*_{j}, x)*P(ω _{j} |x) p(x) = p(x|ω_{j} ) P(ω_{j} )*

What we really are saying in the first/left part of the equation is that the term ** P(ω_{j} |x)** is the appropriate pmf that will have produced the observed pattern of

**. If we were prophetic, this would have been our prior! But then we are neither psychic nor prophetic; we had started with something we thought was right, as priors**

*x***So the difference is balanced by**

*P(ω*_{j}).**on the right-hand side of the equation.**

*p(x|ω*_{j})Rearranging to get the Bayes formula:

From the law of total probability, we can get the probability density function as p(x) = p(x|ωj )P(ωj ) + p(x|ωj )P(ωj ). W1 and w2 are exclusive and complementary; we can split our observations into any such partition. This p(x) also turns out to be a marginal distribution of x, which is the probability of the data under any hypothesis.

Bayesian world denotes the equation with specific names.

*Posterior = [ likelihood * prior ] / evidence*

Bayes formula shows that by observing the value of ** x**, we can convert the prior probability P(ωj ) to the posterior probability P(ωj |x); the probability of the state of nature being ωj given that feature value x has been measured. Another way to think of the Bayes theorem is that we can update the probability of a hypothesis, H, considering some data, D.

p(Hypothesis | Data) = [p( Data | Hypothesis) * p(Hypothesis)] / p(Data)

Now we can frame our Decision Rule based on posterior distributions:** **

*Decide ω _{1} if P(ω_{1} /x) > P(ω_{2} /x) ; otherwise decide ω_{2}*

The evidence factor ** p(x)** is common on both sides; it turns out that it is there to guarantee that the posterior is a probability distribution (sums to 1). While comparing the probabilities, the proportions are of interest:

Hence our Bayesian decision rule:

Decide ω_{1}if p(x/ω_{1 }) * P(ω_{1}) > p(x/ω_{2}) * P(ω_{2}) ; otherwise decide ω_{2}

The impact of priors can be seen in the below picture. Thus, in this case, given that a pattern is measured to have feature value *x* = 14, the probability it is in category *ω _{2}* is roughly 0.08, and that it is in

*ω*is 0.92. At every

_{1}*x*, the sum of the posterior is 1.0.

If this seems complicated to comprehend, please see here for an alternative explanation; the highly skewed *P(ω _{1})* affects the posterior for

*ω*.

_{2}**Error Analysis**

Bayes Decision theory is fundamentally about minimizing errors. Whenever we decide on a particular *x*

** P(error|x) = P(ω_{1}|x) if we decide ω_{2} ** or

*= P(ω*_{2}|x) if we decide ω_{1}Clearly, for a given x we have minimized the probability of error by choosing w1 or w2 with the highest probability. But what about the average probability of error? If we ensure that for every *x*, ** P( error|x ) ** is as small as possible, the sum of errors must be as small as possible. Thus we have justified the following Bayes decision minimizing the probability of error.

**Generalizing the Bayesian Decision Theory **

These above ideas can be generalized in four ways:

- by allowing than one feature;
is a feature vector*x ∈ ℝ*^{D} - by allowing more than two states of nature
: a finite set of classes*{ω*_{1}, ω_{2}, . . . , ω_{c}} - by allowing actions other than merely deciding the state of nature
: a finite set of actions. We now allow the possibility of rejection or no decision in close cases when these actions are not too costly.*{α*_{1}, α_{2}, . . . , α_{a}} - by introducing a loss function
*more general*than the probability of error;: denotes a*λ(α*_{i}|ω_{j}) , i = 1, 2, . . . , a and j = 1, 2, . . . , c*loss function*that describes loss for taking actionwhen the of the x value is*α*_{i}*ω*_{i}

Bayesian decision theory assumes we fully know:

: class conditional probability density function or likelihood*P(x|ω*_{j}), j = 1, 2, . . . , c: prior probabilities, and*P(ω*_{j}), j = 1, 2, . . . , c- Posterior probabilities
can be calculated using the Bayes formula mentioned above, where now the evidence is*P(ω*_{i}|x) ; j = 1, 2, . . . , c

Suppose that we observe a particular ** x** and that we take action

**.**

*α*_{i}If the actual state of nature is ** ω_{j} **, the loss is

**. Since P(ω**

*λ(α*_{i}|ω_{j})_{j}|x) is the probability that the actual state of nature is

**, the expected loss associated with taking action**

*ω*_{j}**is**

*α*_{i}*R(α _{i}|x) = [ λ(α_{i}|ω_{j} )P(ω_{j} |x) integrated over values of j=1 to c ]*.

The expected loss is called a ** risk**, and

**is called**

*R(α*_{i}|x)**. For a particular observation x, we can minimize our expected loss by selecting the action that minimizes the conditional risk.**

*conditional risk***Decision Rule in generalized setup**

In this generalized setup, our problem is to find a decision rule against * P(ω_{j} )* that minimizes the overall risk. A general decision rule

**that tells us which action (from**

*is a function α(x)***) to take**

*α*_{1}, … , α_{a}**observation.**

*for every possible*Clearly, if ** α(x)** is chosen so that

**is as small as possible for every**

*R( α*_{i}(x) )*, then the overall risk will be minimized; this justifies the following statement of the Bayes decision rule:*

**x**To minimize the overall risk, compute the conditional risk

(as defined above) forR(α_{i}|x)and select the actioni = 1,…, afor whichα_{i}is minimum.R( α_{i}|x)

The resulting minimum overall risk is called the ** Bayes risk**, denoted

**, and is the best performance that can be achieved.**

*R*^{∗}**A two-category Classification and selection threshold:**

Consider a two-class state, Let

– action deciding that the true state of nature is*α*_{1}, and*ω*_{1}– action deciding that the true state of nature is*α*_{2}.*ω*_{2}, the loss incurred for selecting*λ*_{ij}= λ(α_{i}|ω_{j})when the true state of nature is*ω*_{i}.*ω*_{j }

The *Bayes risk* for any observation ** x** then becomes

; if we chose*R(α*_{1}|x) = λ_{11}P(ω_{1}|x) + λ_{12}P(ω_{2}|x)and*ω*_{1}; if we chose*R(α*_{2}|x) = λ_{21}P(ω_{1}|x) + λ_{22}P(ω_{2}|x)*ω*_{2}

Then the updated decision rule is

Decide

ifω_{1}R (α_{1}|x ) < R (α_{2}|x )or Decide

ifω_{1}λ_{11}P(ω_{1}|x) + λ_{12}P(ω_{2}|x) < λ_{21}P(ω_{1}|x) + λ_{22}P(ω_{2}|x )

** λ_{21} = λ(α_{2}|ω_{1} )** is the loss incurred for being wrong, and

**is the loss incurred for being right. Ordinarily, the loss incurred for making an error is**

*λ*_{11}= λ(α_{1}|ω_{1})*greater*than the loss incurred for being correct, and both factors

**and**

*λ*_{21}− λ_{11}**are positive.**

*λ*_{12}− λ_{22}Rearranging the rule:

Decide ** ω_{1}** if

*(λ*_{21}− λ_{11}) P(ω_{1}|x ) > (λ_{12}− λ_{22}) P(ω_{2}|x )Using the *Bayes theorem* we write the previous strategy in terms of prior and likelihood:

Decide

if:ω_{1}(

λ_{21}− λ_{11}) P(ω_{1}) P(x|ω_{1}) > (λ_{12}− λ_{22})P(ω_{2}) P(x|ω_{2})⇒

] / [P(x|ω_{1}) / P(x|ω_{2}) > [ (λ_{12}− λ_{22})P(ω2)](λ_{21}− λ_{11}) P(ω1)⇒

>likelihood ratioquantity independent of x⇒

, whereψ(x) > cψ(x) = P(x|ω_{1}) P(x|ω_{2})

Bayes rule can thus be interpreted as deciding ** ω_{1}** if the

**exceeds a**

*likelihood ratio***independent of**

*threshold value***.**

*x*The assumption is that we know the conditional class densities. In a practical setting, we *learn* likelihood from the training dataset. That is, the threshold ** c** acts as prior, and

**acts as a classifier whose parameters are to be learned from the data.**

*ψ(x)***Loss functions**

Regression tasks use loss functions such as quadratic and linear difference, where there is a natural ordering of the predictions. Predictions that are “more wrong” than others can meaningfully be penalized. The symmetrical or ** zero-one loss function** adopts a more straightforward approach, assigning no loss to a correct decision and assigning a unit loss to any error; thus, all mistakes are equally costly.

With a zero-one loss function, the error ** R(a_{i}|x )** becomes the sum of the probability that the state is not equal to

**or**

*i***. The Bayes decision rule to minimize risk means selecting the action that minimizes the conditional risk. Hence, to minimize the average probability of error, we should choose the**

*1 – P(ω*_{i}|x )**that maximizes the posterior probability P(ωi|x). In other words, for minimum error rate:**

*i*** Decide ω_{i} if P(ω_{i}|x ) > P(ω_{j} |x ) for all j not equal to i**.

This is the same rule seen above with posterior probabilities.

We saw class-conditional probability densities and the posterior probabilities in the red and black lines above for the two-class case. The picture below shows the *likelihood ratio* ** p(x|ω_{1})/p(x|ω_{2})** for the same case. The threshold value

**marked is from the same prior probabilities but with a zero-one loss function.**

*θ*_{a}If we penalize mistakes in classifying ** ω_{1}** patterns as

**more than the other way round, or**

*ω*_{2}**, the threshold**

*λ*_{21}> λ_{12}**results. Naturally, the range of**

*θ*_{b}**values for which we classify a pattern as**

*x***gets smaller.**

*ω*_{1}**Disclaimer**:

*I currently work full-time at Swiss Re, Bengaluru. The blogs and articles on this website **www.balajos.com** are the personal posts of myself, Balachandra Joshi, and only contain my personal views, thoughts, and opinions. It is not endorsed by Swiss Re (or any of my formal employers), nor does it constitute any official communication of Swiss Re.*

*Also, please note that the opinions, views, comprehensions, impressions, deductions, etc., are my takes on the vast resources I am lucky to have encountered. No individuals or entities, including the Indian Institute of Science and NSE Talent Sprint who have shown me where to research, or the actuarial professional bodies that provide me continuous professional growth support, are responsible for any of these views; and these musings do not by any stretch of imagination represent their official stands; and they may not subscribe/support/confirm any of these views and hence can be held liable in any vicarious way. All the information in the public space is shared to share the knowledge without any commercial advantages.*