# A Study on the Calibrated Confidence of Text Classification Using a Variational Bayes
## 3 Proposed Method  
When the target label is \(c_{m}\), \(K_{L}\) random numbers are generated from \(w\) conditioned on \(w:\ w\sim N_{J}(\mu,\ \Sigma)\). At this time, when the decoding condition for the \(k\)-th random number is \(c_{m}\), the generated data are \(X_{Dec}^{K_{L}}=\{x_{k}\}_{k=1}^{K_{L}}\ (k=1,\ 2,\ \dots,\ K_{L})\). Therefore, it holds that \(y_{Dec}^{K_{L}}=\{c_{m}\}_{k=1}^{K_{L}}\). The result of concatenating the raw data \(X\) and \(X_{Dec}^{K_{L}}\) in the row dimension is \(X_{Gen}^{K_{L}}=\{x_{l}\}_{l=1}^{N+K_{L}}\). Then, \(y_{Gen}^{K_{L}}\) is a concatenated vector of \(y\) and \(y_{Dec}^{K_{L}}\). This study aims to measure the change in the calibrated confidence according to \(K_{L}\). Equation (2) is an operation for finding \(K_{L}\):  
\[K_{L}=\left\lceil\ L\times N_{-c_{m}}-N_{c_{m}}\ \right\rceil \tag{2}\]  
\(N_{c_{m}}\) and \(N_{-c_{m}}\) denote the number of observations in category \(c_{m}\) and those not in category \(c_{m}\), respectively. When the \(K_{L}\) values obtained using Equation (2) and the raw data are merged, \(N_{c_{m}}\) is \(L\) times \(N_{-c_{m}}\ (K_{L}\in\mathbb{N})\). Let \(f(X,\ y)\) trained on \(X\) and \(y\) be classifier \(f_{X}\). Assuming that the predicted value of the test data is \(f_{X}(X_{test})\), the confidence of the observation with the label \(c_{m}\) is as follows:  
\[\mathcal{L}_{c_{m}}(X_{test};X)=-\log f_{X}(X_{test}|y=c_{m}) \tag{3}\]  
In Equation (3), \(\mathcal{L}_{c_{m}}(X_{test};X)\) and \(f_{X}(X_{test}|y=c_{m})\) are the negative log-likelihood of the test data and predicted values for data with label \(c_{m}\), respectively. In this paper, we propose a VB-based method to improve the calibrated confidence in text classification. Figure 1 shows the architecture of the proposed methodology. First, the proposed method extracts quantitative indicators, text, and labels from the collected documents. Quantitative indicators refer to information, not text, in documents. A label is a category that represents the document, such as the sentiment or subject of the text. The proposed method scales quantitative indicators for effective convergence of VBs. The function that converts the sample space of the input data \(x\) is as follows:  
\[\frac{x-Min(x)}{Max(x)-Min(x)} \tag{4}\]  
In Equation (4), _Max_ and _Min_ are the maximum and minimum values of the data, respectively. Therefore, the space of the input data is normalized to between 0 and 1. Next, for the progress of the proposed method, labels are one-hot encoded. The one-hot encoding of target variable \(y\), which is category \(m\), is as follows:  
\[c_{m}= \begin{cases}1,\ m-th\ element\\ \\ 0,\ otherwise\end{cases}  \tag{5}\]  
In Equation (5), \(c_{m}\) means standard base. If the number of categories is \(M\), \(c_{m}\) denotes a vector with a 1 as the \(m\)-th element and 0 elsewhere. Text is embedded in \(p_{2}\) dimensions through a large-scale, pre-trained language model. This model transforms the document into a vector in real space that reflects the context. The \(p_{2}\)-dimensional space has the advantage of obtaining the distance or correlation between document vectors; these variables are used as inputs to the VB-based generative model. The output is a quantitative indicator and embedding vector reflects the features of a specific label. In Figure 1, the encoder encodes (\(p_{1}+p_{2}+m\))-dimensional input data into a \(J\)-dimensional vector. At this time, \(J\) is smaller than (\(p_{1}+p_{2}+m\)) because the latent space of the data needs to be extracted. Figure A1a is the encoder architecture of the VB-based generative model. The purpose of a generative model is to generate similar data to the  
Figure 1: Architecture of the proposed methodology. training data. Therefore, the encoder multiplies the deviation (\(\sigma\)) of the encoded input data by the noise (\(\epsilon\)) and uses the added value with the mean (\(\mu\)) as a latent vector. Then, the input data of the decoder are a latent vector and one-hot encoded label.