138 American Academic Scientific Research Journal for Engineering, Technology, and Sciences ISSN (Print) 2313-4410, ISSN (Online) 2313-4402 https://asrjetsjournal.org/index.php/American_Scientific_Journal/index Detection of Rare Events: The Need to Know the Customer Ayse Humeyra Bilge a , Tarkan Ozmen b , Ayse Tosun c* a Kadir Has University, Istanbul 34083, Turkey a Email: ayse.bilge@khas.edu.tr b Email: tarkan.ozmen@gmail.com c Email: aysetosun2018@gmail.com Abstract The prediction of customer complaints based on a time series of invoices is a two-stage process consisting of determining anomalies in the sequence of invoices and assessing the response of the customers to these anomalies. In the telecommunication sector, the average complaint rate is approximately 10⁻⁴ hence the prediction of customer complaints falls in the realm of rare event detection. Detecting rare events poses a significant challenge when working with unbalanced datasets. In machine learning applications, oversampling of the minority class and under sampling of the majority class in the training set are well-known preprocessing tools for creating a more balanced set. In previous work, [14] we proposed a cluster based under sampling approach as an alternative to random under sampling of the majority class, based on splitting heterogeneous data into homogeneous subsets, using Principal Component Analysis, to reduce variability within clusters. In the present work we propose a method for assessing the response of the customers to anomalies detected in the time series of invoices. Keywords: Time series analysis; Unbalanced data; clustering and classification; customer scoring. 1. Introduction Customer complaints are mostly rare events, but they are a primary cause of customer dissatisfaction and companies try to predict and handle possible causes before the occurrence of a complaint. It is thus desirable to devise efficient and cost-effective strategies for predicting complaints. ------------------------------------------------------------------------ Received: 11/29/2024 Accepted: 1/30/2025 Published: 2/12/2025 ------------------------------------------------------------------------ * Corresponding author. https://asrjetsjournal.org/index.php/American_Scientific_Journal/index American Academic Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) - Volume 101, No 1, pp 138-160 139 Unless there are clues on possible causes and motives for complaints, predictions are based on the detection of anomalies in a time series and associating these anomalies with the events to be identified, i.e., complaints. The aim of the present work is to framework for dealing with rare customer complaints, within a heterogeneous customer pool. In the case of a heterogeneous customer pool, a detailed statistical analysis of the customer behavior is indispensable for obtaining satisfactory predictions and for applying efficient corrective measures. It is advisable to remove outliers as customers to be paid special attention and proceed with the remaining group, which is still highly heterogeneous. The first step consisting of the detection of anomalies is a more or less standard classification problem for which elaborate machine learning tools are available. Nevertheless, the detection of extremely rare events is a challenging problem that may further be complicated by heterogeneities in the data set. The second step consisting of associating anomalies to complaints requires a more delicate treatment. Because the features of the majority group that do not file any complaint may display anomalies, possibly because some of these anomalies correspond to conscious actions. Furthermore, different people may react differently to the same anomaly. Thus, whichever classifier is used, the amount of "false positive" cases can be quite large. The key to the solution of this problem is to integrate the response of the customer to the anomaly to the classification problem by a feedback mechanism. In the present work, we propose a customer scoring system that monitors the reaction of a customer to anomalies of different types and generate a score for the association of anomalies to complaints. Preliminaries and literature survey are presented in Section 2. A detailed statistical analysis is presented in Section 3. Customer scoring is given in Section 4. An illustrative example for scoring is given in Section 5. Concluding remarks are given in Section 6 2. Preliminaries The classification problem: In dealing with a heterogeneous pool of customers, clustering and classification of the customers with respect to the behavior to be analyzed is a crucial preliminary step. The classification problem is the process of deciding on the group to which a given individual belongs. The population is divided into disjoint sets and each individual is characterized by a set of features. A classification algorithm takes the features as an input and decides on the “class” of that individual. In the case of classifying customers with respect to complaint behavior, roughly speaking, we obtain groups with low mean-low standard deviation invoice series, invoice series with high variability and a group of invoice series that are characterized by extreme values in an otherwise steady time series. In order to obtain a classification, algorithms are developed by an analysis of the data; split as “training” and “test” sets. Machine learning methods applied to this classification, result in either correct or incorrect categorization into four groups: “True-Positive,” “True-Negative,” “False-Positive,” and “False-Negative”. The performance of the classification algorithms is measured by sensitivity (the ratio of “True-Positive” cases to total “Positive” cases) and specificity (the ratio of “True-Negative” cases to total “Negative” cases). American Academic Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) - Volume 101, No 1, pp 138-160 140 In the case of rare event detection data is unbalanced, i.e., “positive” cases that are aimed to be detected form the “minority” class, while “negative” cases constitute the “majority class. For a successful training of the model, it is necessary to provide a sufficient number of positive and negative examples for the algorithm's training phase. However, in the case of rare events, the number of positive cases is often too low, and oversampling techniques, such as the Synthetic Minority Oversampling Technique (SMOTE), can be used to artificially increase the number of positive examples When the ratio of minority to majority class is extremely low, oversampling of the minority class may not be sufficient to balance the dataset and random under-sampling of the majority class is often applied. Random under sampling works well for homogeneous data, however, for heterogeneous data, this approach may fail to yield satisfactory results. In previous work [14] we proposed a preprocessing approach consisting of clustering the data into homogeneous subsets and sample data at based on Principal Component Analysis in order to reflect faithfully the variance in each subset. This method has been applied to detecting customer complaints related to monthly invoices at a major telecommunications company with about 18 million customers and a monthly complaint rate of 1,300 representing an extremely rare event. Imbalanced data problems have been a significant challenge in various real-world applications, including medical diagnostics, financial risk prediction, and text classification tasks such as spam detection [1]. In particular, imbalanced datasets frequently arise in domains where the minority class is the primary focus, such as in fraud detection, rare disease identification, or anomaly detection [2]. If left unaddressed, this imbalance can lead to predictive models that heavily favor the majority class, often at the cost of ignoring the minority class, resulting in poor overall performance in critical cases. This has become a central issue in machine learning and data mining, where learning algorithms tend to prioritize accuracy on the majority class while disregarding the minority class, leading to suboptimal results in high-stakes scenarios. As a result, there has been a growing interest in addressing this issue in the data mining and machine learning fields. Approaches to solving the imbalanced data problem are typically categorized into four major groups: algorithm-level techniques, data-level techniques, cost-sensitive learning methods, and ensemble methods [3,4]. Cost-sensitive methods introduce penalties for misclassifying instances from the minority class, encouraging the model to prioritize accuracy for that class. On the other hand, data-level techniques such as over-sampling and under-sampling directly manipulate the training data to create a more balanced class distribution. These preprocessing steps help ensure that learning algorithms are exposed to sufficient examples from both the majority and minority classes, improving their performance on imbalanced datasets [5]. Among data-level techniques, the Synthetic Minority Over-sampling Technique (SMOTE), proposed by Chawla and his colleagues [6], has dominated the over-sampling area. SMOTE generates synthetic instances for the minority class by interpolating between existing instances, helping to reduce the class imbalance. Several studies, including an investigation by Fernández and his colleagues [7], have demonstrated that SMOTE and its variants can significantly enhance the performance of classifiers on imbalanced datasets. However, it is not without limitations. While SMOTE is a powerful tool for enhancing classification performance, it may introduce noise or over-generalization if the minority class contains significant variance. American Academic Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) - Volume 101, No 1, pp 138-160 141 Similarly, random under-sampling—a method where a random subset of the majority class is selected—can help in reducing class imbalance by discarding excessive instances from the dominant class. However, random under-sampling carries the risk of information loss, as important data points may be removed arbitrarily. To address this issue, researchers have developed hybrid approaches. For example, RUSBoost, introduced by Seiffert and his colleagues [9], combines random under-sampling with the popular boosting technique, thereby improving classification accuracy by mitigating class imbalance while preserving valuable data. Another hybrid approach, UnderBagging, utilizes bagging techniques combined with random under-sampling to create a balanced training dataset and has been shown to improve classifier performance in imbalanced scenarios [9]. In domains such as credit card fraud detection, highly imbalanced datasets are the norm. Randhawa and his colleagues [10] used Adaboost and Majority Voting to evaluate twelve different classifiers in this domain, showing that ensemble methods provide superior results compared to individual classifiers. Similarly, Buda and his colleagues [8] found that combining under-sampling with boosting techniques significantly enhanced classification performance, particularly in highly imbalanced datasets where the minority class constitutes less than 1% of the overall data. The literature suggests that no single method is universally effective for addressing imbalanced data across all datasets [11]. Typically, the choice of method depends on the specific characteristics of the dataset and the nature of the minority class problem. As such, this work proposes a novel approach that aims to enhance predictive performance by first segmenting the data into clusters with similar characteristics and then applying classification models within each segment. This clustering-based methodology, discussed in the following sections, offers a promising way to handle imbalanced data by tailoring the classification process to the specific structure of the dataset, an approach not widely explored in the current literature. Description of Data: In this study, at we worked with monthly invoices of a major telecommunication company that has a customer pool of about 20 million people. At various phases of the analysis, we worked with different samples from this pool. Various statistics that we present aim to display the proportion of complaints and the structure of multiple complaints to a given invoice. Table 1 below, displays the number of complaints to a sample consisting of over 2.3 million customers over 9 months (07/2021-03/2022). This customer pool has been used for the analysis of detecting retail expenditures[13]. Table 3: Distribution of complaints (NC: No Complaint, C: Complaint, over 2.3 customers, 07/2021-03/2022) Month 1 2 3 4 5 6 7 8 9 NC 2 375 072 2 375 153 2 375 120 2 375 100 2 375 136 2 375 351 2 375 438 2 375 497 2 375 351 C 1 444 1 363 1 396 1 416 1 380 1 165 1 078 1 019 1 165 A second sample consists of an 11-month billing history (09/2021-06/2022) for 843,637 subscribers has been American Academic Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) - Volume 101, No 1, pp 138-160 142 used for a clustering of customer invoice sets [13].The number of multiple objections are given in Table 2 below. It is recommended that customers who have filed objections for more than 40% of the monitoring period be placed on a separate observation list and excluded from the general analysis. It can be observed that the majority of customers did not file any objections, and multiple objections are rare. Table 4: Statistics of multiple objections based on Sample 2 (843,637 customers, 09/2021-06/2022) The main result of our previous work is that complaints are extremely rare, they are in general related to anomalies in the invoice series, but extreme anomalies in general correspond to conscious spendings and they don’t lead to objections and complaints. Furthermore, although rare, repeated objections indicate the need for special treatment and corrective actions for a group of customers. Finally, even after classifying customers into relatively homogeneous subsets, still the response of the individuals to anomalies displays high variability. As a result, in the present work we investigate to role of customer response to anomalies. 3. Statistical analysis of the customer pool The following chart displays typical the billing sequences for customers who objected six or more times within the 11-month period. In these graphs, an asterisk (*) on the curve indicates an objection to the corresponding invoice. Number of Objections 0 1 2 3 4 5 6 7 8 9 10 11 Number of people 830499 12619 384 73 28 15 9 1 2 3 1 3 American Academic Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) - Volume 101, No 1, pp 138-160 143 Figure 1: Subscribers with six to seven objections during the 11-month period. Figure 16 As seen in the graphs, some objections are related to the invoice amounts. However, whether high or low, continuous objections to invoices indicate that these customers have issues that need to be managed specifically. In such cases of persistent objections, special attention should be given to the subscriber, and measures should be taken to prevent the ratio of objections from reaching that level. Therefore, subscribers who have filed objections exceeding 40% during the observation period will be placed on a separate observation list, “Observation List 1” and removed from the general list. Invoices Containing Extreme Values: Invoices that exceed a specified threshold value in any given month are considered extreme expenditures. When such an expenditure occurs, the customer should be placed on a separate observation list for assessing the nature and cause of the expenditure. This threshold value may vary from month to month. In the current example, the threshold value has been set at 10,000 TL for all months, and 138 customers who made extreme expenditures in any month have been identified. These customers have filed objections to only six invoices. Three of these objections were made against invoices with extreme values, while the other three were made against relatively low-amount invoices. Typical billing sequences of these subscribers are displayed below. American Academic Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) - Volume 101, No 1, pp 138-160 144 Figure 2: Subscribers with invoices exceeding 10,000 TL in any month. These invoices are interesting in that they also reflect the retail-related expenditures discussed earlier, and they have been provided in detail to exemplify these types of expenditures. These customers are moved to “Observation List 2”. At this stage, the analysis will continue with 843,465 invoice records. General Structure of Features The distribution of the average, standard deviation, and maximum-minimum difference attributes is shown below in Figure 3. In this way, invoice records that are concentrated on a straight line are noteworthy. It will be demonstrated that these records consist of invoices containing a small number of extreme values. However, to perform various proportional calculations, invoice records with zero or very low attribute values will be eliminated first. American Academic Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) - Volume 101, No 1, pp 138-160 145 Figure 3: Scatter plots of the standard deviation (S) and the range (R) with respect to the mean (M). From this data, 10,170 customers with a standard deviation of less than 1 TL, 69 customers with a maximum- minimum difference of less than 1 TL, and 21 customers with an average of less than 10 TL have been identified and transferred to the “Observation List 3”. Those customers are unlikely to file any objection, and the general analysis will continue with 833,205 customers. We note that by increasing the lower bounds it is possible place a considerable amount of customers in this no-risk group. After this stage, clustering will be performed based on spending trends, and separate time series analyses will be conducted for each cluster. Almost 2-level invoice series A typical group of invoice series consist of a few number of high bills in a sequence of relatively low mean low variation invoices. Let's assume that in such a sequence of n elements, there are k high-value (b) invoices and n- k low-value (a) invoices. Such sequences take the form of { a, a, a, a, ..., b, ..., a, a, b, ......, a}. For this sequence, the maximum-minimum difference (R), average (M), and standard deviation (S) are calculated as follows. 𝑅 = 𝑏 − 𝑎, 𝑴 = 𝒂 + 𝒌 𝒏 (𝒃 − 𝒂) American Academic Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) - Volume 101, No 1, pp 138-160 146 𝑺𝟐 = 𝟏 𝒏−𝟏 [(𝒏 − 𝒌) ( 𝒌 𝒏 (𝒃 − 𝒂)) 𝟐 + 𝒌 (𝒃 − 𝒂 − 𝒌 𝒏 (𝒃 − 𝒂)) 𝟐 ] 𝑺 = (𝒃 − 𝒂)√ 𝒌(𝒏−𝒌) 𝒏(𝒏−𝟏) From this, it can be immediately observed that the S/R ratio is independent of the values of a and b and depends on k and n only. Typical values for a=100, b=1000, n=11 and k=1,…,10, M,S,R and the ratio S/R are given as follows. Table 1: Values of M, S, R, and S/R for a=100a, b=1000, n=11, =11, and k=1,…,10k K M S R S/R 1 181.81 271.36 900 0.3015 2 263.63 364.06 900 0.4045 3 345.45 420.38 900 0.4671 4 427.27 454.07 900 0.5045 5 509.09 470.00 900 0.5222 6 590.90 470.00 900 0.5222 7 672.72 454.07 900 0.5045 8 754.54 420.38 900 0.4671 9 836.36 364.06 900 0.4045 10 918.18 271.36 900 0.3015 In Figure 4 below, we display the ratios S/R as a function of M. In this figure, data agglomerated along straight lines thus correspond to nearly binary valued invoices. Those singular high expenditures may relate to retail expenses or exceptional telecommunication expenditure such as usage in foreign countries, which are likely to be made consciously and may not lead to complaints. On the other hand, persistently high-value expenditures significantly above the average may relate to installment payments or package changes, and the likelihood of complaints for this group is also low. American Academic Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) - Volume 101, No 1, pp 138-160 147 Figure 4: S/R ratios for all invoice series and linear lines with a constant slope for k=1,…,5. Data segmentation In the implementation of the algorithm, it is necessary to segment the data into subsets. This segmentation is obtained hierarchically, by segmenting with respect to M, then with respect to S and finally with respect to R, Sorted values of M, S, R and their ratios are given below. Figure 5: Sorted values of M, S, R and their ratios. The thresholds for M are determined in terms of logarithms as shown below. American Academic Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) - Volume 101, No 1, pp 138-160 148 Figure 6: Limits for clustering based on the average. The scatter plots of R and S with respect to M for each group are shown below. Figure 7: Distribution of standard deviation and maximum-minimum difference according to the average. In all groups, there is a concentration along a line with a slope of around 0.29-0.30. In other groups, there is also a noticeable concentration along lines with less distinctly increasing slopes. Avarage American Academic Scientific Research Journal for Engineering, Technology, and Sciences (ASRJETS) - Volume 101, No 1, pp 138-160 149 The monthly complaint rates for these four sections are as follows: Table 2: Number of Complaints and Rates Total ln(M)<4 4