Active Class Selection with Uncertain Deployment Class Proportions Mirko Bunse( ) and Katharina Morik TU Dortmund University, Artificial Intelligence Group, 44221 Dortmund, Germany {firstname.lastname}@tu-dortmund.de Abstract. Active class selection strategies actively choose the class pro- portions of the data with which a classifier is trained. While this freedom of choice can improve the classification accuracy and reduce the data ac- quisition cost, it has also motivated theoretical studies that quantify the limited trustworthiness of the resulting classifier when the chosen class proportions differ from the class proportions that need to be handled during deployment. In this work, we build on these theoretic founda- tions to propose an active class selection strategy that allows machine learning practitioners to express their prior beliefs about the deployment class proportions. Unlike existing approaches, our strategy is justified by PAC learning bounds and naturally supports any degree of uncertainty with respect to these prior beliefs. Keywords: Active class selection · Imbalanced binary classification · PAC learning theory. 1 Introduction Active class selection (ACS) [11, 9] allows machine learning practitioners to ac- tively choose the label proportions of their training data. This freedom of choice is due to a class-conditional data generator, e.g. an experiment or a simulation, which acquires feature vectors for arbitrarily chosen classes. Data generators of this kind appear in various use cases, such as astro-particle physics [4, 3], gas sensor arrays [11], and brain computer interaction [13]. Lomasky et al. [11] have put forward the idea that such a generator can be leveraged in a sequence of multiple acquisition steps, as sketched in Fig. 1. In each step, a classifier is trained and evaluated on all examples that have been acquired so far, starting from a small initial data set (i). Based on the classifier’s performance, a data acquisition strategy is then allowed to choose the label proportions of the next acquisition step (ii). The class-conditional data generator realizes these proportions, i.e. it produces a batch of labeled data according to the choice of the strategy (iii). This batch adds to the training set from which the classifier will be trained in all subsequent iterations. The promise of such a sequential and informed data acquisition is that the classifier can benefit in terms of data acquisition cost and performance, as compared to being trained with some predetermined proportions of classes. © 2021 for this paper by its authors. Use permitted under CC BY 4.0. 2 M. Bunse andActive K. Morik Class Selection with Uncertain Class Proportions 71 prior beliefs about deployment class proportions ation ii) cho ic i) evalu strategy e X →Y Y→X classifier data generator iii) training data existing strategies our proposal Fig. 1. Strategies for active class selection choose the label proportions of newly ac- quired training data. They are allowed to base their decisions on the performance of a classifier that is trained with all previously acquired data. We propose to incorporate prior beliefs, which can be uncertain, into the decision making. Existing strategies [9, 11] for ACS do not account for the class proportions that a trained model needs to handle during deployment; they solely focus on the perceived difficulty of classes. One notable exception is a strategy that ac- quires training data precisely with those label proportions that are faced in the deployment stage; by design, this strategy requires the practitioner to know the deployment class proportions precisely in advance. However, what if we know the deployment class proportions not precisely, but with some degree of uncertainty? For instance, astro-particle physicists can estimate the ratio between their sig- nal and their background class only roughly, as being approximately 1 : 103 or even 1 : 104 [2]. We are not aware of any ACS strategy that supports uncertain deployment class proportions out of the box. Motivated by such uncertainties, we have recently proposed a theoretically justified certificate for ACS-trained models [4]. This certificate declares a range of deployment class proportions for which a given model is accurate (i.e. has an ACS-induced error smaller than some ε > 0) with a high probability (i.e. with probability at least 1 − δ). This declaration can help practitioners in assessing the practical value of an ACS-trained model. However, it has no immediate implication on how to acquire data—in terms of an ACS strategy—when the deployment class proportions are uncertain. In the following, we therefore evolve the theoretical basis of our certificate towards a data acquisition strategy for ACS. This strategy uniquely combines the following qualities: – our ACS strategy naturally supports uncertainty about the deployment class proportions, e.g. as expressed by a Beta prior for binary classification. – our strategy is theoretically justified by PAC learning bounds. Our experiments suggest that our strategy, even under high amounts of un- certainty, exhibits a performance that is comparable to the performance of an optimal strategy with privileged access to the class proportions of the test set. Other strategies, which are oblivious to the deployment class proportions, fall behind by a significant margin. 72 Active M. Class Bunse, K.Selection Morik with Uncertain Deployment Class Proportions 3 We summarize the theoretic foundations of ACS in Sec. 2 before we detail our strategy in Sec. 3. The experiments in Sec. 4 lead to our conclusion in Sec. 5. 2 Theoretical Background The term “domain”, as proposed by domain adaptation [14, 12], describes a probability density function over the data space X × Y. In ACS, we assume that the source domain S—where a machine learning model is trained—differs from the target domain T —where the model is deployed—only in terms of the class proportions pS 6= pT . Such deviations occur due to the freedom of ACS strategies to choose any pS for the acquisition of training data. We are interested in the impact of such deviations on the deployment performance, i.e. on the classification performance with respect to T . Recently, a PAC learning perspective on this setting has provided us with Theorem 1 [4]. This result quantifies the difference in loss values L(h) between an ACS-generated training set D and the target domain T . Only if this difference is small, we can expect to learn a classifier h from D that is accurate also with respect to T , similar to standard PAC learning theory. The key insight of this theorem is that the relevant loss difference between D and T is continuously approaching the inter-domain gap ∆p·∆` while the training set size m increases. In ACS, this increase happens naturally while more and more data is actively being acquired, so that the error of any ACS-trained classifier is increasingly dominated by this gap. Here, ∆p = |pT − pS | denotes the difference between class proportions and ∆` = |`Y =2 (h) − `Y =1 (h)| denotes the difference between class-wise losses. The latter of these terms is constant across domains S and T . In turn, ∆p · ∆` is constant with respect to the random draw of the training set D and is therefore independent of ε, δ, and m; it reflects the interplay between the classifier h, the data distribution, and the loss function. Theorem 1 (Identical mechanism bound; binary classification [4]). For 2 any ε > 0, any h ∈ H, with probability at least 1 − δ, where δ = 4e−2mε : ∆p · ∆` − ε ≤ |LT (h) − LD (h)| ≤ ∆p · ∆` + ε The true difference ∆` from Theorem 1 is unknown, but we can estimate an upper bound ∆`∗ of this quantity from ACS-generated data. The details on this estimation are already presented in the scope of ACS model certification [4] and do not need to be repeated here. All we need to know to establish our ACS strategy is that ∆`∗ is the smallest upper bound of ∆` that holds with probability at least 1 − δ. The probabilistic nature of this upper bound stems from the fact that ∆`∗ is estimated from finite amounts of data. 3 A Strategy for Uncertain Class Proportions The goal of our strategy is to decrease the inter-domain gap ∆p · ∆` from The- orem 1 as much as possible, as according to a prior distribution P̂ of the de- ployment class proportions pT . This goal will allow any binary classification 4 M. Bunse andActive K. Morik Class Selection with Uncertain Class Proportions 73 algorithm to learn accurate predictions for the target domain, as according to the prior beliefs of a domain expert. Formally, we assume a prior P̂ : [0, 1] → [0, 1] of the positive class prevalence pT ∈ [0, 1] to be given. We incorporate P̂ by marginalizing the inter-domain gap over this prior, as according to Eq. 1. Since we do not know the true ∆`, we are using the estimated upper bound ∆`∗ instead. Consequently, the marginalization according to ∆`∗ is an upper bound, with probability 1−δ, of the marginalization according to the true ∆`. Z 1 ∗ ε = P̂(pT = p) · |pS − p| · ∆`∗ d p (1) 0 | {z } = ∆p In each ACS iteration, we are free to alter the class proportions pS of the ACS-generated training set to some degree, depending on how much data we acquire in each batch and on how much data we already have acquired. In fact, we can understand pS = (m1m+m 2 2) as a function of the class-wise numbers of samples m1 and m2 . The upper bound ∆`∗ also lends itself for being interpreted as a function of sample sizes: the more data is acquired in both classes, the tighter will our estimation of this quantity be. Ultimately, we consider ε∗ to be a function of m1 and m2 , so that we can minimize ε∗ via an optimal choice of m1 and m2 in each data acquisition batch. 3.1 Minimizing the Marginalized Error Our strategy decreases ε∗ in the direction of its steepest descent, i.e. it takes a simple gradient step with respect to the acquisition vector m = (m1 , m2 ). The gradient which defines the steepest descent is computed via the product rule: ∇m ε∗ = ∇m f · ∆`∗ + f · ∇m ∆`∗ Z 1 (2) where f (m) = P̂(pT = p) · |pS (m) − p| d p 0 We will come back to the function f shortly. For now, we plug ∆`∗ and ∇m ∆`∗ into the equation above. These functions are defined by r r ∗ ˆ ln δ2 ˆ ln δ1 ∆` (m) = `Y =2 (h) + − `Y =1 (h) + , −2m2 −2m1  3 (3) ln δy 2 √ [∇m ∆`∗ ]y = − · (2 2 ln δy )−1 , my where the δy are probabilities of violations of ∆`∗ that occur from either one of the class-wise losses `Y =y (h) in ∆`. In fact, finding a suitable assignment of δy values within a given probability budget δ = δ1 + δ2 − δ1 δ2 is the central difficulty in model certification; there, the sample size m is fixed, so that ∆`∗ can be optimized over this assignment [4]. Here, we keep the δy fixed instead, to 74 Active M. Class Bunse, K.Selection Morik with Uncertain Deployment Class Proportions 5 values that are obtained with a certificate from previous ACS acquisitions. This change allows us to optimize ∆`∗ over m to acquire new data and it guarantees that ∆`∗ remains an upper bound of the true ∆` also in the next batch, at least with probability 1 − δ. The class-wise estimates `ˆY =y (h) in Eq. 3 are the average values of losses in the training data; they are also part of our certificate. 3.2 A Beta Prior for Binary Class Proportions Now we turn to the function value and the gradient of the function f in Eq. 2. Plugging a parametric prior P̂ into this function can allow us to compute these terms efficiently, in closed forms. To this end, a Beta(α, β) prior is suitable for binary classification because the Beta distribution is a conjugate prior of the Bernoulli distribution, which in turn is a suitable model for the prevalence of binary class labels. As a matter of convenience, the parameters α > 0 and β > 0 can be chosen such that the resulting distribution has some predetermined mean and standard deviation; we believe that domain experts can often express their prior beliefs in terms of these properties. Plugging a Beta prior into the f function from Eq. 2 yields the following components, where I is the regularized incomplete Beta function: 2pS (m)α (1 − pS (m))β  α   fα,β (m) = + pS (m) − 2IpS (m) (α, β) − 1 (α + β)B(α, β) α+β   2IpS (m) (α, β) − 1 m2 ∇m fα,β = · (4) (m1 + m2 )2 −m1 Plugging Eq. 3 and 4 into Eq. 2 provides us with a gradient that we can compute analytically from a certificate with a δy assignment, from sample sizes m1 and m2 and from the prior parameters α and β. The negative gradient −∇m ε∗ of the marginalized error ε∗ defines the class-wise numbers of samples that our strategy acquires in the next data acquisition batch. With small data volumes or with highly imbalanced classes, our strategy is dominated by the ∆`∗ component; small classes need additional data until this upper bound holds with some desired probability 1−δ. Constrastingly, when the total data volume is large, our strategy is dominated by the f component; to this α end, a Beta prior favors class proportions that are close to its mean α+β . The turning point between these two behaviors is well-founded in the PAC learning theory that underlies the estimation of ∆`∗ . 4 Experiments The first introduction of the ACS problem is already accompanied by the pro- posal of five heuristic ACS strategies [11]. In the following, we compare our own strategy from Sec. 3 to these five heuristics: proportional: always sample according to pT , provided that these true pro- portions are already known at training time. 6 M. Bunse andActive K. Morik Class Selection with Uncertain Class Proportions 75 uniform: always sample all classes in the same amount. inverse: sample according to the inverse accuracy of a classifier that is trained on earlier batches; the underlying assumption is that weak class-wise perfor- mances can be counteracted with over-sampling. improvement: sample according to the class-wise improvement in accuracy that has occurred between the current iteration and the iteration before; this strategy assumes that stable performances, i.e. performances that did not change recently, will remain stable during future acquisitions. redistriction: sample according to the class-wise number of training examples for which the prediction has changed between the current iteration and the iteration before; the assumption here is that stability can be promoted by over-sampling classes with volatile decision boundaries. Our theoretical analysis of the ACS problem [5, 4] reveals that the propor- tional strategy is actually more than a heuristic; this strategy is indeed optimal in the limit of data acquisition. However, it requires precise knowledge of pT , which practitioners might not be able to provide. Contrastingly, all other strate- gies are entirely oblivious to the deployment proportions; they solely focus on different notions of class-wise difficulties. This shortcoming is also shared by an ACS strategy that aggregates utility scores of pseudo-instances [9]. For now, we have excluded this approach from our comparison, due to this property. For future work, however, we expect that the method can overcome this limitation with a recent update of its utility function [8]. This update supports a prior of pT , which is in line with our idea of incorporating prior beliefs in ACS. Embedding the update in the original pseudo-instance strategy, however, might not be trivial. 4.1 Methodology We have parameterized the Beta prior of our strategy with a predetermined mean and standard deviation, both set to the true value of pT . Accordingly, the mean of the prior is well aligned with the true class proportions of the deployment data; the uncertainty, however, is as large as possible. In accordance to a reliable evaluation methodology [7], we present pairwise differences between ACS strategies in terms of their statistical significance. A comprehensive way of plotting such differences is through critical difference di- agrams [6, 1], which compare multiple strategies over multiple data sets in a statistically sound way. We employ accuracy as the underlying performance met- ric and we conduct multiple trials to obtain an average performance value for each combination of strategy and data set. These average performances are then summarized through critical difference diagrams. We define the trials via five repetitions of a three-fold cross validation. From the imbalanced-learn 1 package [10], we retrieve 13 data sets that have at least 150 minority class samples (to facilitate sampling) and at most 100 features (to 1 https://imbalanced-learn.org/stable/datasets/ 76 Active M. Class Bunse, K.Selection Morik with Uncertain Deployment Class Proportions 7 facilitate learning). We ensure comparability between all strategies by employing the same classifier in all experiments, a logistic regression with default meta- parameters. The data acquisition happens in up to 8 batches, each of which acquires 50 new training examples. However, not all strategies reach the last batch on all data sets; we stop each trial as soon as the strategy exhausts one of the classes. We opted for this early stopping criterion to focus on “realistic” acquisitions that happen due to free choices and not due to the fact that our experiment only simulates class-dependent data acquisition with finite pools of data. For the same reason, and due to weak performances on imbalanced data, we did not evaluate the uniform strategy here. Due to the early stopping, it becomes increasingly harder to detect significant differences; while the batches three and four can be evaluated on all data sets, only 9 data sets remain for batch eight. The implementation of our configurable experiments is available online2 . 4.2 Results and Discussion Fig. 2 presents the critical difference diagrams, as according to our evaluation methodology. We see that our method, with access to an uncertain prior of pT , performs as well as the privileged strategy that knows pT precisely. Moreover, our method outperforms all existing strategies which are oblivious to pT . Fig. 3 traces this success back to the acquisition behavior that each strategy exhibits. Our own strategy quickly approaches the true proportions pT of classes, due to the perfect alignment between the mean of the prior and pT . For the particular case of a Beta prior, this behavior is a reason for concern: if the mean of this prior was not well aligned with pT , we might have acquired data in mistaken class proportions; only if the mean of the Beta prior is sufficiently accurate, we can expect the competitive behavior that Fig. 2 suggests. Future research down this lane, e.g. with other types of prior distributions, is needed. Fig. 3 further reveals two explanations for the poor performances of the existing strategies: first, all of these strategies exhibit a central tendency of staying close to the class proportions of the initial training set; second, each of these strategies prefers class proportions of an increasingly large variability. Both of these behaviors are due to the sole focus of these strategies on the perceived difficulties of classes, which can differ considerably between the data sets. 5 Conclusion and Outlook In contrast to existing ACS strategies, which either assume precise knowledge about the deployment class proportions or no knowledge at all, we have advo- cated the incorporation of a prior distribution that expresses beliefs about the class proportions with any degree of (un)certainty. Our ACS strategy is well- founded on PAC learning bounds which we have recently proposed for ACS [4]. Experiments suggest that our strategy performs as well as the fully certain case, which, however, is harder to specify than an uncertain prior. 2 https://github.com/mirkobunse/AcsCertificates.jl 8 M. Bunse andActive K. Morik Class Selection with Uncertain Class Proportions 77 avg. rank (pT = 0.1) 5 4 3 2 1 3 4 certification 5 ACS batch inverse improvement 6 redistriction 7 proportional 8 avg. rank (pT = 0.3) 5 4 3 2 1 3 4 5 ACS batch 6 7 8 Fig. 2. Critical difference diagrams evaluate our ACS strategy ( ) against existing ACS strategies [11], one of which has privileged access to the true class proportions pT ( ). The two plots present different values of pT . Each position on the vertical axes corresponds to one critical difference diagram for one batch in the ACS data acquisition loop. Horizontal positions correspond to the average ranks of strategies across multiple data sets, as according to the average accuracy in multiple trials; lower ranks are better. Horizontal connections between two or more strategies indicate that a Wilcoxon signed-rank test is not able to detect significant differences between these methods from the performances they exhibit. 78 Active M. Class Bunse, K.Selection Morik with Uncertain Deployment Class Proportions 9 pT = 0.1 pT = 0.3 0.3 dKL (pS , pT ) certification 0.2 0.5 inverse 0.1 improvement redistriction 0 0 1 3 5 7 1 3 5 7 batch batch Fig. 3. Our ACS strategy ( ) quickly approaches the true proportions pT of classes in terms of the Kullback-Leibler divergence dKL . Due to the uncertainty of the prior, however, this divergence always remains above zero. The standard deviation of dKL , as displayed by the error bars, increases considerably with the other strategies. Future work on ACS should focus on strategies that support multi-class clas- sification and regression. We identify the PAL-ACS framework [9] with a recent update of its utility function [8] as a promising candidate in this direction. Acknowledgments This work has been supported by Deutsche Forschungsgemeinschaft (DFG) with- in the Collaborative Research Center SFB 876 “Providing Information by Re- source-Constrained Data Analysis”, project C3, and by the Federal Ministry of Education and Research of Germany as part of the competence center for machine learning ML2R (01IS18038 A/B). References 1. Benavoli, A., Corani, G., Mangili, F.: Should we really use post-hoc tests based on mean-ranks? J. Mach. Learn. Res. 17(1), 152–161 (2016) 2. Bockermann, C., Brügge, K., Buss, J., Egorov, A., Morik, K., Rhode, W., Ruhe, T.: Online analysis of high-volume data streams in astroparticle physics. In: Europ. Conf. on Mach. Learn. and Knowledge Discovery in Databases. Springer (2015) 3. Bunse, M., Bockermann, C., Buss, J., Morik, K., Rhode, W., Ruhe, T.: Smart control of Monte Carlo simulations for astroparticle physics. In: Astronomical Data Analysis Software and Systems. pp. 417–420 (2017) 4. Bunse, M., Morik, K.: Certification of model robustness in active class selection. In: Europ. Conf. on Mach. Learn. and Knowledge Discovery in Databases. Springer (2021) 5. Bunse, M., Weichert, D., Kister, A., Morik, K.: Optimal probabilistic classification in active class selection. In: Int. Conf. on Data Mining. IEEE (2020) 6. Demšar, J.: Statistical comparisons of classifiers over multiple data sets. J. Mach. Learn. Res. 7(1), 1–30 (2006) 10 M. Bunse andActive K. Morik Class Selection with Uncertain Class Proportions 79 7. Kottke, D., Calma, A., Huseljic, D., Krempl, G., Sick, B.: Challenges of reliable, realistic and comparable active learning evaluation. In: Workshop and Tutorial on Interactive Adaptive Learn. pp. 2–14 (2017) 8. Kottke, D., Herde, M., Sandrock, C., Huseljic, D., Krempl, G., Sick, B.: Toward op- timal probabilistic active learning using a Bayesian approach. Mach. Learn. 110(6), 1199–1231 (2021) 9. Kottke, D., Krempl, G., Stecklina, M., von Rekowski, C.S., Sabsch, T., Minh, T.P., Deliano, M., et al.: Probabilistic active learning for active class selection. In: NeurIPS Workshop on the Future of Interactive Learn. Mach. (2016) 10. Lemaitre, G., Nogueira, F., Aridas, C.K.: Imbalanced-learn: A python toolbox to tackle the curse of imbalanced datasets in machine learning. J. Mach. Learn. Res. 18 (2017) 11. Lomasky, R., Brodley, C.E., Aernecke, M., Walt, D., Friedl, M.A.: Active class selection. In: Europ. Conf. on Mach. Learn. and Knowledge Discovery in Databases. Springer (2007) 12. Pan, S.J., Yang, Q.: A survey on transfer learning. IEEE Trans. Knowl. Data Eng. 22(10) (2010) 13. Parsons, T.D., Reinebold, J.L.: Adaptive virtual environments for neuropsycholog- ical assessment in serious games. IEEE Trans. Consumer Electron. 58(2) (2012) 14. Wang, M., Deng, W.: Deep visual domain adaptation: A survey. Neurocomputing 312 (2018)