## 2 Materials and Methods
\[\text{Encoding of 'a' for all target }min=\frac{(\alpha-e)}{e^{\prime}}+m\ =\ \frac{(1-0.8)}{0.8}\ \times\ 31.82=7.95.\]  
\[\text{Total 'b' label in our training dataset (e) = 3.}\]  
\[\text{Total 'b' label associated with minority class (}min\ \text{o}=1.\] \begin{table}
\begin{tabular}{c c c c c} \hline  & **C1** & **C2** & **C3** & **N** & **Target** \\ \hline Instance 1 (i1) & 100 & 20 & 85 & a & \(min\) \\ \hline Instance 2 (i2) & 200 & 65 & 54 & b & \(min\) \\ \hline Instance 3 (i3) & 166 & 24 & 38 & a & \(maj\) \\ \hline Instance 4 (i4) & 344 & 67 & 89 & b & \(maj\) \\ \hline Instance 5 (i5) & 200 & 30 & 75 & b & \(maj\) \\ \hline \end{tabular}
\end{table} 
Table 1: Sample dataset to explain our algorithm (SMOTE-ENC). If 'b' label had equal affinity towards _min_ and _maj_ class, then total number of 'b' labeled instances in minority samples would be e\(\prime~{}=\) e * i r = 3 \(\times\) 0.4 = 1.2. Encoding of 'b' for all target \(min=\frac{\left(\text{o}-\text{e}\prime\right)}{\text{e}\prime}*m~{}=\frac{ \left(1-1.2\right)}{1.2}~{}\times~{}31.82=-5.30\). \[ \begin{array}{l}\text{Distance SMOTE-ENC }\left(\text{12}-\text{11}\right)\\ =~{}\sqrt{\left(100-200\right)^{2}+\left(20-65\right)^{2}+\left(85-54\right)^ {2}+\left(7.95+5.30\right)^{2}}=114.72\end{array} \]  
We can see that the distance between two data rows in our sample dataset is reduced when calculated by SMOTE-ENC. Hence, it can be said that, in SMOTE-NC, inter and intra level distance of categorical levels are always the same; whereas in SMOTE-ENC, nominal features are encoded as numeric values and the difference between two such numeric value reflects the amount of change of association with minority classes and hence seems to produce better result than SMOTE-NC. By applying this algorithm on the nominal features, we can encode each label as a numeric value where a higher value of a label indicates stronger association with a minority class. This encoding is inspired by [PERSON]'s chi-squared test [25], which can confirm if two categorical variables are related. However, in this method, our objective is not to determine if the nominal features of the samples are related to the target, but rather to quantify the distance between two data points when the label of a categorical variable is changed. Hence, we do not use the chi-squared test, i.e., \(\chi 2\), but rather use chi (\(\chi\)) for each label of a nominal feature to measure the amount of association of that label with the minority class target. The magnitude of \(\chi\) (i.e., chi) is a fraction and when included in the distance calculation between two samples can become insignificant as the difference between two values of a continuous feature is often significantly higher. For this reason, if the dataset has continuous features, \(\chi\) is multiplied by the median of the standard deviation of the continuous variable to make the value comparable to other continuous attributes. However, if the dataset has only nominal features, chi (\(\chi\)) is directly used in distance calculation. We compared our proposed method, SMOTE-ENC, with SMOTE-NC on five different datasets. These datasets have diverse minority to majority ratio, which offers a broad range for testing this algorithm's efficiency. Among these datasets, forest cover data had 7 classes. We evaluated our model on a pair of classes of the original dataset and discarded the rest of the instances. The metrics used in our study to evaluate the models' performance were precision, recall, F-beta score, area under precision recall curve and area under ROC curve. Accuracy was not used as an evaluation metric in this paper, as accuracy is not able to capture model performance for a highly imbalanced dataset. F-beta score is the weighted average of precision (ratio of correctly predicted positive observations to the total predicted positive observations) and recall (ratio correctly predicted positive observations to the total positive observations).