# Dynamic Nearest Neighbor: An Improved Machine Learning Classifier and Its Application in Finances
## 4 Results
### Datasets  
The eight datasets described in this subsection contain patterns taken from real-world activities, whose attributes are closely related to personal finance. All datasets, without exception, have two classes and all but Iranian credit are available in the machine learning repository of the University of California at Irvine [27]. The Iranian credit dataset was shared by the authors of the corresponding research [28]. Due to the restriction of the compared classifiers, the datasets were preprocessed, transforming all data to numerical data and using missing values imputation, in order to be able to apply state-of-the-art algorithms and compare those results with those obtained by the D1-NN in the same datasets. In addition, an algorithm was applied to eliminate the imbalance of the classes in all the datasets and thus be able to use accuracy as a performance measure. The imbalance ratio (\(IR\)) is an index that measures the degree of imbalance. It is defined as [29]:  
\[IR=\frac{|majority\_class|}{|minority\_class|} \tag{1}\]  
where \(|majority\_class|\) represents the cardinality of the majority class in the dataset, while \(|minority\_class|\) represents the cardinality of the minority class. A dataset is considered balanced, if its \(IR\) value is close to or less than 1.5 (note that the \(IR\) value is always greater than 1). To illustrate the concept of the \(IR\) index, the Qualitative Bankruptcy Dataset [30] will be taken as an example, which has 250 patterns included into two classes. The majority class contains 143 patterns while in the minority class there are 107 patterns. \[IR=\frac{143}{107}=1.33 \tag{2}\]  
Thus, the Qualitative Bankruptcy Dataset is a balanced dataset. In order to address the categorical and missing data, a transformation filter provided by the well-known WEKA (Waikato Environment for Knowledge Analysis) platform was applied [31]. After applying these filters, there are datasets with only numeric components and no missing values. In the case of datasets with \(IR>1.5\), it was decided to apply the SMOTE (Synthetic Minority Over-sampling Technique) to compensate for the class imbalance [32]. By reducing class imbalance, it is now possible to apply accuracy as a performance measure. After applying a pattern classifier to a dataset, it is necessary to calculate the performance, in order to know the benefits of this classifier with respect to the other algorithms of the state of the art. The accuracy performance measure is useful to be applied in balanced datasets, and is defined as [33]:  
\[Accuracy=\frac{Number\ of\ hits}{Total\ tested\ patterns} \tag{3}\]  
The following briefly describes the datasets in alphabetical order:  
**Australian credit approval**  
This dataset [34] contains data for people applying for credit cards. The two classes refer to the acceptance or rejection of each of the 690 applications. There are 14 attributes that each pattern contains. There are attributes of type continuous, nominal and missing values. Although the \(IR\) value indicates that there is no imbalance (1.24), the complexity of data at the attribute level that this dataset represents is a good challenge for classifiers. **Bank**  
A Portuguese banking institution ordered direct marketing campaigns which were based on phone calls [35]. Through a questionnaire structured in 16 items applied to 4521 people, it is intended to predict if a potential client will subscribe to a term deposit. The two classes are Yes/No. The dataset patterns contain mixed traits, that is, both numeric and categorical attributes, with no missing values. The \(IR\) index is 7.67, which indicates that the dataset is severely unbalanced. **Bank additional**  
This is an additional dataset to the Bank dataset. It also emerged from a marketing campaign which was also based on phone calls. The marketing campaign was carried out by a Portuguese banking institution, through a questionnaire structured in 20 items applied to 4119 people.