We evaluated the four trained models: RoBERTa, Random Forest, XGBoost, and the combined model using stacking. We perform the evaluations on 20% of the data set (200,799 records), reserved for testing.
4.1.1. Hate Speech Detection Models
For the binary classification task (hate vs. non-hate), we evaluated the four trained models on the test data set.
Table 6 presents the results of Precision, Recall, and F1-Score for each class (0 = No hate, 1 = Hate).
Regarding the accuracy metric, we obtain the following values:
RoBERTa = 0.90;
Random Forest = 0.91;
XGBoost = 0.89;
Combined = 0.93.
The confusion matrix for each trained model is shown in
Table 7.
We observed that the stacked model outperforms the individual models with a higher number of true positives and negatives and a lower number of false positives and negatives. This means that the model has better predictive power and a higher F1 Score. This shows that a stacked model learns from previous predictions and improves performance. Finally, we obtained an accuracy value of 0.93 for the stacked model.
The confusion matrix shown in
Table 7 reveals a higher number of false positives compared to the Random Forest model (FP = 11,758 vs. 9806). This behavior is due to the characteristics of transformer-based models. RoBERTa uses contextual embeddings that capture more complex semantic patterns in the text. Consequently, the model may classify some comments containing potentially offensive lexemes as hate speech, even when the full context does not express explicit hostility. This sensitivity improves hate speech detection but also increases the number of false positives. In comparison, the Random Forest model trained with TF-IDF relies on rigid lexical features and tends to be conservative in its predictions, reducing false positives, although it may limit the detection of hateful expressions.
To verify whether performance differences between models were statistically significant, we calculated 95% confidence intervals for the
accuracy metric of the test-set. For this, we used Wilson’s method for proportions [
51], which provides more robust confidence intervals for binomial proportions than the classical approach. The confidence interval was calculated as follows in Equation (
8).
where
represents the accuracy proportion,
n is the total number of instances in the test set, and
z corresponds to the critical value of the normal distribution for a confidence level of 95% (
).
The results show that the confidence intervals for the analyzed models are as follows: RoBERTa [0.8987, 0.9013], Random Forest [0.9087, 0.9112], XGBoost [0.8886, 0.8914] and the combined model [0.9289, 0.9311].
We note that the confidence interval of the combined model does not overlap with those of the individual models. This suggests that the observed performance improvement is unlikely to be due to random variation in the test set.
Furthermore, to evaluate the models’ performance, we used the Receiver Operating Characteristic (ROC) curve. As Google for Developers (2025) notes, the ROC curve graphically depicts the model’s performance across all thresholds. The AUC (area under the curve) value represents the probability that the model will correctly classify a positive example better than a negative one. A higher AUC indicates a better model.
Figure 10 presents the ROC curves. We see that the models achieve significant performance, with areas under the curve exceeding 0.95. The combined model achieves an area under the curve of 0.98, indicating a greater capacity to detect hate speech.
4.1.2. Emotional Tone Classification Models
For multiclass emotion classification, we evaluated the four models in the test data set. In
Table 8, we present the results of precision, recall and F1-Score for each of the seven emotions (i.e., anger, disgust, fear, joy, neutral, sadness, and surprise).
Regarding the accuracy metric, we obtain the following values:
RoBERTa = 0.75;
Random Forest = 0.85;
XGBoost = 0.86;
Combined = 0.90.
As shown in
Table 9, we present the confusion matrices for each model, where true positives (TP), true negatives (TN), false positives (FP), and false negatives (FN) are grouped by emotion label.
Each colored curve in
Figure 10 represents the performance of a different model (i.e., XGBoost, Random Forest, RoBERTa, and the meta-model), while the AUC values indicate its discriminatory power. The dashed diagonal line represents a reference random classifier. Curves closer to the upper left corner indicate better model performance in terms of true positive rate (TPR) versus false positive rate (FPR).
The results show that the combined model’s values surpass the evaluated metrics for most emotions. For the anger label, it achieves an accuracy of 0.94, a recall of 0.95, and an F1-score of 0.94, compared to the other individual models. For the disgust label, it achieves an accuracy of 0.82, a recall of 0.84, and an F1-score of 0.83. Regarding the fear label, it achieved an accuracy of 0.88 and an F1-score of 0.83, compared to the RoBERTa model, which had the lowest values with an accuracy of 0.43 and an F1-score of 0.57. Similarly, for the joy label, it achieves 0.88 in accuracy, recall, and F1-score. Although the value for the neutral label is lower, it still outperforms the other individual models. Finally, in the sadness label, it achieved an F1 score of 0.81 compared to 0.54 for RoBERTa. These results indicate that the combined model performs better across all labels.
We performed the procedure described above to analyze the statistical validity of the results. We calculated 95% confidence intervals for the accuracy metric using Wilson’s method for binomial proportions [
51].
The intervals obtained for the evaluated models were: RoBERTa [0.7481, 0.7519], Random Forest [0.8484, 0.8516], XGBoost [0.8585, 0.8615], and the combined model [0.8987, 0.9013].
These results indicate that the confidence interval of the combined model remains clearly separated from those of the individual models, suggesting that the observed improvement is unlikely to be explained by random variation.
The confusion matrices presented in
Table 9 support these results. The combined model shows higher values for true positives and true negatives while reducing false positives and false negatives in most emotions, suggesting a greater generalization capacity.
Figure 11 presents the ROC curves for each emotion. In this case, since it is a multi-class problem, we generated one curve per label. The combined model achieved curves closest to the ideal point, with higher AUC values for most emotions, notably
anger (0.98),
fear (0.99),
joy (0.98), and
sadness (0.98).
The multiple colored curves in
Figure 11 represent the performance of the different models (i.e., XGBoost, Random Forest, RoBERTa, and the meta-model) for each emotional category. Each line corresponds to a specific emotion, and its AUC value reflects its classification performance. The dashed diagonal line indicates the performance of a random classifier, while curves closer to the upper-left corner indicate better performance.
4.1.3. REST API Performance Testing
We conducted performance tests to verify the RESTful API’s behavior under multiple concurrent users. We used Apache JMeter, a tool that allowed us to simulate user loads and generate real-time reports, measuring metrics such as average, minimum and maximum response times, standard deviation, error rate, and throughput. In each test, we configure a different number of users and a progressive increment period. The number of users increases by 100 to a maximum of 600.
Table 10 shows the details of the results obtained.
By exposing the API through an access tunnel with Ngrok, we identified bandwidth and traffic-control limitations that affected response times. With loads of 100 and 200 users, the API remained stable, with average response times of 27,651 ms and 52,630 ms, respectively, and no errors were recorded. Starting with 300 users, although the average response time decreased (49,008 ms), errors were reported (13%), reflecting an overload in the handling of concurrent requests. This trend intensified with 400 users (15.25% errors), and especially with 500 and 600 users, where errors reached 35% and 52.83%, respectively, demonstrating the API’s inability to process all requests.
The throughput increased from 1.27 req/s (100 users) to 2.33 req/s (600 users), indicating that the system attempted to process more requests, although not all were successful. Similarly, bandwidth consumption increased from 0.74 KB/s to 4.45 KB/s, highlighting the need for servers with greater power and capacity to support high concurrent loads.
The system was evaluated under controlled conditions as a proof-of-concept deployment scenario. While the API remained functionally stable up to approximately 200 concurrent users, the observed response times (27,651 ms for 100 users and 52,630 ms for 200 users) suggest that the current implementation does not meet the latency requirements of real-time or pre-moderation systems. Therefore, the proposed system should be interpreted as a proof of concept that validates the feasibility of the approach, rather than a production-ready solution.
Before introducing the BACON-AR framework, it is important to clarify that the performance metrics reported in the previous subsections correspond to the predictive capacity of the ensemble classifier itself. The BACON-AR framework does not modify the trained architecture or retrain the predictive models. Instead, it operates as a post hoc analytical layer applied to the probabilistic outputs generated by the ensemble.
Consequently, the purpose of the BACON-AR analysis is not to improve classification performance metrics such as accuracy or AUC but rather to analyze the calibration of predicted probabilities and determine an optimal decision threshold under asymmetric risk conditions. This distinction ensures that the predictive evaluation of the ensemble model and the risk-sensitive decision analysis performed by BACON-AR remain conceptually separated.
4.1.4. Analysis of the Bayesian Calibration and Optimal Design Under Asymmetric Risk (BACON-AR) Framework
This section analyzes the probabilistic output generated by the ensemble model using the BACON-AR framework. The objective is to evaluate the calibration of predicted probabilities and determine an optimal decision threshold under asymmetric risk conditions without modifying the underlying predictive model.
The
BACON-AR framework, defined in
Section 3.6.9, was applied to the validation data set to evaluate its empirical behavior under asymmetric decision costs. The ensemble model’s underlying architecture remained unchanged; only the probabilistic outputs were post-processed using Bayesian calibration and risk-based threshold optimization. In the experimental setup, asymmetric costs were defined as
, reflecting the greater impact of false negatives on the target classification scenario.
The experimental configuration used to evaluate the
BACON-AR framework is summarized in
Table 11. While
Table 12 presents the comparative results between the original ensemble classifier and the same model after applying the
BACON-AR framework. The analysis focuses not only on traditional performance metrics (e.g., AUC, recall, and precision) but also on calibration behavior, minimum risk, and the decision threshold obtained via asymmetric risk minimization.
To avoid potential confusion, it is important to clarify that the metrics reported correspond to different stages and tasks within the proposed framework. The accuracy values close to 0.90 reflect the standalone performance of the base classifiers on specific tasks, such as hate speech detection and emotional tone classification. In contrast, the metrics reported in
Table 12 correspond exclusively to the final ensemble output evaluated under the BACON-AR decision framework.
From an interpretative perspective, the results reported in
Table 12 indicate that the ensemble classifier already produces reasonably calibrated probability estimates. Consequently, the Bayesian adjustment introduced by the
BACON-AR procedure does not substantially modify the Expected Calibration Error.
It is important to distinguish between probability calibration and decision optimization. Although the Expected Calibration Error (ECE) remains approximately unchanged after BACON-AR is applied, this does not indicate a lack of contribution. Instead, BACON-AR operates at the decision level by selecting an operating threshold under asymmetric risk conditions.
BACON-AR does not modify the predictive architecture or improve its intrinsic classification performance. Instead, it operates as a post hoc decision layer over the ensemble probabilities. In the present results, its demonstrated contribution lies in selecting an operating threshold that minimizes total expected risk under asymmetric cost conditions. Therefore, the empirical effect of BACON-AR should be interpreted as cost-sensitive threshold optimization rather than as an improvement in predictive performance or a clear numerical gain in calibration.
The data used for this analysis came from the combined model trained with RoBERTa, Random Forest, and XGBoost. In the
BACON-AR evaluation summarized in
Table 12, the ensemble output achieved an AUC of 0.883, a recall of 93.5%, and a precision of 72.3%, while the framework was further analyzed from the perspective of calibration and asymmetric risk minimization.
Although the ensemble probabilities
were already reasonably calibrated according to the Expected Calibration Error reported in
Table 11, the
BACON-AR framework includes a Bayesian recalibration step as part of its structured post hoc decision procedure. In this context, the recalibration stage was applied to examine whether a lower-risk operating threshold could be obtained under asymmetric cost conditions rather than to correct a substantial calibration deficiency in the underlying ensemble model. This use of calibration remains consistent with the probabilistic interpretation of predicted confidence discussed in the calibration literature [
39]. The general calibration formula is defined as
where
represents the calibrated probability,
the original probability of the model, and
and
are the empirical proportions observed of the positive and negative classes. This adjustment aims to align the predicted probabilities with the observed empirical class proportions, following the calibration approaches described in the literature [
16,
40]. The calibration quality is subsequently evaluated through the Expected Calibration Error (ECE), which measures the discrepancy between the predicted confidence and the empirical accuracy across probability bins.
The computational development of the
BACON-AR framework was implemented in
Python, using
NumPy and
Pandas for probability calculations, calibration, and risk optimization. The mathematical procedure is summarized in Algorithm 4, which combines Bayesian calibration and the search for the optimal threshold
that minimizes total risk
.
| Algorithm 4: BACON-AR: Bayesian Calibration and Optimal Threshold Selection under Asymmetric Risk. |
![Futureinternet 18 00218 i004 Futureinternet 18 00218 i004]() |
The proposed BACON-AR procedure integrates Bayesian posterior recalibration with cost-sensitive decision optimization under asymmetric misclassification penalties. The calibration stage adjusts predicted probabilities according to empirical class priors, reducing prior-shift distortions and improving probabilistic interpretability.
Calibration quality is quantitatively assessed using the Expected Calibration Error (ECE), which measures the discrepancy between empirical accuracy and predicted confidence across probability bins.
The final decision rule is obtained by minimizing an asymmetric empirical risk function that explicitly incorporates differentiated costs for false negatives and false positives.
This formulation is in line with established principles in the evaluation and calibration theory of probabilistic models [
52,
53], ensuring the deployment of a statistically coherent and decision-aware model.
In this study, the Bayesian component of the BACON-AR framework refers specifically to posterior recalibration using empirical class priors estimated from the validation data, rather than to a fully parameterized Bayesian generative model with externally imposed prior distributions.
In practical terms, the ensemble probabilities are adjusted according to the proportions of the observed class before the asymmetric empirical risk is minimized. This clarification aligns the terminology of the framework with the mathematical apparatus actually implemented in the present study.
The Algorithm 4 summarizes the implementation of the
BACON-AR framework. Before presenting the BACON-AR comparative results,
Table 11 summarizes the experimental configuration used for calibration assessment, asymmetric-risk analysis, and threshold selection.
Starting with the ensemble probabilities, Bayesian calibration is applied, the expected calibration error (ECE) is calculated, and the asymmetric risk curve is obtained. The optimal threshold is selected as the point that minimizes , ensuring a decision consistent with the costs assigned to false negatives and false positives.
The parameters summarized in
Table 11 describe the experimental configuration used to evaluate the BACON-AR framework.
It is important to note that the AUC, recall, and precision values reported in
Table 12 correspond to the preserved predictive metrics of the underlying ensemble and are included to show that BACON-AR does not improve baseline predictive performance. By contrast, the quantities reported later in the sensitivity analysis correspond to threshold-dependent operating characteristics obtained under specific asymmetric cost ratios and should not be interpreted as directly comparable replacements for the values in
Table 12.
As shown in
Table 12, the global predictive metrics reported in this BACON-AR analysis, namely AUC, recall and precision, remained stable after the procedure was applied.
From a calibration perspective, the Expected Calibration Error (ECE) also remained numerically similar before and after the Bayesian adjustment, indicating that the ensemble classifier already produced reasonably calibrated probability estimates.
By identifying an optimal decision threshold, the framework allows the model to adapt its behavior to the relative impact of false negatives and false positives without altering its intrinsic predictive capacity.
This indicates that the framework does not alter the intrinsic predictive capability of the ensemble classifier but rather evaluates how probabilistic outputs can be translated into decisions under asymmetric cost conditions. Under the selected asymmetric cost configuration, adjusting the operating threshold from 0.50 to reduced the total risk without changing the reported predictive metrics. Therefore, the demonstrated contribution of BACON-AR in this study, should be interpreted as cost-sensitive threshold optimization on top of an existing classifier rather than as an improvement in predictive performance or a clear numerical gain in calibration.
These findings were further examined through calibration analysis using the reliability diagrams shown in
Figure 12. The dashed diagonal line represents perfect calibration, whereas the empirical curves correspond to the ensemble probabilities before and after applying the
BACON-AR framework. The visual comparison indicates that the probabilistic estimates remain close to the ideal calibration trend, supporting the interpretation that
BACON-AR preserves the ensemble output’s overall reliability structure while redefining the operating threshold under asymmetric cost conditions.
The comparison between the uncalibrated model and the output obtained after applying the BACON-AR framework indicates that the probabilistic estimates remained close to the ideal calibration line, following the interpretation commonly used in reliability analysis [
54]. In practical terms, this result suggests that the framework preserved the overall calibration behavior of the model while redefining the decision threshold under asymmetric costs. The Expected Calibration Error remained approximately stable, which supports the interpretation that the proposed procedure did not distort the probabilistic structure of the ensemble predictions but instead provided a cost-sensitive decision adjustment on top of the existing classifier.
After examining the calibration behavior, the next step was to analyze how the asymmetric decision criterion changes the operating point of the classifier.
Figure 13 presents the total risk function in the
BACON-AR framework. This curve allows identifying the threshold that minimizes the expected risk when false negatives and false positives are assigned different costs. In this case, the minimum of the function is reached around
, which indicates the most appropriate operating threshold in the selected asymmetric cost configuration.
In
Figure 13, the red marker denotes the minimum-risk point of the curve, and the dashed red vertical line identifies the corresponding optimal threshold. Together, these visual elements indicate the operating condition in which the
BACON-AR decision rule minimizes the expected total risk.
To provide a more detailed interpretation of the previous result, the total risk was decomposed into its two main components, namely, the contribution associated with false negatives and the contribution associated with false positives.
Figure 14 shows this decomposition and illustrates how both terms evolve as the decision threshold changes. This representation allows a clearer understanding of the trade-off induced by the asymmetric cost setting. As the threshold varies, one component decreases while the other increases, and the optimal point emerges at which the combined effect of both terms is minimal. In the figure, the red marker identifies that minimum-risk point, while the dashed red vertical line marks the threshold
at which the balance between false-negative and false-positive contributions becomes operationally preferable under the selected asymmetric cost configuration.
This decomposition reinforces the interpretation that the contribution of BACON-AR lies in selecting a cost-sensitive operating threshold under asymmetric conditions rather than changing the intrinsic predictive capacity of the underlying ensemble model.
To define the decision phase, the
BACON-AR framework incorporates a total risk function expressed as
where
and
are the costs associated with false negatives and false positives, respectively, and
is the indicator function. The objective is to identify the threshold
that minimizes the total risk:
This operating point is visually highlighted in
Figure 13 and
Figure 14 through the red marker and the dashed red vertical line.
The criterion was applied empirically to the validation data, establishing a cost relationship
, where the cost of a false negative is considered twice that of a false positive, consistent with the nature of the problem and following the approach of [
42]. The search for the minimum of the total risk function
determined an optimal value of
, which represents the equilibrium point between both types of errors in the selected asymmetric cost configuration [
17].
This result highlights the primary contribution of the BACON-AR framework. Rather than modifying the predictive capacity of the ensemble classifier, the framework provides a structured analytical mechanism to translate probabilistic predictions into operational decisions under asymmetric cost conditions. By explicitly modeling the relative impact of false negatives and false positives, the decision threshold can be adjusted to reflect the priorities of the moderation scenario.
To evaluate whether the selected asymmetric cost ratio induces unstable decision behavior, a sensitivity analysis was performed by varying the relationship between false-negative and false-positive costs over the set , using the same balanced subset of 510,252 records.
Because
BACON-AR operates as a post hoc decision layer, modifying this ratio does not retrain the underlying ensemble model; instead, it changes the operating threshold selected under the asymmetric decision criterion.
Table 12, summarizes the resulting operating characteristics.
We include
Table 13 to document how the BACON-AR operating point changes when the CFN/CFP ratio is varied under asymmetric cost conditions. Its purpose is not to demonstrate an improvement in the predictive performance of the classifier but to support the interpretation that the selected threshold
= 0.43 follows from a sensitivity analysis of the decision rule and reflects the trade-off between false negatives and false positives in the adopted cost configuration.
Within the sensitivity analysis reported in
Table 13, the selected configuration
yielded an optimal threshold of approximately
. At this operating point, the threshold-dependent operating characteristics were
,
, precision
, recall
, and
. These values characterize the trade-off induced by the asymmetric decision rule. They should be interpreted as operating-point sensitivity results under a specific cost configuration, rather than as direct replacements for the ensemble-level metrics summarized earlier in
Table 12.
As the relative cost assigned to false negatives increases, the optimal threshold decreases monotonically from 0.50 to 0.40. This shift reduces the number of false negatives from 7743 to 2662, at the expense of an increase in false positives from 10,226 to 18,584. In this sense,
Table 13 should be interpreted as a sensitivity analysis of the operating point rather than as a second summary of the predictive performance of the ensemble classifier.
Additional bootstrap resampling confirmed the stability of this behavior, with low dispersion in threshold, recall, and F1-score across the evaluated ratios. For the selected configuration , the optimal threshold remained close to 0.43 in both repeated-run analysis () and bootstrap estimation (), supporting its use as a balanced operating choice rather than as an arbitrarily fixed setting.
Using the same balanced subset of 510,252 records, the ensemble model maintained an AUC of 0.883 under the BACON-AR framework. These results indicate that BACON-AR can be used to select an operating threshold that is consistent with the selected asymmetric cost assumptions while preserving the predictive metrics of the underlying ensemble.
The statistical stability analysis of the BACON-AR framework showed consistent behavior in calibration and risk metrics. After five independent repetitions, the framework achieved an average ECE of , a minimum risk of , and a stable optimal threshold of , confirming reproducibility under small data perturbations.
Figure 15 summarizes the repeated-run stability analysis across five independent repetitions. In each subplot, the solid line represents the mean trajectory of the evaluated metric across runs, while the shaded band represents the variability associated with the corresponding standard deviation. The three panels show the behavior of the Expected Calibration Error, the minimum total risk, and the optimal threshold, respectively.
These results indicate that the BACON-AR framework maintained stable calibration and decision behavior under small variations in the validation data, which is desirable in operational moderation systems where decision policies must remain consistent across changing samples.