Method for calculating a confidence score, associated with the result of inference data processing by a model

The method calculates confidence scores by measuring lens depth with optimized Fermat Distance, addressing limitations of existing methods by capturing complex cluster geometries and densities, ensuring accurate uncertainty estimation and anomaly detection.

FR3158815A1Pending Publication Date: 2025-08-01AMPERE SAS +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
FR2024000966
Authority / Receiving Office
FR · FR
Patent Type
Applications
Current Assignee / Owner
Filing Date
2024-01-31
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

Existing methods for calculating confidence scores in machine learning models, particularly for out-of-distribution data, are limited by restrictive assumptions about data distribution, computational intensity, and impact on model performance, failing to effectively capture complex cluster geometries and densities.

Method used

A method using optimized Fermat Distance to measure lens depth in the representation space of machine learning models, considering the density and geometry of clusters, without altering the model architecture, to calculate a confidence score.

Benefits of technology

This approach provides stable and accurate uncertainty estimates across various data sets, maintaining model performance and enabling efficient anomaly detection without additional trainable parameters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000_ABST
    Figure 00000000_0000_ABST
Patent Text Reader

Abstract

The invention relates to a method for calculating a confidence score (SC), associated with the result of a processing of inference data (DI) by a Machine Learning Model (MA), by considering a distribution of points (20) in a representation space (10) of the Model (MA). The distribution of points (20) comprises: at least one cluster of points (21; 21, 22) resulting from the processing of training data (DA) by the Machine Learning Model (MA), and at least one point to be evaluated (30) resulting from the processing of the inference data (DI) by the Machine Learning Model (MA). The point to be evaluated (30) has a depth (P1; P1, P2) measurable with respect to each cluster of points (21; 21, 22).The method comprises the following steps: A) for each cluster of points (21; 21, 22), evaluating the depth (P1; P1, P2) of the point to be evaluated (30) with respect to a selection of points (25; 25, 26) of this cluster of points (21; 21, 22), following the statistical technique of the Lens Depth (PL) calculated using as distance measure an optimized Fermat Distance (DF), taking into account the density and the geometry of each cluster of points (21; 21, 22); where the optimized Fermat Distance (DF) is defined as follows: DFQ,α(x,y) = min { |x-q1|α + α : (q1,…,qk) ∈ Qk with qk = y and k ≥ 1} ; then B) define the confidence score (CS) associated with the result of the inference data processing (ID), as being a maximum depth (MD) of the point to be evaluated (30). Abstract figure: figure 5.
Need to check novelty before this filing date? Find Prior Art

Description

Title of the invention: Method for calculating a confidence score, associated with the result of processing inference data by a model Technical field

[0001] The present invention relates to a method for calculating a confidence score, associated with the result of processing inference data by a Machine Learning Model.

[0002] The field of the invention is that of inference data processing. Prior art

[0003] Generally speaking, current methods for dealing with classification problems are based on neural networks terminated by an activation layer, most often of the softmax type (softmax model, i.e. with a normalized exponential function). This framework has proven to be very effective in terms of accuracy, in particular thanks to the creation of increasingly numerous and comprehensive training databases. However, in addition to performance on training data, the importance of generalizing the learned models is crucial, and in particular in critical applications, it is relevant to detect so-called out-of-distribution (OoD) data, i.e. intuitively, data that is too far from the training data.Generally, we want to associate a confidence (or uncertainty) score with this OoD data in order to be able to reject uncertain predictions because they are made on data that are too far removed from the data used when training the neural network. This is called out-of-domain uncertainty (Gawlikowski et al., 2023).

[0004] The invention aims to develop a method that can be applied directly to a model and provides a confidence score. In addition, we wish to preserve the training mechanism and the model architecture. In this way, the model's performance will be preserved. A desirable property for any well-trained neural network (or more classical machine learning model) is the preservation of data geometry. In other words, similar data should be close in the representation space and different data should be far apart. Intuitively, with this property, each class should be represented as a different cluster in the representation space. In addition, data that are different from the training data should be far apart from any cluster obtained on the training data in the representation space.

[0005] Assuming this desirable property of a classification model, a method Directly measuring "how far away" a point is from clusters taking into account the density and geometry of each cluster in the representation space should provide an uncertainty score. Moreover, an ideal scoring method should be directly applicable to the representation space of a standard softmax model. Therefore, we can take advantage of the performance of well-developed standard softmax models.

[0006] A common method is to fit a Gaussian model (Lee et al., 2018) and then calculate the minimum Mahalanobis distance (Mahalanobis, 2018) from the different clusters as an indicator to distinguish the distribution of OoD data. This approach is based on the following assumptions: (1) in the feature space of the trained model, each class forms a separate cluster and (2) each cluster simply follows a multivariate Gaussian distribution. The first assumption has been largely proven by experiments in several previous works showing that deep neural networks transform inputs of different classes into different clusters in the representation space (see Yang et al. (2017), Caron et al. (2018)). However, the assumption that the data in a cluster are Gaussian distributed or follow a particular distribution is quite restrictive.As shown later in the description, the Gaussian assumption fails even in a very simple case. This motivates a method capable of capturing more complex clusters without any prior distribution assumptions.

[0007] One way to handle uncertainty in the neural network is its Bayesian modeling (see Kwon et al. (2020), Kendall & Gai (2017)). The Bayesian approach provides a principled method for modeling uncertainty in a well-defined probabilistic framework. However, this approach has a major drawback. Indeed, integration with respect to the previous in a very high-dimensional space is required to obtain the final result.

[0008] Another common approach is the Deep Ensemble method (see (Lakshminarayanan et al., 2017)). Here, many independently trained models are applied to the same task. Then, uncertainty is measured using the predictions obtained with these models. This approach is popular because it is simple to implement. However, it requires significant computational resources for both training and inference.

[0009] Dropout sampling (Gai & Ghahramani, 2016) can be considered as a version of deep ensembles. In this case, the replicated models are much more correlated because they share a large part of common parameters. In Prior Networks, the prior distribution is applied on the model output (see Malinin & Gales (2018)). However, since we place a prior distribution on the predictive distributions, the result is limited and, therefore, the performance may be affected.

[0010] Another approach is to measure the “degree centrality” of a point with respect to the different clusters in the representation space. This could be done using the geometry and distributions of these clusters. In this direction, the distance-based method and the density-based method can be grouped into the same class. One of the simplest methods is to use the nearest neighbor distance (Sun et al., 2022). This is very simple but has the disadvantage of completely ignoring the geometry of the clusters.

[0011] A more sophisticated approach uses the Mahalanobis maximum distance (Mahalanobis, 2018). Here, each cluster in the representation space is modeled as a multivariate Gaussian distribution (Lee et al., 2018). Despite taking the distribution into account, Gaussian modeling is too restrictive because it leads to an ellipsoid to shape each cluster. These latter methods are independent of the network training process. Therefore, the model performance is not affected. This is not the case for the deterministic uncertainty quantification method (Van Amersfoort et al., 2020) built on the ideas of RBF (radial basis function) networks. This approach requires training a specific type of model, which makes it difficult to maintain model performance.In the density-based approach, one solution is to train an additional calibration model (e.g. Kuleshov & Deshpande (2022). . But the construction of the recalibration model itself can have an impact on the estimation of uncertainty.

[0012] Another approach to capturing cluster geometry is the one-class SVM (Schôlkopf et al., 1999). It learns a decision function for novelty detection: it classifies new data as similar to or different from the training set. This method has some similarities with the invention, in that both essentially measure the “distance” of a point to the “boundary” between in-distribution and out-of-distribution data, naturally taking into account the cluster geometry. However, the effectiveness of the SVM approach is strongly influenced by the choice of the kernel and its hyperparameters. Disclosure of the invention

[0013] The aim of the present invention is to propose a method for calculating a confidence score which is improved compared to existing methods.

[0014] To this end, the invention relates to a method for calculating a confidence score, associated with the result of processing inference data by a Machine Learning Model, by considering a distribution of points in a representation space of the Machine Learning Model, where the distribution of points understand : - at least one cluster of points (also called cluster) resulting from the processing of training data by the Machine Learning Model and - at least one point to be evaluated resulting from the processing of inference data by the Machine Learning Model during an inference phase; where the point to be evaluated has a measurable depth relative to the or each cluster of points; characterized in that the method comprises the following steps: A) for the or each cluster of points, evaluate the depth of the point to be evaluated relative to a selection of points in this cluster of points, following the statistical technique of Lens Depth calculated using as a distance measure an optimized Fermât Distance, taking into account the density and geometry of the or each cluster of points; where: - Rd is the set of real numbers of dimension d describing the representation space (10), - Q is a finite, local and non-empty subset of Rd, - xe Rd, -yeQ, - Ixl is the Euclidean form of x, - a is a hyperparameter > 1, The optimized Fermât Distance (FD) is defined as follows: DFQ>a(x,y) = min { Ix-q^ + y*-1, _ p: (qb...,qk) e Qk with qk = y and k > 1}, then B) define the confidence score associated with the result of the inference data processing, as being a maximum depth of the point to be evaluated, where: Bl) when the distribution of points comprises a single cluster of points, the maximum depth is the depth evaluated with respect to a selection of points of this cluster of points, or B2) when the point distribution comprises several clusters of points, the maximum depth is defined among the depths evaluated with respect to a selection of points from each cluster of points.

[0015] Thus, the invention makes it possible to improve the calculation of confidence score, compared to existing methods. The invention makes it possible to obtain excellent qualitative results on a restricted data set and can give competitive or improved uncertainty estimates on large data sets, compared to recognized reference methods. The method includes a single hyperparameter to tune. Moreover, the results are stable with respect to this hyperparameter. The method is applicable to all Deep Learning Models, for example, neural networks, without changing the learning process and architecture of these Models. The model can be a softmax model, i.e. a normalized exponential function. The method is implemented without making any initial assumptions about the shape of the point distribution. In addition, the method is implemented without using any trainable parameter belonging to the Machine Learning Model.

[0016] According to other advantageous characteristics of the invention, taken in isolation or in combination:

[0017] - The or each selection of points comprises at least 20% of the cluster of points corresponding, selected randomly or according to a predefined mathematical rule.

[0018] - The or each selection of points comprises 100% of the corresponding cluster of points laying.

[0019] - The distribution of points includes several points to be evaluated resulting from the processing of inference data by the Machine Learning Model during the inference phase, and in that steps A) and B) are carried out successively: - either on all points to be assessed; - either on a selection of points from among all the points to be evaluated.

[0020] Step B) is carried out directly in the representation space of the Machine Learning Model, without intervening in the learning process of the Machine Learning Model.

[0021] - The optimized Fermât Distance is defined with a > 1.2.

[0022] - The optimized Fermât Distance is defined with a > 2.

[0023] The invention also relates to a method for detecting anomalies, comprising the implementation of the method for calculating a confidence score mentioned above, followed by a step C), consisting of comparing the inference data with a set of reference data among the learning data, then a step consisting of classifying the inference data, either in an existing category, or in a category outside the domain.

[0024] The invention also relates to a method for training a Machine Learning Model, comprising the implementation of the anomaly detection method mentioned above, then a step E) of modifying the training data set by integrating at least certain inference data from the out-of-domain category into the existing category. Description of figures

[0025] The invention will be better understood on reading the description which follows, given solely by way of non-limiting example and made with reference to the attached drawings on which:

[0026] [Fig. 1] is the representation in two planes of a capture of points belonging to clusters in the shape of half-moons, according to the Mahalanobis method on the left (fig. 1a) and according to the method of the invention on the right (fig. 1b).

[0027] [Fig.2] is the two-plane representation of the lens depth (LD) using the Euclidean distance, for a Gaussian distribution on the left (fig. 2a) and a half-moon on the right (fig. 2b).

[0028] [Fig.3] is the representation of different Fermât paths between two fixed points randomly chosen from a half-moon cluster, using different values of hyperparameter a.

[0029] [Fig.4] is the representation of an empirical lens depth (LD) calculation, in using the sampled Fermât distance, for a half-moon cluster.

[0030] [Fig.5] is a graph showing steps A) and B) of the calculation method according to the invention, as well as steps C) and D) of an anomaly detection method, and step E) of a learning method, with the parameters associated with each step.

[0031] [Fig.6] is a representation of an empirical lens depth (LD) calculation, using the optimized Fermât distance (FD), with a half-moon cluster and a spiral cluster.

[0032] [Fig.7] is a representation of an empirical lens depth (LD) calculation, using the optimized Fermât distance (FD), shows the results of four trials performed by stimulating the spiral dataset with 1000 points and then randomly choosing only 20% of the simulated points as the data sample to calculate the lens depth (LD).

[0033] [Fig.8] is a representation of an empirical lens depth (LD) calculation, using the optimized Fermât distance (FD), with different values of the hyperparameter a.

[0034] [Fig.9] is a representation of the results obtained using different methods. Detailed description of the invention

[0035] [Fig.l] shows the example of a simple distribution of points (20) in a representation space (10) of type R2, with two clusters (21, 22) corresponding to two half-moon shaped classes. In this example, the Mahalanobis distance (fig. la) based on the Gaussian hypothesis does not fully capture the distribution of the clusters (21, 22), whereas the method according to the invention (fig. 1b) represents very well the centrality of a point (30) with respect to the clusters (21, 22).

[0036] This motivates to develop a non-parametric method that can measure how "central" a point (30) is with respect to a cluster (21) or to each cluster (21, 22) of a distribution of points (20), without needing to optimize a model en- trainable plus auxiliary. Furthermore, the method must accurately capture the (20) distribution with complex support and shape, and thus be suitable for a variety of cases. To determine how central a (30) point is with respect to a (20) distribution, we use the so-called statistical lensing depth (LD) notion (Liu, 1990), which will be introduced later. Furthermore, for the LD to correctly capture the shape of the (20) distribution, an appropriate distance must be adopted, which adaptively takes into account its geometry and density. The Fermât distance (FD) is a good candidate for this purpose. However, the Fermât distance (FD) is not directly tractable because it relies on integrals along rectifiable paths. A recent paper by Groisman et al. (2022) proposes the use of an explicit sampled Fermât distance (FD) (see also Cholaquidis et al. (2023)).The authors show that this sampled distance systematically estimates the Fermât distance (FD). In the context of the present invention, their results are used to calculate the lens depth (LD).

[0037] In summary, the contribution of the present invention is twofold: - 1) We apply the lens depth (LD) combined with the Fermât distance (FD) in the context of out-of-distribution uncertainty estimation, for classification problems in general, and in particular applied to deep learning models. For this, we first re-examine the property of the lens depth (LD) with the Fermât distance on simple visual examples. This allows us to highlight an artifact effect when directly using the sampled Fermât distance (FD) to estimate the lens depth (LD). Based on these observations, we propose the necessary improvements for a more appropriate estimation. - 2) We propose a simple strategy to significantly reduce the complexity of lens depth (LD) calculation. We show in our experiments that this simple strategy is very effective.

[0038] Lens depth (LD) (Liu, 1990) is a specific notion of a more general quantity called Depth (Tukey, 1975). A depth is a score measure of the membership of a point (30) with respect to a distribution of points (20) in a general space (10). The greater the depth, the more central the point (30) is in the distribution (20). The lens depth (LD) of a point (30) with respect to a distribution Px is defined as the probability that this point (30) belongs to the intersection of two random balls. These balls are centered at two independent random points X and Y , both having the distribution Px and a radius equal to the distance between X and Y . More formally, if we work on a space Rd, the lens depth (LD) of a point x with respect to the distribution Px is defined as follows: LD(x,Px) = P (xe B1 ❖ B2), (xe Rd) (1) where: • d is a distance given on Rd, • XbX2 are independent and identically distributed with the Px distribution, • B(p,r) is the closest ball centered on p with radius r, •B^BCX, d(X2, X1)),i=l,2. Consider A(Xb X2) = B1 ❖ B2. Equation (1) leads to the following empirical version of lens depth (LD): LDn(x) = / n\-iy , \ (2) For the empirical version, the set of intersections can be rewritten as follows: A(X„ X2) = {x : d(x, Xi) < d(X„ X2)}. (3)

[0039] Obviously, a crucial question is the choice of the distance d. The Euclidean choice must be avoided, as shown below.

[0040] [Fig.2] shows examples of lens depth (LD) using Euclidean distance. We see that in the Gaussian case, the lens depth (LD) contour lines capture the (20) distribution quite well. However, for the lunar distribution, they fail miserably. This is not surprising since Euclidean distance does not take the Px distribution into account.

[0041] This gives rise to a natural problem, as mentioned in Groisman et al. (2022): How to learn a distance that can capture both the geometry of a geometric manifold and the underlying density? The Fermât distance (FD) allows us to solve this problem.

[0042] Following the teachings of Groisman et al. (2022), let S be a subset of Rd. For a continuous and positive function f : S —> R+ , [3 > 0 and x, ys S, the Fermât distance Df.p(x, y) is defined as follows: Df.p(x, y) = infYTf,p(Y) (4) Or : r / Xr) / , / * 5 *

[0043] Here, the infimum is taken over all continuous and rectifiable paths y contained in S*, the closure of S, which begins at x and ends at y.

[0044] Sampled Fermât distance: Let Q be a non-empty, locally finite subset of Rd, serving as the data set. Ixl denotes the Euclidean norm of x, q(x) GQ is the particle closest to x in Euclidean distance (assuming uniqueness). For a > 1 and x,y G Rd, the sampled Fermât distance is defined as: DFQ>a(x,y) = min { - n / :(01,---4 / ^0 / 6) with qj = q(x), qk = q(y) and k > 1}.

[0045] Groisman et al. (2022) showed that the sampled Fermât distance, when properly scaled, converges to the Fermât distance (FD). The Fermât distance sampled from the dataset Q finds the shortened path connecting the points. The length of each path is the sum of the Euclidean distances of consecutive points on the path fed by a coefficient a.

[0046] [Fig.3] shows different values of the coefficient a. With a = 1, the shortened path between x and y is simply the line connecting q(x) and q(y) (fig. 3a). However, with a sufficiently large a, this definition of path length discards consecutive points with a large Euclidean distance, instead favoring points that are closely positioned in terms of Euclidean distance. Therefore, this allows qualifying the path through areas covered by many points (i.e., high-density areas). Moreover, since this distance also depends on the number of terms in the sum in equation (6), this forces a path to be sufficiently smooth. These two remarks show that the Fermât path naturally captures the distribution and geometry of the dataset. In [Fig. 3], we return to the example of the moon. We randomly choose two points and calculate the Fermât path. We see that with a = 1, we recover the Euclidean distance and therefore the Fermât path is simply a straight line. For a greater than 1 but not large enough (e.g., a = 1.2, Fig. 3b), the Fermât path still does not capture the orientation of the dataset. However, as a grows, the Fermât path quickly follows the orientation of the dataset. For example, with a = 3, the path follows the shape of the distribution very well.

[0047] The lens depth (LD) is now calculated, using the sampled Fermât distance instead of using the Euclidean distance. [Fig.4] shows the results of this calculation for a half-moon cluster. We see that the shape of the dataset is much better captured. However, we also observe some areas with a constant lens depth (LD) value, represented by the same color and forming an unwanted artifact.

[0048] The existence of such zones is explained by the following proposition: For xe Rd, LD(x) = LD(q(x)). In other words, the empirical lensing depth (LD) is constant over the Voronoi cells associated with Q. Suppose we have a finite number of points distinct in the plane, called sites, seeds, or generators. Each seed has a corresponding region, called a Voronoi cell, composed of all points in the plane closer to that seed than to any other. See Aurenhammer, 1991, for details.

[0049] The consequence of the last proposition is that even for a very distant point in the data set Q, the value of the lens depth (LD) remains the same as that of its nearest point in Q. Therefore, the lens depth (LD) does not vanish to infinity. This is totally undesirable, because an ideal property, regardless of depth, is to vanish to infinity. To avoid this undesirable artifact, the sampled Fermât distance should be modified so that it takes into account the distance to Q.

[0050] [Fig.5] is a diagram illustrating the implementation of a calculation method according to the invention. The method is designed to calculate a confidence score (CS), associated with the result of a processing of inference data (ID) by a Machine Learning Model (ML), by considering a distribution of points (20) in a representation space (10) of the Machine Learning Model (ML). The representation space (10) is also called latent space. The training data (LD) comprises for example several images used for training the model (ML). The inference data (ID) comprises for example an image used to obtain a prediction, when using our Model (ML). Inference is the use of the Model (ML).

[0051] The distribution of points (20) includes: - at least one cluster of points (21; 21, 22), also called cluster, resulting from the processing of learning data (LD) by the Machine Learning Model (ML) and - at least one point to be evaluated (30) resulting from the processing of inference data (ID) by the Machine Learning Model (ML) during an inference phase. The point to be evaluated (30) has a depth (PI; PI, P2) measurable relative to the or each cluster of points (21; 21, 22). The calculation method includes steps A) and B) defined below.

[0052] In step A), for the or each cluster of points (21; 21, 22), the depth (PI; PI, P2) of the point to be evaluated (30) is evaluated with respect to a selection of points (25; 25, 26) of this cluster of points (21; 21, 22), according to the statistical technique of the Lens Depth (PL) calculated using as a distance measure an optimized Fermât Distance (DF), taking into account the density and the geometry of the or each cluster of points (21; 21, 22). The following parameters are defined: - Rd is the set of real numbers of dimension d describing the representation space (10), - Q is a finite, local and non-empty subset of Rd, - xe Rd, -yeQ, - Ixl is the Euclidean form of x, - a is a hyperparameter > 1. The optimized Fermât Distance (DF) is defined as follows: DFQ>a(x,y) = min { Ix-qJ" + yi _ i “ : (qb... ,qk) e Qk(7) with qk = y and k > 1}, then

[0053] In step B), the confidence score (CS) associated with the result of the inference data processing (ID) is defined as being a maximum depth (MD) of the point to be evaluated (30). In a case Bl), when the distribution of points (20) comprises a single cluster of points (21), then the maximum depth (PM) is the depth (PI) evaluated with respect to a selection of points (25) of this cluster of points (21). In a case B2), when the distribution of points (20) comprises several clusters of points (21, 22), then the maximum depth (PM) is defined among the depths (PI, P2) evaluated with respect to a selection of points (25, 26) of each cluster of points (21, 22).

[0054] According to a particular embodiment, the or each selection of points (25; 25, 26) comprises 100% of the corresponding cluster of points (21; 21, 22). This makes it possible to obtain better calculation precision.

[0055] Alternatively, the method may be implemented with the or each point selection (25; 25, 26) comprising only a portion of the corresponding point cluster (21; 21, 22), preferably at least 20% of the corresponding point cluster (21; 21, 22). The points retained in the or each point selection (25; 25, 26) may be selected randomly or according to a predefined mathematical rule. This saves computing power.

[0056] In the case where the distribution of points (20) comprises several points to be evaluated (30) resulting from the processing of the inference data (DI) by the Machine Learning Model (MA) during the inference phase, steps A) and B) are carried out successively: - either on all points to be assessed (30); - either on a selection of points (35) among all the points to be evaluated (30). In other words, if we have several points to evaluate (30), we execute the method on each point (30), or at least some of these points (30). Steps A) and B) are carried out successively for the different points (30), one after the other.

[0057] Advantageously, step B) can be carried out directly in the representation space (10) of the Machine Learning (ML) Model, without intervening in the learning process of the Machine Learning (ML) Model. Thus, the method does not impact the performance of the original Model (ML). In particular, in the case where the Machine Learning (ML) Model is a neural network, step B) can be carried out directly from the values calculated by the penultimate layer of neurons of the neural network.

[0058] [Fig.5] also illustrates the implementation of an anomaly detection method, comprising the implementation of the calculation method according to steps A) and B), followed by a step C), consisting of comparing the inference data (DI) with a reference data set (DR) among the training data (DA), then a step D) consisting of classifying the inference data (DI), either in an existing category (CE), or in an out-of-domain category (CH). The inference data (DI) classified in the out-of-domain category (CH) are identified as anomalies and retained for further processing.

[0059] [Fig.5] also illustrates the implementation of a method for training a Machine Learning Model (MLM), comprising the implementation of the anomaly detection method mentioned above, then a step E) of modifying the training data set (LD), by integrating at least some inference data (ID) from the out-of-domain category (ODC) to the existing category (EC).

[0060] Let us return to equation (7) defining the optimized Fermât distance (DF). In the original definition Groisman et al. (2022), the Fermât path always starts from the closest point in the dataset. Therefore, the distance to this closest point is completely ignored. To eliminate this drawback, the distance to a potential starting point located in Q has been added to equation (7). Note that the optimization problem for computing the optimized Fermât distance (DF) is of the same type as that for computing the sampled Fermât distance (DF), with only a change of starting point. As a result, the consistency of this empirical Fermât distance (DF) with respect to the theoretical Fermât distance (DF) remains true. Indeed, in equation (7), the point qe Q is not fixed in q(x) but remains free and is part of the optimization problem.Furthermore, the optimized Fermât distance (FD) benefits from two interesting properties. First, if xe Q then equation (7) coincides with equation (6). . Second, the optimized Fermât distance (FD) increases to infinity as x moves away from Q. Therefore, in this case, the corresponding empirical lens depth (LD) with respect to the dataset tends to 0.

[0061] [Fig.6] shows two examples of empirical lens depth (LD) using optimized Fermât distance (FD). Two data sets with different magnitude scales are deliberately chosen to show that the lens depth (LD) can work independently of the distribution scale. The unwanted artifact present in [Fig.5] of the constant value area is erased. Moreover, for distant points in the data set, the lens depth (LD) quickly tends to 0. In conclusion, the method according to the invention ideally captures the shape of the distributions.

[0062] We experiment and evaluate the stability of the method on the spiral dataset. This is a delicate dataset, and a standard method like the Gaussian method cannot capture the shape of the distribution.

[0063] In an ideal world, when running a statistical algorithm, it is desirable to have as large a sample as possible. However, in many cases, only a very small amount of data is available. This motivates the study of the stability of the method according to the invention in a small data regime. [Fig. 7] shows the results of four trials, performed by stimulating the spiral dataset with 1000 points and then randomly choosing only 20% of the simulated points (i.e., 200 points) as the data sample to calculate the lens depth (LD). We perform different analyses for different random samples with a = 5 for visual evaluation. In all 4 trials, the method according to the invention gives a slightly different estimate of the lens depth (LD). This small fluctuation is expected, since we only take 20% of the points at random each time. Nevertheless, the method captures the shape of the dataset very well (the full sample of 1000 points is displayed in the figures).

[0064] In the method according to the invention, a single hyperparameter a governing the optimized Fermât distance (FD) is chosen. It is therefore important to evaluate the stability of the method with respect to this hyperparameter. For this, we experiment with different values of a > 1 (recall that a = 1 corresponds to the Euclidean distance).

[0065] [Fig.8] shows the results of four trials, testing the method on the spiral dataset: (a) a = 3 (b) a = 5 (c) a = 10 (d) a = 15 The conclusion is that the method according to the invention is very stable, whatever the values of a. Indeed, in all four cases, the method always captures the support of the data set almost perfectly, which implies a strong stability of the method.

[0066] The ultimate goal is to use lens depth (LD) to provide a score of out-of-distribution uncertainty. To do this, we apply the lens depth (LD) to the representation space of a neural network. More precisely, we work with the functionality of the penultimate layer just before the activation layer. In this classification setup, we have several distinct clusters. Now, there are two ways to calculate the lens depth (LD) of a new point: (1) All clusters are considered as a single distribution to calculate the lens depth (LD); (2) Calculate the lens depth (LD) with respect to the different clusters, and then take the maximum among the lens depths (LD) (i.e., the lens depth (LD) with respect to the nearest cluster). It turns out that the first approach gives unsatisfactory results. We therefore adopt the second approach.

[0067] According to equation (2), to calculate the lens depth (LD) for a given point, we first calculate its distances from all sample members in each cluster (called internal points). These are then compared to the pairwise distances of the interior points. This makes the complexity greater than O(N2). It is therefore very interesting to reduce the number of interior points used to calculate the lens depth (LD) while maintaining good accuracy. By keeping only n interior points among the initial N, we then have 3 different simple strategies: • I. Random: We randomly sample n points from N initial points without replacement. •IL K-mean / center: We want the n points to cover the support of the initial sample well. Therefore, we first apply K-mean clustering with n centroids on the N points. Then, the resulting n centroids are used as interior points. •III. K-means / center+: Same as strategy II, but instead of using the centroids directly, we use the interior point closest to each centroid.

[0068] [Fig.9] shows the implementation of a neural network trained to classify 2 moon-shaped classes. Different uncertainty estimates are calculated based on the network characteristics without directly seeing the inputs. (a) LD,a =3 (b) LD,a =10 c) Euclidean distance (d) Mahalanobis distance (e) Entropy of the predicted probability A common way to provide an uncertainty score is to use the predictive distribution entropy. It is maximized when the predictive distribution is uniform. In this example, the predictive distribution entropy is high only in a borderline region (Fig. 8e). This is to be expected, as the network is trained to learn a boundary between the two classes. Nevertheless, it is desired to assign high uncertainty (or low confidence) to the region without training data. Indeed, it may be too risky to make decisions in these areas, especially in critical applications. Surprisingly, in this example, the crude use of the Euclidean distance (Fig. 8c) seems to capture the input distribution better than the use of the Mahalanobis distance (Fig. 8d). This may suggest that the distribution of clusters in the representation space is more complicated than the Gaussian distribution, the lens depth (LD) can impressively capture the area where we have training data (a = 3, 10). Therefore, the lens depth (LD) is able to catch clusters with complex support shape in the representation space.Additionally, we intentionally use 2 values for a with a large spread to show stability with respect to this hyperparameter a.

[0069] In the present invention, we have applied a notion in statistics which is the lens depth (DF) combined with an optimized version of the Fermât distance (DF). This combination naturally captures the shape and density of the distribution. Unlike the multiple previously proposed methods which assume a prior distribution or use an additional model with trainable parameters as well as modifying the mechanism of the training process, the proposed method is non-parametric. Through a dataset and experiments conducted on deep neural networks, it is found that the computational method adapts well to a variety of cases. Furthermore, the computational method can be used to implement an anomaly detection method and a learning method.

[0070] These methods can be implemented differently from the examples presented in the description above and in Figures 1 to 11 without departing from the scope of the invention, which is defined by the claims. Furthermore, the technical characteristics of the different embodiments and variants mentioned above can be, in whole or in some cases, combined with each other. Thus, the methods according to the invention can be adapted in terms of costs, functionalities and performances. REFERENCES

[0071] Aurenhammer, F. Voronoi diagrams—a survey of a fundamental geometry data structure. ACM Computing Surveys (CSUR), 23(3):345-405, 1991.

[0072] Caron, M., Bojanowski, P., Joulin, A., and Douze, M. Deep clustering for unsu-pervised learning of visual features. In Proceedings of the European conference on computer vision (ECCV), pp. 132-149, 2018.

[0073] Cholaquidis, A., Fraiman, R., Gamboa, F., and Moreno, L. Weighted lens depth: Some applications to supervised classification. Canadian Journal of Statistics, 51(2):652-673,2023.

[0074] DeVries, T. and Taylor, G. W. Improved regularization of convolutional neural networks with cutout. arXiv preprint arXiv: 1708.04552, 2017.

[0075] Gai, Y. and Ghahramani, Z. Dropout as a bayesian approximation: Representing model uncertainty in deep learning. In international conférence on machine learning, pp. 1050-1059. PMLR, 2016.

[0076] Gawlikowski, J., Tassi, C. R. N., Ali, M., Lee, J., Humt, M., Feng, J., Kruspe, A., Triebel, R., Jung, P., Roscher, R., et al. A survey of uncertainty in deep neural networks. Artificial Intelligence Review, 56(Suppl 1):1513-1589, 2023.

[0077] Groisman, P., Jonckheere, M., and Sapienza, F. Nonhomogeneous euclidean first-passage percolation and distance learning. Bernoulli, 28(1):255-276, 2022.

[0078] Kendall, A. and Gai, Y. What uncertainties do we need in bayesian deep learning for computer vision? Advances in neural information processing Systems, 30, 2017.

[0079] Krizhevsky, A., Nair, V., and Hinton, G. Cifar-10 (canadian institute for advanced research). URL http: / / www.

[0080] es. toronto. edu / ~kriz / cifar .html.

[0081] Kuleshov, V. and Deshpande, S. Calibrated and sharp uncertainties in deep learning via density estimation. In International Conférence on Machine Learning, pp. 11683-11693. PMLR, 2022.

[0082] Kwon, Y., Won, J.-H., Kim, B. J., and Paik, M. C. Uncertainty quantification using bayesian neural networks in classification: Application to biomédical image segmentation. Computational Statistics & Data Analysis, 142: 106816, 2020.

[0083] Lakshminarayanan, B., Pritzel, A., and Blundell, C. Simple and scalable prédictive uncertainty estimation using deep ensembles. Advances in neural information processing Systems, 30, 2017.

[0084] LeCun, Y. The mnist database of handwritten digits. http: / / yann. lecun. com / exdb / mnist / , 1998.

[0085] LeCun, Y., Chopra, S., Hadsell, R., Ranzato, M., and Huang, F. A tutorial on energy-based learning. Predicting structured data, 1(0), 2006.

[0086] Lee, K., Lee, K., Lee, H., and Shin, J. A simple unified framework for detecting out-of-distribution samples and adversarial attacks. Advances in neural information processing Systems, 31, 2018.

[0087] Liang, S., Li, Y., and Srikant, R. Enhancing the reliability of out-of-distribution image détection in neural networks. arXiv preprint arXiv: 1706.02690, 2017.

[0088] Liu, R. Y. On a notion of data depth based on random

[0089] simplices. The Annals of Statistics, pp. 405-414, 1990.

[0090] Liu, W., Wang, X., Owens, J., and Li, Y. Energy-based outof-distribution détection. Advances in neural information processing Systems, 33:21464-21475, 2020.

[0091] Mahalanobis, P. C. On the generalized distance in statistics. Sankhya, ndian Journal of Statistics, Sériés A (2008-), 8O:S1-S7, 2018.

[0092] Malinin, A. and Gales, M. Prédictive uncertainty estimation via prior networks. Advances in neural information processing Systems, 31, 2018.

[0093] Netzer, Y., Wang, T., Coates, A., Bissacco, A., Wu, B., and Ng, A. Y. Reading digits in natural images with unsupervised feature learning. 2011.

[0094] Pedregosa, F., Varoquaux, G., Gramfort, A., Michel, V., Thirion, B., Grisel, O., Blondel, M., Prettenhofer, P., Weiss, R., Dubourg, V., Vanderplas, J., Passos, A., Coumapeau, D., Brucher, M., Perrot, M., and Duchesnay, E. Scikit-learn: Machine learning in Python. Journal of Machine Learning Research, 12:2825-2830, 2011.

[0095] Ren, J., Liu, P. J., Fertig, E., Snoek, J., Poplin, R., Depristo, M., Dillon, J., and Lakshminarayanan, B. Likelihood ratios for out-of-distribution détection. Advances in neural information processing Systems, 32, 2019.

[0096] Shôlkopf, B., Williamson, R. C., Smola, A., Shawe-Taylor, J., and Platt, J. Support vector method for novelty détection. Advances in neural information processing Systems, 12, 1999.

[0097] Sun, Y., Ming, Y., Zhu, X., and Li, Y. Out-of-distribution détection with deep nearest neighbors. In International Conférence on Machine Learning, pp. 20827-20840. PMLR, 2022. Tukey, J. W. Mathematics and the picturing of data. In Proceedings of the International Congress of Mathematicians, Vancouver, 1975, volume 2, pp. 523-531, 1975.

[0098] Van Amersfoort, J., Smith, L., Teh, Y. W., and Gai, Y. Uncertainty estimation using a single deep deterministic neural network. In International conférence on machine learning, pp. 9690-9700. PMLR, 2020.

[0099] Xiao, H., Rasul, K., and Vollgraf, R. Fashion-mnist: a novel image dataset for benchmarking machine learning algorithms, 2017.

[0100] Yang, B., Fu, X., Sidiropoulos, N. D., and Hong, M. Towards k-means-friendly spaces: Simultaneous deep learning and clustering. In international conférence on machine learning, pp. 3861-3870. PMLR, 2017.

Claims

Claims

1. Method for calculating a confidence score (CS), associated with the result of a processing of inference data (ID) by a Machine Learning Model (ML), by considering a distribution of points (20) in a representation space (10) of the Machine Learning Model (ML), where the distribution of points (20) comprises: - at least one cluster of points (21; 21, 22) resulting from the processing of learning data (LD) by the Machine Learning Model (ML) and - at least one point to be evaluated (30) resulting from the processing of the inference data (ID) by the Machine Learning Model (ML) during an inference phase; where the point to be evaluated (30) has a depth (PI; PI, P2) measurable relative to the or each cluster of points (21; 21, 22); characterized in that the method comprises the following steps: A) for the or each cluster of points (21; 21, 22), evaluating the depth (PI; PI, P2) of the point to be evaluated (30) with respect to a selection of points (25; 25, 26) of this cluster of points (21; 21, 22), according to the statistical technique of the Lens Depth (PL) calculated using as a distance measure an optimized Fermât Distance (DF), taking into account the density and the geometry of the or each cluster of points (21; 21, 22); where: - Rd is the set of real numbers of dimension d describing the representation space (10), - Q is a finite, local, non-empty subset of Rd, - xe Rd, -y eQ, - Ixl is the Euclidean form of x, - a is a hyperparameter > 1, the optimized Fermât Distance (DF) is defined as follows: DFQ>a(x,y) = min { Ix-qJ" + _n i“ : (qi,...,qk) e Qk with qk = y and k > 1}, then B) define the confidence score (CS) associated with the result of the inference data processing (ID), as being a maximum depth (MD) of the point to be evaluated (30), where: Bl) when the distribution of points (20) comprises a single cluster of points (21), the maximum depth (PM) is the depth (PI) evaluated with respect to a selection of points (25) of this cluster of points (21), or B2) when the distribution of points (20) comprises several clusters of points (21, 22), the maximum depth (PM) is defined among the depths (PI, P2) evaluated with respect to a selection of points (25, 26) of each cluster of points (21, 22).

2. Method according to claim 1, characterized in that the or each selection of points (25; 25, 26) comprises at least 20% of the corresponding cluster of points (21; 21, 22), selected randomly or according to a predefined mathematical rule.

3. Method according to claim 1, characterized in that the or each selection of points (25; 25, 26) comprises 100% of the corresponding cluster of points (21; 21, 22).

4. Method according to one of claims 1 to 3, characterized in that the distribution of points (20) comprises several points to be evaluated (30) resulting from the processing of the inference data (DI) by the Machine Learning Model (MA) during the inference phase, and in that steps A) and B) are carried out successively: - either on all the points to be evaluated (30); - or on a selection of points (35) from among all the points to be evaluated (30).

5. Method according to any one of claims 1 to 4, characterized in that step B) is carried out directly in the representation space (10) of the Machine Learning Model (ML), without intervening in the learning process of the Machine Learning Model (ML).

6. Method according to any one of claims 1 to 5, characterized in that the optimized Fermât Distance (DF) is defined with a > 1.

2.

7. Method according to any one of claims 1 to 6, characterized in that the optimized Fermât Distance (DF) is defined with a > 2.

8. Method for detecting anomalies, comprising implementing the method according to any one of claims 1 to 7, followed by a step C), consisting of comparing the inference data (DI) with a reference data set (DR) among the training data (DA), then a step D) consisting of classifying the inference data (DI), either in an existing category (CE), or in an out-of-domain category (CH).

9. Method of training a machine learning model (MA), comprising the implementation of the anomaly detection method according to claim 8, then a step E) of modifying the training data set (DA) by integrating at least certain inference data (DI) from the out-of-domain category (CH) into the existing category (CE).