## 2 Materials and Methods
### Weighted Confusion Matrix Utility Metric  
In healthcare applications such as grading knee osteoarthritis severity, where classes range from 0 (healthy) to 4 (severe osteoarthritis), it is pivotal to emphasize accurate prediction of the endpoints, namely the healthy state and the severely affected state. Misclassifications that confuse healthy knees with osteoarthritis states or vice versa may lead to adverse clinical decisions. To address this concern, a novel metric is introduced, termedthe _Weighted Endpoint Accuracy Score (WEAS)_, for evaluating the usefulness of confusion matrices in multi-class classification tasks.  
Let \(M(i,j)\) denote the \((i,j)\)-th element of the confusion matrix, corresponding to the number of instances with true class \(i\) predicted as class \(j\). The per-class accuracy is defined as  
\[\text{Acc}_{i}=\frac{M(i,i)}{\sum_{j}M(i,j)},\quad i=0,1,\ldots,n, \tag{29}\]  
where \(n\) is the highest classification index (i.e., \(n=4\) in this study's knee osteoarthritis with example).  
To reflect clinical priorities, a heavier weight \(w\) is assigned to the endpoint classes (i.e., classes 0 and \(n\)) and a weight of 1 to all intermediate classes (\(1\leq i\leq n-1\)). The overall metric is computed as:  
\[\text{WEAS}=\frac{w\cdot\text{Acc}_{0}+\sum_{i=1}^{n-1}\text{Acc}_{i}+w\cdot \text{Acc}_{n}}{2w+(n-1)}. \tag{30}\]  
For instance, in the case of grading knee osteoarthritis (with \(n=4\)), choosing \(w=2\) (or another clinically-motivated value) ensures that high accuracy in classifying a healthy knee (class 0) and a severely affected knee (class 4) substantially influences the overall metric. This metric is designed to capture the clinical utility of the model by highlighting performance in the most critical classification regions.  
Furthermore, the metric can be extended to incorporate a misclassification penalty based on the distance between true and predicted classes. Let a penalty function be defined as  
\[d(i,j)=|i-j|, \tag{31}\]  
which imposes larger penalties for misclassifications that deviate further from the true class. A composite utility function can then be formulated as  
\[U=\lambda\cdot\text{WEAS}-(1-\lambda)\cdot\text{Penalty}, \tag{32}\]  
with \(\lambda\in[0,1]\) balancing the trade-off between the weighted endpoint accuracy and the overall misclassification cost.  
By adopting the WEAS and its extensions, the proposed metric enhances the evaluation of machine learning models in healthcare settings, ensuring that models which excel in distinguishing clinically essential endpoints are favored, thereby better aligning performance measures with clinical decision-making requirements.  
Summary of Notation  
For clarity, we summarize below the notation and symbols used in Equations (29)-(32) and throughout the manuscript:  
* \(M(i,j)\): Element in the \(i\)-th row and \(j\)-th column of the confusion matrix, indicating the number of samples with true class \(i\) predicted as class \(j\).
* \(n\): Highest class index (e.g., \(n=4\) for five classes labeled 0 to 4).
* \(Acc_{i}\): Per-class accuracy for class \(i\).
* \(w\): Weight assigned to endpoint classes (\(i=0\) and \(i=n\)) to emphasize their clinical importance; all other classes have weight 1.
* WEAS: Weighted Endpoint Accuracy Score, as defined in Equation (30).
* \(d(i,j)\): Penalty function, defined as the absolute difference \(|i-j|\) between true and predicted class.  
* \(U\): Composite utility function, combining WEAS and the misclassification penalty, as defined in Equation (32).
* \(\lambda\in[0,1]\): Trade-off parameter that balances the emphasis between WEAS and the misclassification penalty.
* \(\sum\): All summations are taken over the specified class indices as indicated in the equations.