# Improved Surprise Adequacy Tools for Corner Case Data Description and Detection
## 3 Corner Cases Detection Based on SA
### Distance-Based SA and Its Modification
For example, assuming the testing data \(x\) is the corner-case data, there happens to exist a neighbor \(x_{a}\) very close to \(x\), namely \(x\approx x_{a}\), since the above DSA are calculated based on the distance of point-to-point, this may lead DSA to be a low value due to \(dist_{a}\to 0\), as shown in \[dist_{a}=\|a_{N}(x)-\alpha_{N}(x_{a})\| \tag{5}\]0 In this case, the novelty of \(x\) with respect to training data is regarded as small based on SA definition. However, this result causes novel inconsistent behavior in the data for the corner case. Furthermore, this result will be meaningless for corner case study as well. Therefore, a possible modification based on the first modification is to select a more general class descriptor for surprise calculation. In [29], the class centers were commonly used as feasible global descriptors. Hence, we can replace the nearest neighbor with the class center in surprise calculation, and the new equations can be written as below  
\[dist_{a}=\|a_{N}(x)-\alpha_{N}(x_{a})\| \tag{5}\]1  
\[dist_{a}=\|a_{N}(x)-\alpha_{N}(x_{a})\| \tag{5}\]2  
where \(m_{a}\) is the center of the class which \(x\) belongs to; \(m_{b}\) is the center of a different class \(c_{b}\) (\(c_{b}\
eq c_{x}\)) which the closest point \(x_{b}\) to \(x\) belongs to. For each \(s\in\{a,b\}\), the center point \(m_{s}\) is calculated by  
\[dist_{a}=\|a_{N}(x)-\alpha_{N}(x_{a})\| \tag{5}\]3  
\[dist_{a}=\|a_{N}(x)-\alpha_{N}(x_{a})\| \tag{5}\]4 The first modification of DSA. (**a**) specific case. (**b**) modification. Then, the newly modified DSA can be calculated as \(dist_{a}/dist_{b}\). Its diagram is shown in Figure 4b. (3) Modification 3: novelty calculation via local data descriptors  
In the above modification of DSA, the characteristic of a class is simply described by the class center. However, corner-case data usually have some obvious characteristics of closing to boundary or outlier location. Class centers are good global descriptors of classes, but not effective to capture local characteristics, e.g., in reflecting the characteristics of corner case data in imbalanced data (as shown in Figure 5a). In this paper, to modify DSA for corner case data detection, we propose to replace the global descriptors with local descriptors, e.g., the center of the nearest neighborhood shown in Figure 5b. The DSA of testing data \(x\) can be still calculated via (11), (12) and (8), while the calculation of the center \(m_{s,\delta}\) for each \(s\in\{a,b\}\) should be modified as  
\[dist_{a}=\|a_{N}(x)-\alpha_{N}(x_{a})\| \tag{5}\]5  
where \(X_{s,\delta}\) (\(\subseteq X_{s}\)) represents the neighborhood set of inputs included in the hyper-sphere whose center is \(x_{s}\) and radius is \(\delta\), namely several nearest neighbors of \(x_{s}\). Here, two methods of determining the neighborhood set are provided. One kind of neighborhood is denoted by a given size of Euclidean round (i.e., the same radius \(\delta\) for all inputs is used), as follows  
\[dist_{a}=\|a_{N}(x)-\alpha_{N}(x_{a})\| \tag{5}\]6  
where, \(x_{a}\) (\(s=a\)) and \(x_{b}\) (\(s=b\)) are inputs explained in the previous Modification 2 and \(X_{s}\) is the set defined in (13). An alternative definition of the nearest neighborhood is determined by \(k\)-nearest points [30]. In this case, the radius \(\delta\) is given for each \(x_{s}\) such that \(X_{s}\) includes only \(k\) nearest neighbors of \(x_{s}\) (i.e., \(|X_{s,\delta}|=k\)) and therefore  
\[dist_{a}=\|a_{N}(x)-\alpha_{N}(x_{a})\| \tag{5}\]7  
where, \(x_{i_{j}}\in X_{s}\) is the \(j_{th}\) nearest point to \(x_{s}\). \[dist_{a}=\|a_{N}(x)-\alpha_{N}(x_{a})\| \tag{5}\]8 The second modification of DSA. (**a**) specific case. (**b**) modification.