Next Article in Journal
Grünwald–Letnikov Fractional Ensemble with α-Specific Power Weighting for Multi-Cancer Classification
Previous Article in Journal
PEAO: A Cooperative Parallel Enzyme Optimization Algorithm with Adaptive Search Mechanisms
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Class Cardinality as a Source of Prediction Uncertainty in E-Commerce Customer Analytics

1
Department of Computer Science and Engineering, Techno India University, Kolkata 700091, West Bengal, India
2
Department of Mathematics, Techno India University, Kolkata 700091, West Bengal, India
3
Department of Computer Application, Techno India University, Kolkata 700091, West Bengal, India
4
Computer Science Department, Jadavpur University, Kolkata 700032, West Bengal, India
*
Author to whom correspondence should be addressed.
Analytics 2026, 5(3), 36; https://doi.org/10.3390/analytics5030036
Submission received: 23 June 2026 / Revised: 5 August 2026 / Accepted: 20 August 2026 / Published: 8 September 2026

Abstract

Class imbalance and class cardinality both affect multiclass classification, but their influence on probabilistic estimation has been less explored. This study examines these impacts using an e-commerce dataset. The study follows a four-stage methodology comprising classifier comparative evaluation, controlled class-cardinality analysis, validation using real categorical variables, and class-imbalance evaluation. Multiclass classification tasks are evaluated using Support Vector Machine, Gaussian Naive Bayes, Logistic Regression, Random Forest, and Decision Tree classifiers. Under five-fold cross-validation, performance is assessed using the macro-F1 score, log loss, and accuracy. Results show that macro-F1 score and accuracy decrease as class cardinality increases, causing greater classification difficulty. Tree-based models like Random Forest exhibit more balanced performance across classes. Gaussian Naive Bayes obtains the lowest log loss, indicating more accurate probability estimations. Class cardinality effects are isolated by varying the number of classes while keeping the features and classifier fixed. Increasing class cardinality reduced posterior confidence and increased entropy and log loss. Using real-time categorical variables, these trends are confirmed. Class imbalance primarily affects minority class performance, whereas class cardinality exerts a broader influence on probabilistic confidence and prediction uncertainty. The findings emphasize the necessity to consider class cardinality, class imbalance, and probabilistic metrics when evaluating multiclass classification models.

1. Introduction

E-commerce has developed into a data-driven ecosystem where advanced technologies facilitate personalized customer experiences that enable efficient decision-making, thus leading to enhanced business performance. The rapid growth of e-commerce has increased the demand for intelligent systems that can analyze user behavior, improve product discovery, and support personalized shopping experiences. Future research in e-commerce recommender systems and artificial intelligence is discussed in Ref. [1] to improve personalization and decision-making. For the development of effective e-commerce recommendation systems, the study identifies emerging areas, such as knowledge graphs and content-based image retrieval, which could lead to future research. The review in Ref. [2] highlights agent-based modeling, network theory, and machine learning methods to enhance personalized customer experiences and further the understanding of market trends. The study shows that e-commerce decision-making can be improved by combining complex systems models with predictive analytics for improved inventory management and pricing strategies. In an e-commerce data analysis class, cardinality refers to the number of distinct categories present in a dataset, whereas class imbalance describes inequalities in the number of observations belonging to different categories. Focusing on large e-commerce datasets, the challenges faced by imbalanced data being frequently misclassified by conventional machine learning methods are studied in Ref. [3]. A hybrid approach is proposed that combines multiple data-processing techniques and algorithms to improve classification accuracy and predictive performance. The survey in Ref. [4] highlights that class imbalance remains a major challenge in machine learning and deep learning studies, affecting model performance across a wide range of real-world applications. The study reviews recent approaches to managing imbalanced data for classification and regression and outlines future research directions. Ref. [5] demonstrates that class imbalance significantly reduces the effectiveness of machine learning models and leads to biased predictions toward the majority class. The study with two classes, or binary classification, shows improvements in metrics such as macro-F1 score and accuracy.
Comparing the existing literature, previous studies address only class imbalance, whereas the present work investigates the joint impact of class cardinality and class imbalance on e-commerce classification performance. This shows how the number of classes influences the performance of machine learning models. Our approach is an empirical study of the interaction between class cardinality and class imbalance in e-commerce classification, a topic that has been underexplored in the literature.
E-commerce systems employ multiclass classifiers for customer segmentation, product recommendation, payment preference prediction, and purchase frequency analysis [6,7]. As businesses introduce more specific customer categories, the number of target classes increases substantially. Understanding how increasing class cardinality affects predictive confidence and uncertainty is therefore essential for designing reliable e-commerce decision support systems [8,9]. E-commerce platforms increasingly use multiclass prediction systems, and increasing the number of categories can degrade confidence and reliability. The study in [10] proposes a continuous learning Naive Bayes framework for sentiment classification of e-commerce product reviews. This makes efficient processing of large-scale and continuously growing review data possible. The results show that the model successfully transfers knowledge across domains and achieves improved adaptability and classification performance on reviews from different product categories and domains. This study does not address how classifiers behave under simultaneous multiclass and imbalanced conditions. In another study, a large-scale multi-label e-commerce customer review dataset comprising more than 50,000 reviews across three product categories was developed [11]. The study demonstrated that machine learning methods can effectively identify multiple aspects of customer opinions from a single review with high classification performance. Although the study considers multiple labels for each customer review, its focus is on multi-label sentiment analysis rather than multiclass classification. Consequently, it does not examine how varying class cardinality or class imbalance affects classifier performance, which constitutes the primary focus and novelty of the present study. The research in [12] proposes a self-supervised learning framework combined with a structured domain knowledge model to automatically classify e-commerce products based on their raw materials, reducing the need for extensive manual labeling. As per the results of the work, the proposed method achieves an accuracy of 91%. This shows e-commerce applications require efficient and reliable product classification. Although the above research addresses product classification in e-commerce, it neither considers class imbalance nor evaluates classifier behavior under varying numbers of classes. Thus, the challenges of multiclass imbalanced classification remain unexplored.
The study in [13] discusses the challenges faced by high-cardinality categorical variables. The research proposed an empirical Bayes preprocessing method to convert high-cardinality categorical attributes into numerical features for use in predictive models. The work in [14] demonstrates that a hierarchical Bayesian model can effectively handle high-cardinality attributes by modeling their interactions, resulting in improved classification performance and reduced overfitting. The study in [15] compares encoding strategies with SVM, Random Forest, and other classifiers for high-cardinality features. The author in [16] studies machine learning algorithms on datasets containing high-cardinality categorical variables and discusses their strengths and weaknesses. The work in [17] compared 179 classification algorithms from 17 machine learning families across 121 real-world datasets to identify the most effective classifiers for practical classification problems. The authors concluded that Random Forest and Support Vector Machine were among the most reliable and accurate classifiers for diverse real-world classification problems. The study in [18] explains the behavior of tree-based methods when categorical variables contain many levels. The study concluded that Decision Tree-based methods, including Random Forest, can produce biased predictions when categorical variables contain absent levels. Appropriate handling of these levels is necessary to improve model reliability. The research [19] concluded that Random Forest, Support Vector Machine, Logistic Regression, Decision Tree, and Naive Bayes represent complementary supervised learning approaches that provide competitive performance across diverse real-world classification tasks, making them suitable identified classifiers. The same five classifiers are used in this study for comparing multiclass classification performance.
The major contribution of the present study is the detailed analysis of multiclass classification performance due to both class cardinality and class imbalance. Unlike prior studies that primarily focus on binary or fixed cardinality classification problems, this work evaluates how increasing the number of classes influences the effectiveness and stability of machine-learning algorithms in imbalanced e-commerce datasets. The study identifies class cardinality as an independent driver of uncertainty.

2. Methodology

An e-commerce dataset comprising 3900 customers and eight variables was analyzed to investigate the effects of class cardinality and class imbalance on multiclass classification performance. The synthetic dataset of customer shopping trends contains features that include customer age, gender, purchase amount, preferred payment methods, frequency of purchases, and more. The publicly available dataset (https://www.kaggle.com/datasets/iamsouravbanerjee/customer-shopping-trends-dataset, accessed on 25 November 2025) adds valuable information to customer behavior and purchase patterns. Two continuous variables, namely ‘Age’ and ‘Purchase Amount,’ are selected as predictor features. The study uses only two predictor variables to isolate the effects of class cardinality and class imbalance without the added complexity of a large number of input features. These two continuous variables are used as inputs to train all the classifiers, while the categorical variables are used as target variables. The categorical variables ‘Category,’ ‘Season’ and ‘Size’ have 4 classes each; ‘Payment Method’ and ‘Shipping Type’ have 6 classes each; and ‘Frequency of Purchases’ has 7 classes. Table 1 and Table 2 give the class distribution (frequency and percentage) of the categorical variables. Table 1 shows a moderately imbalanced distribution for the variable ‘Category,’ with ‘Clothing’ clearly dominating. The four seasonal classes have nearly uniform frequencies, indicating a well-balanced categorical variable, suitable for fair multi-class classification. For the variable ‘size,’ there is a noticeable class imbalance, dominated by the ‘M’ size. Table 2 summarizes the class-wise frequency distribution of the three categorical variables, ‘Payment Method,’ ‘Shipping Type,’ and ‘Frequency of Purchases’, with 6 and 7 classes, along with their corresponding counts and percentages. The variable ‘Payment Method’ indicates a well-balanced class distribution, minimizing bias toward any single payment method. The variable ‘Shipping Type’ reflects a balanced categorical variable, suitable for fair multiclass classification. The variable ‘Frequency of Purchases,’ with 7 classes, shows slight variations but remains largely balanced overall. Despite higher class cardinality, no class dominates the dataset.
Five supervised machine-learning classifiers, namely, Gaussian Naive Bayes (GNB), Logistic Regression (LR), Random Forest (RF), Decision Tree (DT), and Support Vector Machine (SVM), are evaluated using a 5-fold cross-validation framework [20,21]. Model performance is assessed using accuracy, macro-F1 score, and log loss to capture classification accuracy, class-balanced performance, and probabilistic calibration, respectively [22,23]. To isolate the effect of class cardinality, a controlled experiment is conducted by artificially merging class labels to construct 2-, 4-, 6-, and 7-class scenarios while keeping the predictor variables and classifier fixed. Gaussian Naive Bayes is selected for this analysis because it directly estimates posterior probabilities from Bayes’ theorem, enabling the evaluation of posterior confidence, entropy, and log loss under varying class cardinalities [24,25,26]. The results are further validated using real categorical variables with naturally occurring class counts. Finally, the impact of class imbalance is examined by comparing classification performance before and after balancing selected target variables through random under-sampling. Statistical significance of model differences is assessed using paired t-tests and Wilcoxon signed-rank tests [27]. These tests are used when two continuous measurements are obtained from the same observations under two related conditions. The paired t-test evaluates whether the average difference between two related sets of observations is statistically significant when the differences follow a normal distribution. When this normality assumption is not satisfied, the Wilcoxon signed-rank test serves as a non-parametric alternative by comparing the ranks of the paired differences rather than their actual values.
Hyperparameter optimization was intentionally not performed in this study because the objective was to investigate the effects of class cardinality and class imbalance rather than maximize the predictive performance of individual classifiers. Standard MATLAB R2018a implementations were employed for all classifiers. Gaussian Naive Bayes and Decision Tree used the default settings provided by fitcnb and fitctree, respectively. Logistic Regression was implemented through an ECOC framework with a linear logistic learner, while Support Vector Machine used an ECOC framework with an RBF kernel and feature standardization. Random Forest was implemented using the TreeBagger algorithm with 100 trees. Identical predictor variables, 5-fold cross-validation partitions, and evaluation metrics were maintained across all experiments to ensure a fair comparison and to isolate the effects of class cardinality and class imbalance.

3. Results

In this section, we discuss the experimental results acquired from six multiclass e-commerce classification tasks with varying levels of class cardinality and class imbalance. The analysis is organized into four parts: (i) comparative evaluation of machine-learning classifiers; (ii) controlled investigation of class cardinality effects; (iii) real-variable validation of the observed trends; and (iv) assessment of the impact of class imbalance and statistical significance.

3.1. Comparative Performance of Machine Learning Classifiers

Six independent comparative experiments are conducted using two continuous features (age and purchase amount). Each experiment targeted one categorical variable with varying class cardinality (four, six or seven classes). Gaussian Naive Bayes, which is a probabilistic supervised classifier, was compared with widely used supervised machine-learning classifiers like Logistic Regression, Decision Trees, Random Forests, and Support Vector Machines using a five-fold cross-validation framework to assess relative effectiveness. All models are trained and tested using the same dataset, five-fold cross-validation, and identical evaluation metrics to ensure a fair comparison. The performance of the models is assessed using accuracy, average macro-F1 score, and log loss. The metric accuracy, which works well when classes are balanced, measures the proportion of correct predictions that the model computes. The macro-F1 score measures how well the model performs across all classes. For multiclass problems, such balanced evaluation provides overall correctness and reliability. The metric log loss evaluates how well the model assigns probability to the correct class. Lower values obtained indicate better probabilistic predictions. Five-fold cross-validation is used to evaluate model performance. The dataset is split into five mutually exclusive folds. Four folds are used for model training, and the remaining fold is used for testing during each iteration. Performance metrics are averaged across the five folds to obtain robust estimates and minimize the effects of sampling variability. Multiclass classification is handled in a model-dependent manner. Gaussian Naive Bayes, Decision Trees, and Random Forests natively support multiclass targets and are trained directly. Logistic Regression and Support Vector Machines, which are essentially binary classifiers, are extended to the multiclass setting using an Error-Correcting Output Codes (ECOC) framework with linear logistic and RBF (radial basis function) kernel SVM learners, respectively. This ensured consistent and fair evaluation across all classification tasks involving four to seven classes. An SVM with an RBF kernel is employed to model nonlinear relationships between customer age, purchase amount, and the target classes. Since SVMs are inherently binary, multiclass classification is achieved using an ECOC framework with RBF kernel SVM learners. Feature standardization is applied to ensure numerical stability and improve classification performance.
For the e-commerce dataset, Figure 1 and Figure 2 summarize the accuracy and macro-F1 score of the five classifiers (GNB, LR, DT, RF, and SVM) involving six multiclass classification tasks. Figure 1 shows that classification accuracy decreases as class cardinality increases from four to six to seven classes. Unlike accuracy, which measures the overall proportion of correct predictions, the macro-F1 score or F1 score analysis (Figure 2) shows that tree-based models (Decision Tree and Random Forest) provide better balance across classes and more effective identification of less frequent classes. Macro-F1 scores decrease as class cardinality increases from four to seven classes, highlighting the growing difficulty of maintaining performance across classes in higher cardinality classification tasks. Thus, higher accuracy does not necessarily imply better multiclass classification performance.
Table 3 evaluates model performance using the accuracy of metrics, macro-F1 scores, and log loss across the six independent multiclass experiments with increasing class cardinality, as discussed above. The performance of five supervised classifiers, Gaussian Naive Bayes (GNB), Logistic Regression (LR), Decision Tree (DT), Random Forest (RF), and Support Vector Machine (SVM), are reported across six categorical targets: ‘Category,’ ‘Size,’ ‘Season’ with four classes; ‘Payment Method,’ ‘Shipping Type,’ with six classes; and ‘Frequency of Purchase’ with seven classes.
Considering four class variables, the models GNB, LR, and SVM show identical accuracies for ‘Category’ and ‘Season’ (almost 0.44), suggesting these models are likely to predict dominant classes, but linear decision boundaries are insufficient to separate classes using only two features. Decision trees and random forests yield lower accuracies (0.34–0.36), indicating difficulty in learning stable splits from limited continuous inputs. Despite similar accuracies, GNB, LR, and SVM exhibit extremely low macro-F1 scores (almost 0.15) for ‘Category’ and ‘Season.’ This implies poor minority class recognition and class bias. Decision Tree and Random Forest achieve noticeably higher macro-F1 scores (0.23–0.26), indicating better balance across classes, even though overall accuracy is lower. High accuracy here is misleading. Tree-based models like Decision Tree and Random Forest provide reasonable multiclass predictions, as reflected by the macro-F1 score.
For the four-class variables (Category, Size, and Season), GNB consistently shows low log loss (1.2–1.4) and produces well-calibrated probability estimates. Logistic Regression and SVM exhibit extremely high log loss (almost 36), suggesting severely overconfident or numerically unstable probability outputs. Random Forest achieves moderate log loss (3–4), balancing discrimination and calibration. Considering performance on higher cardinality variables (six and seven classes), accuracy drops sharply across all models (0.14–0.18), reflecting the increased difficulty of classification with higher class cardinality. No model shows dominant accuracy, indicating a limited ability of the given features to distinguish between classes. For six- and seven-class variables, Decision Tree and Random Forest outperform all others in the macro-F1 score (0.15–0.17), demonstrating superior learning across classes in high-cardinality settings. Compared to LR and SVM, which have their limitations, GNB maintains a modest macro-F1 score (0.10–0.14). With the increasing number of classes, tree-based models perform better in terms of class balance, even when accuracy remains low. Although GNB shows weaker classification performance, it provides more reliable probability estimates by generating the lowest log loss (1.8–2.0). Random Forest maintains moderate log loss (6–9). For all experiments, LR and SVM show high log-loss values (almost 36), indicating less reliable probability estimations with varying class structures.
Therefore, accuracy alone is not sufficient to evaluate multiclass problems that have imbalance or a large number of classes. The macro-F1 score, which measures how well the model performs across all classes, is the most informative score in this study. Log loss shows probabilistic reliability, and the classifier GNB performs best. Random Forest emerges as the best overall model that provides balanced performance across classes along with stable probability estimations.
Table 3 demonstrates that increasing the number of classes significantly decreases classification performance for all models. The linear models show higher accuracy, but their low F1 score and high log-loss values indicate class-wise poor performance and also less reliable probability estimations. Again, considering Random Forest, which is a tree-based model, we can observe effective balance across the classes and stable probabilistic behavior. Although the classification performance is weak, Gaussian Naive Bayes computes the lowest log loss, indicating better probability estimates.

3.2. Controlled Analysis of Class Cardinality Effects

Next, to isolate the impact of class cardinality on multiclass tasks, the categorical variable ‘Frequency of Purchases,’ which naturally contains seven classes, is selected as the baseline target variable. Controlled scenarios with two, four, six, and seven classes are generated by systematically regrouping the original class labels using deterministic modulo-based mapping. The regrouping is neither random nor based on semantic similarity among the purchase frequency categories. It is performed solely to vary the number of target classes while keeping the predictor variables, classifier, and dataset unchanged. Among all classifiers, Gaussian Naive Bayes (GNB) is selected because it directly models posterior probabilities derived from Bayes’ theorem. By fixing the classifier and varying only the number of classes, the observed changes in confidence, entropy, and log loss can be attributed primarily to class cardinality rather than differences among learning algorithms.
Figure 3 illustrates the resulting changes in probabilistic behavior as class cardinality increases. A clear monotonic decline in mean posterior confidence is observed, decreasing from approximately 0.58 (2 classes) to 0.16 (7 classes). Entropy and log loss increase steadily, indicating greater uncertainty in the predicted class probabilities and reduced confidence in the classifier’s decisions. Thus, increasing the number of classes reduces posterior confidence while increasing entropy and log loss, and finally leads to greater uncertainty in probabilistic classification. Table 4 shows a monotonic decrease in posterior confidence accompanied by increased entropy and log loss as class cardinality increases. Thus, increasing class cardinality systematically reduces posterior confidence and increases uncertainty.
Artificial class cardinality control is used to isolate the effect of class count alone, whereas using different variables (Category, Season, Payment, etc.) introduces multiple confounding factors beyond class cardinality. Entropy and log loss were computed using the natural logarithm (base e). Accordingly, entropy is expressed in nats. The theoretical maximum entropy for a K-class problem is ln(K), which is attained only when the posterior probabilities are uniformly distributed across all classes. Since the classifier produces non-uniform posterior probability distributions, the observed entropy values are expected to be close to, but not necessarily equal to, ln(K).

3.3. Real-Variable Validation of Class Cardinality Effects

In addition to controlled class cardinality variation, real-variable validation was performed using categorical variables with naturally occurring class counts (four, six or seven classes). Figure 4 presents the class cardinality effect using real categorical variables with different classes and confirms the controlled experimental findings that increasing class cardinality is associated with reduced posterior confidence and increased entropy and log loss. Table 5 shows that the four-class variables (Category, Size, and Season) exhibit relatively higher confidence and lower uncertainty measures, whereas the six-class variables (Payment Method and Shipping Type) and the seven-class variable (Frequency of Purchases) display progressively lower confidence and higher entropy and log-loss values. These consistent trends demonstrate that the influence of class cardinality extends beyond controlled experiments and is also evident in real-world categorical variables.

3.4. Impact of Class Imbalance and Statistical Significance Testing

Next, the impact of class imbalance on posterior probability behavior is examined using a Gaussian Naive Bayes classifier. Two categorical variables are analyzed under five-fold cross-validation, one with a naturally imbalanced class distribution (Category) and another with a more uniform distribution (Frequency of Purchases). First, the model is trained and evaluated on the original data to obtain the macro-F1 score, posterior probability variance, and confusion entropy. Next, a balanced dataset is created by reducing the number of samples in the majority classes, and thus, class imbalance is addressed. Using the balanced dataset, the model was trained again, and the evaluation metrics were recomputed. Comparing the imbalanced and balanced datasets, we can examine the impact of unequal class distributions on probability confidence and uncertainty.
Table 6, with original and balanced evaluations, shows clearly the impact of class imbalance on posterior probability behavior for the ‘Category’ variable. Balancing the class distribution leads to an increase in the macro-F1 score from 0.154 to 0.293, indicating improvement in the recognition of less frequent classes. Balancing the dataset reduced overconfident predictions. Higher posterior probability variance and entropy suggested realistic estimations. In contrast, the variable ‘Frequency of Purchases’ shows very little change after balancing. The macro-F1 score increases from 0.101 to 0.111, which is a very small improvement, and the changes in probability variance and entropy are negligible. The stability observed shows that the variable is already balanced. Thus, the prediction uncertainty involved is influenced more by the large number of classes than by class imbalance. The above results show that class imbalance has a strong impact on prediction confidence and model performance, and this happens when there is strong class dominance. When variables are already balanced, resampling produces little change in performance or uncertainty.
Additional statistical tests were performed to check whether the observed differences between the models were real or due to random variation. Using five-fold cross-validation, Gaussian Naive Bayes was compared with the best-performing classifier model after considering a class-wise balanced dataset. Accuracy and log loss are computed for each fold, and paired statistical tests are applied across the folds. The paired t-test is used to compare the average performance of two models such that the data are normally distributed. The Wilcoxon signed-rank test is used when the data do not satisfy this normal condition. As we perform both tests, the conclusions about the model performance differences become more reliable.
‘Frequency of Purchases’ is chosen as the target variable, as its class distribution is already balanced and has minimal class imbalance effects. The models compared are Gaussian Naive Bayes (GNB) and Random Forest (RF), the latter of which is considered the best performing in this case. For each fold of cross-validation, accuracy and log loss are computed. As discussed above, statistical tests applied are the paired t-test and the Wilcoxon signed-rank test. The decision rule says that when p ≥ 0.05, the difference is likely due to chance, and when p < 0.05, the difference is statistically significant.
Accuracy for GNB is 0.1390, and accuracy for the best model, RF, is 0.1390. The paired t-test p-value is 1.0, and the Wilcoxon signed-rank p-value is 1.0. It is worth noting that both models achieve identical accuracy across all cross-validation folds. This results in no major difference to be observed or considered. Consequently, neither the parametric nor the non-parametric tests indicate statistical significance. Further, in terms of accuracy alone, the two models are the same for the selected target variable.
For the selected target variable, GNB achieved a lower log loss (1.95) than RF (8.93), indicating better probabilistic calibration. The paired t-test yielded a statistically significant difference (p = 3.07 × 10−5), whereas the Wilcoxon signed-rank test produced a p-value of 0.0625, which is slightly above the 0.05 significance level. This difference between the two tests is likely due to the limited sample size of only five cross-validation folds, which reduces the statistical power of the non-parametric Wilcoxon test. Therefore, the statistical evidence should be interpreted with caution. Although both models achieved identical classification accuracy, GNB consistently produced lower average log loss, suggesting more reliable probability estimation. However, given the small number of cross-validation folds, these findings should be regarded as preliminary rather than conclusive, and further validation using repeated cross-validation or additional datasets is recommended.

4. Discussion

The present study investigated the influence of class cardinality and class imbalance on multiclass classification in an e-commerce dataset. The findings suggest that increasing the number of target classes inherently increases the complexity of the classification task, making reliable probabilistic prediction more challenging. This highlights the importance of evaluating multiclass models using not only accuracy but also class-wise and probabilistic performance measures. The observed differences among classifiers further indicate that high overall accuracy does not necessarily imply balanced performance across all classes, underscoring the need to select evaluation metrics according to the objectives of the application.
One of the major findings of this study is that having more classes can make estimations more uncertain. The controlled experiments with varying numbers of classes and fixed features and classifiers showed decreased posterior or prediction confidence along with increased entropy and log loss. This behavior occurs because the classifier must distribute its probability mass or predicted probabilities across a larger number of competing classes. As the number of classes increases, the probability mass is distributed across many possible outcomes. This reduces maximum probability confidence and increases entropy, indicating more uncertainty in the classification process [28,29]. The increase in log loss shows that the model becomes less confident in its estimations as the number of classes increases. Thus, the study shows that increasing the number of classes increases prediction uncertainty even when the classifier and input features remain the same.
The validation experiments with real variables confirmed that the class cardinality effect extends beyond the controlled experiments performed previously. Categorical variables with six and seven classes exhibited lower probability confidence along with higher entropy and log-loss values than categorical variables with four classes. The similar trend between controlled and real variable analyses makes the conclusion strong that class cardinality exerts significant influence on probabilistic classification behavior. This observation is especially important for e-commerce applications, where tasks such as customer segmentation, product classification, and purchase frequency estimation often involve many categories.
The study found that unlike class cardinality, class imbalance has a different impact on model performance. As we balanced the imbalanced ‘Category’ variable, it produced results that showed improvement in the macro F1 score. This indicated improved classification of less frequent classes. On the other hand, balancing the already well-distributed ‘Frequency of Purchases’ variable resulted in only marginal changes. These results suggest that class imbalance affects model performance mainly because some classes have many more samples than others. Again, class cardinality influences the overall uncertainty of the classification problem. Therefore, class cardinality and class imbalance should be considered as two different factors such that they have related challenges influencing multiclass classification tasks.
This work is not about comparing machine learning algorithms. Instead, it demonstrates that class cardinality is an independent factor for predicting uncertainty in multiclass e-commerce classification. It shows that increasing the number of classes increases prediction uncertainty. Previous studies have focused on improving classification accuracy or reducing class imbalance. This study isolates the effect of increasing the number of target classes while keeping the predictor variables and classifier unchanged. This controlled experiment enables the observed changes in posterior confidence, entropy, and log loss to be attributed specifically to class cardinality rather than to differences in features or the learning algorithm.
The primary contribution of this study lies in isolating the effect of class cardinality on probabilistic confidence, entropy, and log loss and, at the same time, examining the role of class imbalance. Unlike previous studies that focus primarily on comparison of machine learning classifiers or correction of class imbalance, the present work demonstrates that increasing class cardinality itself contributes to uncertainty estimation. The combination of controlled experiments and real variable validation provides strong evidence that class cardinality should be considered an important factor when developing reliable e-commerce classification and decision support systems.
Although the present investigation is conducted using a single e-commerce dataset, the main conclusions are expected to extend beyond this specific application. The observed relationship between increasing class cardinality and increasing prediction uncertainty originates from the distribution of posterior probability across a larger number of competing classes, a property that is fundamental to multiclass probabilistic classification rather than specific to the dataset analyzed. Nevertheless, the magnitude of the effect may differ across datasets depending on feature quality, class separability, sample size, dimensionality, and class imbalance. Therefore, the present results should be interpreted as demonstrating a general trend rather than establishing universal quantitative values. Future studies should validate these findings using datasets from diverse application domains such as healthcare, finance, remote sensing, image recognition, and text classification.

5. Business Implications

The results of this study have important implications for the design and deployment of e-commerce analytics systems. As the number of product categories increases, prediction confidence decreases and uncertainty increases, which can negatively affect recommendation and inventory management systems. Customer grouping approaches that create a large number of highly specific customer groups may decrease predictive reliability. As a result, this makes it more difficult to accurately identify customer preferences and purchasing behavior. The study [30] demonstrates that advanced machine learning models improve customer segmentation and prediction performance. Hence, the importance of reliable classification for marketing and personalization strategies is recognized. In marketing analytics, businesses should consider more than just classification accuracy when increasing the number of customer or product classes. Evaluating uncertainty metrics such as entropy and log loss can offer important insights into the confidence and reliability of model predictions. The research [31] proposes uncertainty-based classification techniques that explicitly quantify uncertainty in categories, emphasizing the importance of uncertainty measures alongside accuracy when making business decisions. The results also suggest that personalization systems with many classes may need additional customer information, behavioral data, or improved classification methods to maintain good predictive performance. Overall, the study emphasizes the importance of maintaining a balance between the number of categories and predictive reliability when designing data-driven decision support systems for e-commerce applications.

6. Conclusions

This study investigated the effects of class cardinality and class imbalance on multiclass classification in an e-commerce dataset. Its primary contribution is demonstrating that class cardinality is an independent source of predictive uncertainty. By systematically varying the number of target classes while keeping the classifier and predictor variables unchanged, the study isolated the effect of class cardinality on probabilistic prediction. The observed trends were further validated using real categorical variables with naturally occurring class counts, confirming the broader applicability of the proposed framework.
The study also showed that class imbalance and class cardinality influence classification performance through different mechanisms. Class imbalance primarily affects the recognition of less frequent classes, whereas class cardinality exerts a broader influence on probabilistic confidence and prediction uncertainty, even in relatively balanced datasets. The primary contribution of this work is the conceptual demonstration that class cardinality should be regarded as an independent factor governing predictive uncertainty in multiclass classification, its controlled experimental methodology, and its validation framework, rather than in the empirical comparison of classifiers alone.
Overall, the results emphasize the importance of considering both class cardinality and class imbalance, together with probabilistic evaluation measures, when assessing multiclass classification models. The results have practical implications for customer segmentation, product categorization, marketing analytics, and personalization systems in e-commerce. Increasing the number of categories may improve business specificity but can also reduce predictive reliability and increase uncertainty. Future work may extend this analysis to larger datasets, additional machine-learning and deep-learning models, and hierarchical classification frameworks for managing high-cardinality prediction tasks.

Author Contributions

Conceptualization, M.S. and I.G.; methodology, M.S. and P.M.; software, I.G.; validation, P.M., I.G. and M.S.; formal analysis, J.P. and M.S.; investigation, P.M.; resources, I.G.; data curation, P.M. and S.S.; writing—original draft preparation, M.S.; writing—review and editing, P.M.; visualization, I.G.; supervision, P.M.; project administration, I.G.; funding acquisition, I.G. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Data Availability Statement

The original data presented in the study are openly available in https://www.kaggle.com/datasets/iamsouravbanerjee/customer-shopping-trends-dataset (accessed on 25 November 2025).

Acknowledgments

The authors are thankful to Techno India University, West Bengal, for the support given during the work.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Valencia-Arias, A.; Uribe-Bedoya, H.; González-Ruiz, J.D.; Santos, G.S.; Ramírez, E.C.; Rojas, E.M. Artificial intelligence and recommender systems in e-commerce. Trends and research agenda. Intell. Syst. Appl. 2024, 24, 200435. [Google Scholar] [CrossRef] [Scilit]
  2. Madanchian, M. The Role of Complex Systems in Predictive Analytics for E-Commerce Innovations in Business Management. Systems 2024, 12, 415. [Google Scholar] [CrossRef] [Scilit]
  3. Anthoniraj, S.; Kumar, A.N.; Hemakumar Reddy, G.; Raju, M. Classification of Imbalanced Data in E-Commerce. In International Conference on Smart and Sustainable Technologies in Energy and Power Sectors (SSTEPS); IEEE: Mahendragarh, India, 2022; pp. 204–209. [Google Scholar] [CrossRef] [Scilit]
  4. Chen, W.; Yang, K.; Yu, Z.; Shi, Y.; Philip Chen, C.L. A survey on imbalanced learning: Latest research, applications and future directions. Artif. Intell. Rev. 2024, 57, 137. [Google Scholar] [CrossRef] [Scilit]
  5. Suguna, R.; Suriya Prakash, J.; Aditya Pai, H.; Mahesh, T.R.; Vinoth Kumar, V.; Yimer, T.E. Mitigating class imbalance in churn prediction with ensemble methods and SMOTE. Sci. Rep. 2025, 15, 16256. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  6. Wu, Z.; Jin, L.; Zhao, J.; Jing, L.; Chen, L. Research on Segmenting E-Commerce Customer through an Improved K-Medoids Clustering Algorithm. Comput. Intell. Neurosci. 2021, 2022, 9930613. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  7. Cevahir, A.; Murakami, K. Large-scale Multi-class and Hierarchical Product Categorization for an E-commerce Giant. In Proceedings of COLING 2016, the 26th International Conference on Computational Linguistics: Technical Papers; The COLING 2016 Organizing Committee: Osaka, Japan, 2016; pp. 525–535. [Google Scholar]
  8. Guo, C.; Pleiss, G.; Sun, Y.; Weinberger, K.Q. On Calibration of Modern Neural Networks. arXiv 2017, arXiv:1706.04599. [Google Scholar] [CrossRef] [Scilit]
  9. 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. Artif. Intell. Rev. 2023, 56, 1513–1589. [Google Scholar] [CrossRef] [Scilit]
  10. Xu, F.; Pan, Z.; Xia, R. E-commerce product review sentiment classification based on a naïve Bayes continuous learning framework. Inf. Process. Manag. 2020, 57, 102221. [Google Scholar] [CrossRef] [Scilit]
  11. Deniz, E.; Erbay, H.; Coşar, M. Multi-Label Classification of E-Commerce Customer Reviews via Machine Learning. Axioms 2022, 11, 436. [Google Scholar] [CrossRef] [Scilit]
  12. Lei, B.; Wang, J.; Shen, C. Automatic classification method of e-commerce commodity raw materials through the introduction of self-supervised concepts and the construction of domain ontology. Sci. Rep. 2026, 16, 8058. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  13. Micci-Barreca, D. A preprocessing scheme for high-cardinality categorical attributes in classification and prediction problems. ACM SIGKDD Explor. Newsl. 2001, 3, 27–32. [Google Scholar] [CrossRef] [Scilit]
  14. Jambeiro Filho, J.; Wainer, J. Using a Hierarchical Bayesian Model to Handle High Cardinality Attributes with Relevant Interactions in a Classification Problem. In Proceedings of the IJCAI’07: Proceedings of the 20th International Joint Conference on Artificial Intelligence, Hyderabad, India, 6–12 January 2007; pp. 2504–2509. Available online: https://dl.acm.org/doi/10.5555/1625275.1625679 (accessed on 23 May 2026).
  15. Pargent, F.; Pfisterer, F.; Thomas, J.; Bischl, B. Regularized target encoding outperforms traditional methods in supervised machine learning with high cardinality features. arXiv 2021, arXiv:2104.00629. [Google Scholar] [CrossRef] [Scilit]
  16. Sigrist, F. A Comparison of Machine Learning Methods for Data with High-Cardinality Categorical Variables. arXiv 2023, arXiv:2307.02071. [Google Scholar] [CrossRef] [Scilit]
  17. Fernández-Delgado, M.; Cernadas, E.; Barro, S.; Amorim, D. Do We Need Hundreds of Classifiers to Solve Real World Classification Problems? J. Mach. Learn. Res. 2014, 15, 3133–3181. [Google Scholar]
  18. Caruana, R.; Niculescu-Mizil, A. An Empirical Comparison of Supervised Learning Algorithms. In ICML ‘06: Proceedings of the 23rd International Conference on Machine Learning; Association for Computing Machinery: New York, NY, USA, 2026; pp. 161–168. [Google Scholar] [CrossRef] [Scilit]
  19. Au, T.C. Random Forests, Decision Trees, and Categorical Predictors: The “Absent Levels” Problem. arXiv 2017, arXiv:1706.03492. [Google Scholar] [CrossRef] [Scilit]
  20. Rodriguez, J.D.; Perez, A.; Lozano, J.A. Sensitivity Analysis of k-Fold Cross Validation in Prediction Error Estimation. IEEE Trans. Pattern Anal. Mach. Intell. 2010, 32, 569–575. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  21. Abedin, T.; Xu, H.; Uddin, S. The impact of K selection in K-fold cross-validation on bias and variance in supervised learning models. Sci. Rep. 2026, 16, 6084. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  22. Rainio, O.; Teuho, J.; Klén, R. Evaluation metrics and statistical tests for machine learning. Sci. Rep. 2024, 14, 6086. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  23. Farhadpour, S.; Warner, T.A.; Maxwell, A.E. Selecting and Interpreting Multiclass Loss and Accuracy Assessment Metrics for Classifications with Class Imbalance: Guidance and Best Practices. Remote Sens. 2023, 16, 533. [Google Scholar] [CrossRef] [Scilit]
  24. Stern, H.S. Bayesian Statistics. In International Encyclopedia of the Social & Behavioral Sciences; Smelser, N.J., Baltes, P.B., Eds.; Pergamon: Oxford, UK, 2001; pp. 1052–1056. [Google Scholar] [CrossRef] [Scilit]
  25. Ramos, D.; Franco-Pedroso, J.; Lozano-Diez, A.; Gonzalez-Rodriguez, J. Deconstructing Cross-Entropy for Probabilistic Binary Classifiers. Entropy 2018, 20, 208. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  26. Warren, E.M.; Handley, J.C.; Sheets, H.D. Cross entropy and log likelihood ratio cost as performance measures for multi-conclusion categorical outcomes scales. J. Forensic Sci. 2025, 70, 589–606. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  27. Cleophas, T.J.; Zwinderman, A.H. Paired Continuous Data (Paired T-Test, Wilcoxon Signed Rank Test, 10 Patients). In SPSS for Starters and 2nd Levelers; Springer: Cham, Switzerland, 2016. [Google Scholar] [CrossRef] [Scilit]
  28. Bishop, C.M. Pattern Recognition and Machine Learning; Springer: New York, NY, USA, 2006. [Google Scholar]
  29. Cover, T.M.; Thomas, J.A. Elements of Information Theory, 2nd ed.; Wiley: Hoboken, NJ, USA, 2006. [Google Scholar] [CrossRef] [Scilit]
  30. Balasundaram, E.; Aranganathan, P.; Annavajjala, K.S.; Sivakumar, R.; Arumugam, M.; Vinoth, A. A Hybrid Approach for Customer Segmentation and Loyalty Prediction in E-Commerce. Prabandhan Indian J. Manag. 2024, 17, 56–69. [Google Scholar] [CrossRef] [Scilit]
  31. Zhang, J.; Qiu, Y.; Dong, L. Conformal deep forest for uncertainty-aware classification. J. King Saud Univ. Comput. Inf. Sci. 2025, 37, 155. [Google Scholar] [CrossRef] [Scilit]
Figure 1. Comparison of classification accuracy across six multiclass ecommerce prediction tasks.
Figure 1. Comparison of classification accuracy across six multiclass ecommerce prediction tasks.
Analytics 05 00036 g001
Figure 2. Comparison of F1 scores across six multiclass ecommerce prediction tasks.
Figure 2. Comparison of F1 scores across six multiclass ecommerce prediction tasks.
Analytics 05 00036 g002
Figure 3. Effect of class cardinality on posterior confidence, entropy, and log loss.
Figure 3. Effect of class cardinality on posterior confidence, entropy, and log loss.
Analytics 05 00036 g003
Figure 4. Real-variable validation of the effect of class cardinality on confidence, entropy, and log loss.
Figure 4. Real-variable validation of the effect of class cardinality on confidence, entropy, and log loss.
Analytics 05 00036 g004
Table 1. Summary of the categorical variables with 4 classes.
Table 1. Summary of the categorical variables with 4 classes.
CategorySeasonSize
ClassesFrequencyClassesFrequencyClassesFrequency
Accessories1240 (31.79%)Fall975 (25.00%)L1053 (27.00%)
Clothing1737 (44.54%)Spring999 (25.62%)M1755 (45.00%)
Footwear599 (15.36%)Summer955 (24.49%)S663 (17.00%)
Outerwear324 (8.31%)Winter971 (24.90%)XL429 (11.00%)
Table 2. Summary of the categorical variables with 6 and 7 classes.
Table 2. Summary of the categorical variables with 6 and 7 classes.
Payment MethodShipping TypeFrequency of Purchases
ClassesFrequencyClassesFrequencyClassesFrequency
Bank Transfer612 (15.69%)2-Day Shipping627 (16.08%)Annually572 (14.67%)
Cash670 (17.18%)Express646 (16.56%)Bi-Weekly547 (14.03%)
Credit Card671 (17.21%)Free Shipping675 (17.31%)Every 3 months584 (14.97%)
Debit Card636 (16.31%)Next Day Air648 (16.62%)Fortnightly542 (13.90%)
PayPal677 (17.36%)Standard654 (16.77%)Monthly553 (14.18%)
Venmo634 (16.26%)Store Pickup650 (16.67%)Quarterly563 (14.44%)
Weekly539 (13.82%)
Table 3. Comparative analysis of five machine-learning classifiers for six multiclass e-commerce classification tasks.
Table 3. Comparative analysis of five machine-learning classifiers for six multiclass e-commerce classification tasks.
CategorySizeSeason
ModelAccuracyF1 scoreLog lossAccuracyF1 scoreLog lossAccuracyF1 scoreLog loss
GNB0.44540.15401.22040.25310.23571.38680.45000.15511.2594
LR0.44540.154036.04370.26130.239936.04370.45000.155136.0437
DT0.36080.23468.79960.25590.255111.07770.34150.23919.2554
RF0.34380.23863.89500.25920.25863.61130.33950.26173.6257
SVM0.44540.154036.04370.25510.249736.04370.45000.155136.0437
Payment MethodShipping TypeFrequency of Purchase
ModelAccuracyF1 scoreLog lossAccuracyF1 scoreLog lossAccuracyF1 scoreLog loss
GNB0.16330.12081.79600.16900.13981.79480.13950.10301.9508
LR0.15360.097436.04370.16690.136336.04370.14050.096736.0437
DT0.16620.165316.01000.16920.168115.82300.14560.143917.4117
RF0.16150.16097.18040.16490.16486.88320.15260.15229.0245
SVM0.16080.136836.04370.17740.170736.04370.14670.134336.0437
Table 4. Effect of class cardinality on probability confidence (Gaussian Naive Bayes).
Table 4. Effect of class cardinality on probability confidence (Gaussian Naive Bayes).
Number of ClassesMean ConfidenceMean EntropyLog Loss
20.5764428710.6811775210.682370808
40.2963328341.3482757261.352318492
60.2848258491.7465937821.752378223
70.1565025231.94360291.950618192
Table 5. Real-variable validation of class cardinality effect (using Gaussian Naive Bayes).
Table 5. Real-variable validation of class cardinality effect (using Gaussian Naive Bayes).
VariableNumber of ClassesMean ConfidenceMean EntropyLog Loss
Category40.4457145551.2174898451.219867201
Size40.2714139791.3837607181.387446215
Season40.4499233141.2554569131.258927761
Payment Method60.1824274391.7895780891.795229106
Shipping Type60.1824004761.7893314661.793801015
Frequency Purchases70.1565025231.94360291.950618192
Table 6. Impact of class imbalance on probability measures using Gaussian Naive Bayes.
Table 6. Impact of class imbalance on probability measures using Gaussian Naive Bayes.
VariableMacro-F1 Score OriginalMacro-F1 Score BalancedProbability Variance OriginalProbability Variance BalancedConfusion Entropy OriginalConfusion Entropy Balanced
Category0.1540352410.2934783740.0001557420.0001652451.2175320351.382238689
Frequency Purchases0.1006411230.1111986723.23 × 10−53.21 × 10−51.9435627751.944018522
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Ghosh, I.; Sinha, M.; Mallick, P.; Poray, J.; Sarkar, S. Class Cardinality as a Source of Prediction Uncertainty in E-Commerce Customer Analytics. Analytics 2026, 5, 36. https://doi.org/10.3390/analytics5030036

AMA Style

Ghosh I, Sinha M, Mallick P, Poray J, Sarkar S. Class Cardinality as a Source of Prediction Uncertainty in E-Commerce Customer Analytics. Analytics. 2026; 5(3):36. https://doi.org/10.3390/analytics5030036

Chicago/Turabian Style

Ghosh, Ishan, Mourani Sinha, Partho Mallick, Jayanta Poray, and Souvik Sarkar. 2026. "Class Cardinality as a Source of Prediction Uncertainty in E-Commerce Customer Analytics" Analytics 5, no. 3: 36. https://doi.org/10.3390/analytics5030036

APA Style

Ghosh, I., Sinha, M., Mallick, P., Poray, J., & Sarkar, S. (2026). Class Cardinality as a Source of Prediction Uncertainty in E-Commerce Customer Analytics. Analytics, 5(3), 36. https://doi.org/10.3390/analytics5030036

Article Metrics

Back to TopTop