## 2 Materials and Methods  
Since the SMOTE method is based on the k-nearest neighbor algorithm, distance calculation between two instances is the most important aspect of generating synthetic samples. In the feature space, deriving the distance between continuous variables is straightforward; however, for categorical variables, calculating the distance between two labels can be complex. In SMOTE-NC, if a label of a categorical attribute differs between an instance and its nearest neighbors, then a fixed-value, i.e., median of standard deviations of continuous features, is added in the distance calculation. Hence, in this method, for a multi-label categorical feature, the distance between any two labels is the same. Now, let us consider a dataset where the target is to identify a potential buyer of a life insurance plan. Suppose the dataset has a nominal feature, marital status, with three labels--single, married and divorced--and the following is the percentage distribution of people who bought life insurance plan: single \(\rightarrow\) 18%, divorced \(\rightarrow\) 22% and married \(\rightarrow\) 60%. In SMOTE-NC, the distance between married-divorced and divorced-single is considered to be the same. However, based on the data, it seems people who are divorced or single are less interested in buying life insurance than married people. So, considering the similar affinity towards the target, single and divorced labels should be closer to each other than to the married label; i.e., the distance between married-divorced should be more than that between single-divorced. In SMOTE-ENC, labels of a categorical variable are represented by their affinity of association with the minority class target. We explain our algorithm (Algorithm 1) using a sample training dataset (Table 1) with three continuous features (C1, C2, C3) and a categorical feature (N). The dataset is imbalanced where we have 2 instances of minority class labelled as \(min\) and 3 instances of majority class labelled as \(maj\). ```
Input: t = number of minority class samples in training set: n% = amount of oversampling; k = number of nearest neighbors to be considered, s = total number of instances in training set, c = number of continous variables in the dataset, m = median of standard deviation of continuous features when c > 0
```  
```
ir = t/s for each categorical feature, do for each \"l\" in distinct labels, do  e = total number of \"l\" labeled instances in training set  e\({}^{\prime}=e*ir\);  o = number of \"l\" labeled minority class instances in training set \(\chi=\frac{(\alpha-e)}{e^{\prime}}\); if c > 0,  l = \(\chi^{*}\) m; else,  l = \(\chi\);  end end  Apply SMOTE (t, n, k)  For the synthetic data points, the categorical attribute's value is decided as the value in the majority of its nearest neighbors. Inverse-encode categorical values to their original labels. ```  
**Algorithm 1**SMOTE-ENC algorithm  
In SMOTE-NC, the distance between i1-i2 is calculated as follows:  
The standard deviations of the three continuous features (C1, C2, C3) associated with minority class \(min\), are 70.71, 31.82 and 21.92 respectively, and the median m, of these numbers is 31.82. The distance between the two instances i1 and i2 are calculated as:  
\[\text{Distance}_{\text{SMOTE-NC}}\ (\text{i2 - ii})\ =\ \sqrt{(100-200)^{2}+(20-65)^{2}+(85-54)^{2}+(31.82)^{2}}=118.31\]  
In our algorithm (SMOTE-ENC), we do the encoding of nominal labels as follows (alphabetical notations are same as Algorithm 1):  
\[\text{Imbalance ratio (ir) = 2/5 = 0.4.}\]  
\[\text{Total 'a' label in our training dataset (e) = 2.}\]  
\[\text{Total 'a' label associated with minority class (}min\ \text{o}=1.\]  
\[\text{If 'a' label had equal affinity towards }min\ \text{and}\ \text{}maj\ \text{class}\], then the total number of 'a' labeled instances in minority samples would be e\({}^{\prime}=e*ir\) = 2 \(\times\) 0.4 = 0.8.