Why Priors and Costs Both Matter
A classifier does more than decide which class makes an observation more likely. It must also account for how common each class is before observing the data and, when appropriate, how costly each kind of wrong decision is. These adjustments can change the chosen class even when one class has the larger posterior probability.
For a binary problem, label the classes 1 and 2. Write \(\pi_k=P(Y=k)\) for the prior probability of class \(k\), and \(f_k(x)\) for the density of an observation \(X=x\) under that class. The likelihood ratio \(f_2(x)/f_1(x)\) compares how well the observation fits the two class models. Posterior odds also incorporate the prior odds \(\pi_2/\pi_1\). A cost-sensitive decision then compares those posterior odds with a threshold determined by the two error costs.
From Posterior Odds to a Cost-Sensitive Rule
Bayes' rule gives the posterior odds in a useful product form. For observations where both class densities are positive,
The first factor is the likelihood ratio; the second is the prior odds. To choose a class under the stated costs, compare the conditional losses of the two possible decisions.
To prove the rule, abbreviate \(p_k=P(Y=k\mid X=x)\). Choosing class 1 has conditional loss \(C_{1|2}p_2\), because this decision incurs a cost only if class 2 is true. Choosing class 2 has conditional loss \(C_{2|1}p_1\). Thus class 2 has smaller loss exactly when
Substituting the posterior-odds identity gives the likelihood-ratio version. Replacing the strict inequality by equality gives the tie case. \(\square\)
The two thresholds answer different comparisons. The posterior-odds threshold compares the posterior odds directly with the cost ratio. The likelihood-ratio threshold also includes the prior odds, because the likelihood ratio alone does not reflect how prevalent the classes are.
The Threshold for Equal-Variance Gaussian Classes
Suppose the observation is one-dimensional and the class distributions are Gaussian with a shared variance: \(X\mid Y=k\sim N(\mu_k,\sigma^2)\), where \(\sigma^2>0\). If \(\mu_2>\mu_1\), the log likelihood ratio increases with \(x\), so the cost-sensitive rule has a single threshold: observations above it are assigned to class 2.
For a complete derivation, the Gaussian density has the same normalizing constant in both classes, so it cancels in the ratio. Taking logarithms and expanding the squares gives
The cost-sensitive likelihood-ratio rule requires this log ratio to exceed \(\log\!\left(\frac{C_{2|1}\pi_1}{C_{1|2}\pi_2}\right)\). Since \((\mu_2-\mu_1)/\sigma^2\) is positive, solving that inequality for \(x\) gives the stated threshold and preserves the inequality direction. \(\square\)
The midpoint of the two means is the threshold only when the quantity inside the logarithm is 1. Unequal priors or unequal error costs generally move it. If \(\mu_2<\mu_1\), the log likelihood ratio decreases with \(x\), and solving the same inequality reverses the direction of the resulting one-sided decision.
Worked Calculations
Worked Example: A More Likely Class Is Not Always the Decision
Suppose \(X\mid Y=1\sim N(0,1)\) and \(X\mid Y=2\sim N(2,1)\), with priors \(\pi_1=0.7\) and \(\pi_2=0.3\). Let \(C_{2|1}=4\) and \(C_{1|2}=1\). Classify an observation \(x=1.5\).
For these means and variance, the log likelihood ratio is \(\log(f_2(x)/f_1(x))=2(x-1)\). At \(x=1.5\), it equals \(1\), so the likelihood ratio is \(e\), approximately \(2.718\). The posterior odds for class 2 over class 1 are therefore
Thus \(P(Y=2\mid x)=1.165/(1+1.165)\approx0.538\), and \(P(Y=1\mid x)\approx0.462\). Class 2 has the larger posterior probability. But the cost-odds threshold is \(C_{2|1}/C_{1|2}=4\), and \(1.165<4\), so the cost-sensitive rule chooses class 1.
Checking the conditional losses confirms the decision: choosing class 1 costs \(1(0.538)=0.538\) in posterior expected loss, while choosing class 2 costs \(4(0.462)=1.848\). The less probable class is the lower-cost decision here.
Worked Example: Locating a Threshold Shifted by Priors and Costs
Let \(X\mid Y=1\sim N(-1,4)\) and \(X\mid Y=2\sim N(1,4)\), with \(\pi_1=0.25\), \(\pi_2=0.75\), \(C_{2|1}=2\), and \(C_{1|2}=5\). Find the threshold and classify \(x=-4.2\) and \(x=-3.8\).
The likelihood-ratio threshold is \(\frac{C_{2|1}\pi_1}{C_{1|2}\pi_2} =\frac{2(0.25)}{5(0.75)}=\frac{2}{15}\approx0.1333\). Here \(\mu_2-\mu_1=2\), the variance is 4, and the midpoint is 0. Hence
Because \(\mu_2>\mu_1\), choose class 2 above this threshold and class 1 below it. For a direct check, the log likelihood ratio is \(x/2\). At \(x=-4.2\), it is \(-2.1\), giving a likelihood ratio of about \(0.1225<0.1333\); choose class 1. At \(x=-3.8\), it is \(-1.9\), giving a likelihood ratio of about \(0.1496>0.1333\); choose class 2. The threshold lies below the midpoint because class 2 has a larger prior and choosing class 1 when class 2 is true has the larger error cost.
Worked Example: Posterior Odds in a Two-Dimensional Gaussian Model
Let \(X\in\mathbb{R}^2\). Suppose \(X\mid Y=1\sim N_2((0,0),I)\) and \(X\mid Y=2\sim N_2((2,1),I)\), where \(I\) is the \(2\times2\) identity matrix. Set \(\pi_1=0.2\), \(\pi_2=0.8\), \(C_{2|1}=3\), and \(C_{1|2}=2\). Classify \(x=(1,2)\).
The shared covariance and Gaussian density formula give \(\log(f_2(x)/f_1(x))=(2,1)^\mathsf{T}x-\frac12(2^2+1^2)\). At \(x=(1,2)\), this is \(2(1)+1(2)-2.5=1.5\). Thus the likelihood ratio is \(e^{1.5}\approx4.4817\), and the posterior odds are
The posterior probability of class 2 is \(17.9268/(1+17.9268)\approx0.9472\). The cost-odds threshold is \(3/2=1.5\), so the rule chooses class 2. The conditional loss of choosing class 1 is \(2(0.9472)\approx1.8944\); that of choosing class 2 is \(3(1-0.9472)\approx0.1584\). The calculation verifies the decision using both posterior odds and conditional loss.
A Practical Decision Sequence and a Common Pitfall
Compare the class densities at the observed value, or calculate their log ratio when that is simpler.
Multiply the likelihood ratio by \(\pi_2/\pi_1\) to obtain posterior odds for class 2 over class 1.
Choose class 2 only when its posterior odds exceed \(C_{2|1}/C_{1|2}\); equality gives a tie.
A common mistake is to compare the likelihood ratio directly with the cost ratio and stop. That omits the priors: the likelihood-ratio threshold is \(\frac{C_{2|1}\pi_1}{C_{1|2}\pi_2}\), not merely \(\frac{C_{2|1}}{C_{1|2}}\). The cost ratio alone is the threshold for posterior odds, after prior information has already been incorporated. Another mistake is to choose whichever class has posterior probability above one half automatically. That is valid only when the two misclassification costs are equal.
In practice, these calculations make explicit how prevalence and the consequences of different errors shape a classification boundary. In the one-dimensional equal-variance model, their combined effect is a shift from the midpoint between the means. In the multivariate shared-covariance model, the log likelihood ratio is linear in the observation, so changing the priors or costs changes the decision threshold for that linear score.
Check Your Understanding
Use posterior odds and conditional losses to justify each decision.
- If the posterior odds for class 2 over class 1 are 3, and \(C_{2|1}=6\), \(C_{1|2}=2\), which class is chosen?
- In the equal-variance Gaussian threshold formula, what happens to the threshold when \(\pi_2\) increases while all other quantities stay fixed?
- For the model in the first worked example, what posterior-odds value produces a tie between the two decisions?
- Why is the likelihood-ratio threshold not generally equal to the cost ratio?
- If \(\mu_2<\mu_1\), does increasing \(x\) make the likelihood ratio \(f_2(x)/f_1(x)\) increase or decrease?