Over Sampling
Over Sampling
Abstract—Breast cancer is among the most deadly diseases, dis- breast cancer diagnosis consists of a visual analysis performed
tressing mostly women worldwide. Although traditional methods by professionals aiming to identify possible abnormalities
for detection have presented themselves as valid for the task, they (e.g., nodules), which may indicate cancer risk signs. Once
still commonly present low accuracies and demand considerable
time and effort from professionals. Therefore, a computer-aided identified, it is possible to extract relevant measures from such
diagnosis (CAD) system capable of providing early detection nodules, assisting physicians to judge the presence or absence
becomes hugely desirable. In the last decade, machine learning- of cancerous tissue.
based techniques have been of paramount importance in this Many image processing-based algorithms have also been
context, since they are capable of extracting essential information proposed to help in such tasks [5]–[7], as well as machine
from data and reasoning about it. However, such approaches
still suffer from imbalanced data, specifically on medical issues, learning techniques, which have been commonly employed for
where the number of healthy people samples is, in general, both nodule segmentation and classification. Agarap [8], for
considerably higher than the number of patients. Therefore instance, studied the performance of several machine learning
this paper proposes the O2 PF, a data oversampling method techniques to label a nodule as benign or malignant. Further,
based on the unsupervised Optimum-Path Forest Algorithm. Passos et al. [9] developed a neural network to tell benign
Experiments conducted over the full oversampling scenario
state the robustness of the model, which is compared against from malignant nodules, and to label the latter according to
three well-established oversampling methods considering three the most likely cancer type.
breast cancer and three general-purpose tasks for medical issues Moreover, once the nodules can be seen as abnormalities,
datasets. their identification can also be tackled in an unsupervised
Index Terms—Data imbalance, Oversampling, Optimum-Path fashion. In such a direction, Ribeiro et al. [10] used the unsu-
Forest.
pervised Optimum-Path Forest (OPF) [11] algorithm to distinct
malignant nodes from benign, obtaining significant results.
I. I NTRODUCTION
The unsupervised Optimum-Path Forest algorithm possesses
Computer-Aided Diagnosis (CAD) systems aim at helping properties commonly employed to improve other machine
physicians to quickly report better diagnosis to patients, thus learning techniques, such as the Brainstorm Optimization [12],
representing an essential step towards dangerous disease accu- as well as to create new techniques, such as the OPF-based
rate diagnosis. Besides, intelligent-based CAD systems have approach for anomaly detection [13] and the Fuzzy OPF
successfully employed machine learning techniques, a promis- classifier [14].
ing subfield of artificial intelligence, to tackle complicated Although the above-mentioned techniques obtained promis-
problems that demand knowledge and reasoning about the ing results in the context of breast cancer detection, most
subject. Regarding the latter, several works were developed of the classification algorithms usually suffer from imbal-
in the last few years to aid detecting atherosclerosis [1], anced dataset problems, which arises when the number of
Parkinson’s disease [2], and breast cancer [3], to name a few. samples among classes differs significantly. In this scenario,
Breast cancer is a dangerous illness, affecting millions of the trained classifier is more likely to label a new sample as
women, as well as few men, around the world. According to belonging to the most common (majority) class, degrading
the World Health Organization, such a disease was responsible its performance for the smallest (minority) class. Moreover,
for the death of approximately 627, 000 women in 2018 such a situation may degenerate when the dataset presents
worldwide [4]. Therefore, early diagnosis is crucial to effec- outliers. Numerous studies have also been proposed to cope
tively prevent its progress, consequently making it possible to with such a problem in medical datasets [15]–[17]. Therefore,
elaborate more efficient treatment plans. In general, standard the generation of synthetic samples for the minority class,
which is usually referred to as oversampling, is recognized as a
∗ Authorscontributed equally. prominent contribution to rebalancing the dataset for classifier
The authors would like to thank FAPESP grants #2013/07375-0,
#2014/12236-1, #2019/18287-0, and #2019/07665-4, as well as CNPq grants training purposes, consequently improving their robustness to
#427968/2018-6 and #307066/2017-7. label minority class samples correctly. In this context, several
powerful oversampling strategies have been proposed in the by minimizing the normalized graph cut function, as it takes
literature to tackle such a problem [18]–[20], most of them into account the dissimilarities between clusters as well as the
still presenting difficulties while enforcing diversity among similarity degree among samples of each cluster.
new synthetic samples, which denotes a problem that worth Concerning the second step, the algorithm must select the
to be addressed, since it can improve classifier generalization prototypes to form the root of each OPT (which will ultimately
properties. form clusters) to rule the competition process and conquer
To such an extent, this work proposes an approach to per- the remaining samples in the graph. The supervised OPF
form oversampling via the Optimum-Path Forest, hereinafter proposed by Papa et al. [21], [22] selects as prototypes the
named O2 PF. The method employs the unsupervised OPF nearest samples from different classes, found by computing
algorithm to capture features intrinsic to the minority class into the graph Minimum Spanning Tree (MST). However, in the
different clusters. Further, new training examples are generated unsupervised variant, since labels are usually unavailable,
by sampling from a Gaussian distribution parametrized by Rocha et al. [11] proposed to select the prototypes as the
the cluster characteristics. Therefore, the main contribution samples located in the center of each cluster. To such an extent,
of this paper are twofold: (i) extending the OPF algorithm all samples are assigned a density score ρ(xi ), ∀xi ∈ D,
capabilities by introducing a novel oversampling mechanism computed through a Gaussian probability density function
that enforces synthetic intra-class variability; and (ii) studying (pdf), defined as follows:
how O2 PF can benefit the development of CAD systems
by extensively evaluating it on five tumor-classification and 1 X
−d(xi , xj )
one retinopathy identification tasks. Finally, the full-balanced ρ(xi ) = √ exp , (1)
k 2πσ 2
? 2σ 2
datasets are employed to train the OPF classifier, and results, ∀xj ∈Ak? (xi )
i.e., the accuracy, recall, and F1-measure, are compared against
where i 6= j, σ = dmax /3 and dmax stands for the maximum
the ones obtained by the standard training dataset without
arc-weight in G. This formulation considers all adjacent nodes
oversampling. Additionally, results are compared against three
for density computations, as the Gaussian distribution covers
baselines: SMOTE [18], the Borderline SMOTE [19], and
99.7% of the samples with distance d(xi , xj ) ∈ [0, 3σ].
ADASYN [20].
After evaluating Equation 1 for each node in the graph, the
In the remainder of this paper, Section II presents the theo-
density values are used to populate a priority queue in a way
retical background regarding the unsupervised and supervised
that the unsupervised OPF maximizes the cost of each sample,
OPF algorithm variants, whereas Section III introduces the
thus partitioning the graph into OPTs. Such a cost is defined in
proposed approach. Further, Section IV outlines the experi-
terms of paths on G, which is an acyclic sequence of adjacent
mental setup and Section V discusses experimental results.
samples in Ak? .
Finally, Section VI presents conclusions and future works.
Let πxi be a path with terminus at sample xi and starting
II. BACKGROUND from some root R(xj ), being the latter the set of all prototype
This section presents the theoretical background regarding samples. Further, let πxi = hxi i be a trivial path (i.e., a path
the unsupervised and supervised variants of the OPF algo- containing only one sample), whereas πxi · hxi , xj i denotes
rithm. the concatenation of a path πxi and the arc (xi , xj ) such that
i 6= j.
A. Unsupervised Optimum-Path Forest In the third step, the algorithm assigns to each path πxi
Let D = {x1 , x2 , . . . , xn } be a dataset such that xi ∈ Rm a value fmin (πxi ) given by a smooth connectivity function
represents the features extracted from the i-th sample. Further, fmin : D → R+ , which must satisfy some constraints to
let G = (D, Ak? ) be a graph where each node corresponds to a ensure the algorithm theoretic correctness [23], [24]. A path
different feature vector connected to its k ? -nearest neighbors, πxi is considered optimal if fmin (πxi ) ≥ fmin (τxi ) for any
as defined in the adjacency relationship set Ak? . other path τxi . Among the proposed path-cost functions in
The unsupervised OPF algorithm consists in partitioning the the literature, the unsupervised OPF relies on the following
graph through a competitive process, in which a few samples formulation:
are marked as “prototypes” and compete among themselves
to conquer the remaining nodes. Such a procedure partitions ρ(xi ) if xi ∈ R
the G into optimum-path trees (OPTs) rooted at a prototype, fmin (hxi i) = (2)
ρ(xi ) − δ otherwise.
each corresponding to a cluster, where a sample is more fmin (πxi · hxi , xj i) = min{fmin (πxi ), ρ(xj )},
similar to the elements of its tree than any other tree. Overall,
the process can be divided into three steps: (i) computing a where δ = min∀(xi ,xj )∈Ak? |ρ(t)6=ρ(s) |ρ(t) − ρ(s)| consists in
proper neighborhood size k ? and the adjacency relationship the smallest quantity to avoid plateaus and over-segmentation
Ak? , (ii) electing the prototype nodes, and (iii) performing in regions near prototypes (i.e., areas with the highest density).
the competition process to partition the dataset into OPTs. Among all possible paths πxi that originate in some local
Regarding the first step, different approaches may be con- maximum, i.e., some prototype, the OPF algorithm assigns to
sidered. Among others, Rocha et al. [11] proposed to find k ? each sample a final path whose minimum density value along
it is maximum. Such final path value is represented by a cost making the classifier biased towards a subset of characteristics
map C, as follows: present in that class. To tackle such issues, the O2 PF first
performs the clustering from minority class samples, which
C(xi ) = max {f (πxj · hxj , xi i)}. (3) turns possible the extraction of common patterns intrinsic to
∀πxj ∈D, i6=j
the class, i.e., the samples’ average position and variance.
The OPF algorithm maximizes C(xi ) ∀xi ∈ D by com- Further, the algorithm assumes that all features from a class
puting an optimum-path forest for each sample in descending follow a normal distribution. Thus, a new sample z ∈ Rm can
order of cost. Each forest is encoded as an acyclic predecessor be generated by sampling such a distribution from some of
map P which assigns to each sample xi ∈ / R its predecessor the q clusters found. Notice the number of synthetic samples
P(xi ) in the optimum path from R, or a marker nil when generated by each cluster is proportional to the number of
xi ∈ R. original samples compounding it, i.e., we are always doubling
It is important to remark that the unsupervised OPF algo- the number of samples from the minority class, although the
rithm determines the number of clusters (OPTs) automatically, user can set that percentage. The distribution is performed as
hence such information is not required beforehand, differently follows:
from other algorithms. Furthermore, the only hyperparameter
that must be set is the search interval upper bound kmax for z ∼ N (µq , Σq ), (6)
the proper neighborhood size k ? ∈ [1, kmax ].
where µq ∈ Rm stands for the distribution mean, defined
B. Supervised Optimum-Path Forest as the average feature vector from all samples within the q-
Differently from its unsupervised version, the supervised th cluster. Moreover, Σq ∈ Rm×m is the covariance matrix,
variant uses a fully-connected graph G 0 = (D, B) instead. computed as follows:
Moreover, the closest samples from different classes are 1
marked as prototypes, as aforementioned. Regarding the com- Σq = (Xq − µq )(Xq − µq )T , (7)
nq − 1
petition process, instead of using Equation 2, the following
smooth function is employed: given that Xq ∈ Rm×nq is a matrix formed by concatenating
all nq cluster feature vectors. Figure 1 illustrates the proposed
0 if xi ∈ R approach behavior.
fmax (hxi i) = (4)
∞ otherwise.
fmax (πxi · hxi , xj i) = max {fmax (πxi ), d(xi , xj )} . Benign
Malignant
O2PF
Further, the following cost map is used to partition the
graph:
2
datasets. The proposed approach is compared against three Recall 0.5834 ± 0.2308 0.6287 ± 0.1505 0.5791 ± 0.1811 0.6237 ± 0.1560
Accuracy 0.9388 ± 0.0212 0.9403 ± 0.0157 0.9403 ± 0.0165 0.9415 ± 0.0138
baseline techniques, i.e., SMOTE, Borderline SMOTE, and CC
F1 0.5330 ± 0.1548 0.5673 ± 0.0900 0.5414 ± 0.1109 0.5675 ± 0.0905
ADASYN. Best k 13.2500 ± 10.8714 6.5500 ± 1.4654 6.5500 ± 1.7168 6.0000 ± 1.5166
Diagnostic II
Accuracy 0.9490 ± 0.0176 0.9476 ± 0.0192 0.9419 ± 0.0217 0.9490 ± 0.0191 task since no technique reached a 0.7 recall. Unusual behavior
F1 0.9195 ± 0.0294 0.9170 ± 0.0331 0.9080 ± 0.0353 0.9196 ± 0.0315
is observed over the Cervical Cancer dataset, whose all tech-
Best k 23.5000 ± 29.6268 6.4500 ± 1.4992 5.4000 ± 0.8602 6.8500 ± 1.5580
niques obtained an approximate accuracy of 94%, despite the
recall below 0.63. Such behavior may suggest samples from
Results observed over WBCD Prognostic dataset show all the minority class are distributed among a subcluster from
techniques obtained similar statistical results considering the majority class, therefore providing high accuracy despite the
recall. Regarding the accuracy, one can observe the proposed low recall.
approach obtained the highest average value, together with the
borderline SMOTE. Such a result suggests samples generated D. O2 PF Hyperparameter Selection
by O2 PF fit better the class distribution, being less prone O2 PF requires a proper selection of a single hyperparameter,
to false negatives. A similar behavior is observed over the the kmax , which is employed in the clustering process. Such a
Diagnostic I dataset. Concerning the Diagnostic II dataset, hyperparameter, however, is way less sensitive when compared
the proposed approach obtained the best results, together with to a proper selection of the best k, performed by the other
ADASYN and SMOTE, outperforming Borderline SMOTE. techniques. Figure 3 depicts a grid search considering a proper
Considering the accuracy, O2 PF obtained the highest averages. selection of those hyperparameters for each technique. Notice
Despite the good performance achieved by the oversampling the central line describes the average value over the valida-
approach using O2 PF, the baseline algorithms have shown tion dataset, while the broader area describes the standard
statistical similarity in most of the cases. Sparse clusters with deviation. Notice even though O2 PF considers a very wider
low density may be responsible for introducing new samples interval, i.e., ranging from [5, 100], most of the time, the results
that are distant from the original distribution of the minority outperform the other techniques, which assume a shorter
class, a situation that would be likely to produce outliers in interval between [5, 10].
the new resample dataset. Such behavior may also influence
in a moderate recall, as observed in Tables II. VI. C ONCLUSION
This paper presented an oversampling approach based on
C. General Purpose Medical Datasets Results the unsupervised Optimum-Path Forest Algorithm. The pro-
Table III presents the results obtained over the three general posed O2 PF showed to be capable of handling the class
purpose medical datasets, i.e., Diabetic Retinopathy Debrecen, imbalance problem through a simple and effective procedure
Cervical Cancer and Mammographic Mass. that generates new synthetic samples based on the normal
Considering Diabetic Retinopathy Debrecen, the proposed distribution of the feature vectors inside each cluster. The
approach outperformed the average recall overall techniques, experiments performed in three datasets of breast cancer, apart
although SMOTE and Borderline SMOTE achieved similar from three complementary medical issue datasets, showed that
results. Similar behavior is observed over the F1 metric. On the O2 PF approach demonstrated similar or superior results
the other hand, O2 PF, SMOTE and ADASYN obtained the when compared to the baseline methods already proposed in
best results regarding the Cervical Cancer dataset. Since both the literature.
Borderline SMOTE and ADASYN are variants of SMOTE, Notwithstanding, the effectiveness of the proposed approach
they are expected to perform differently over different sce- may still suffer in synthesizing new samples based on low-
narios. However, as observed in most of the experiments, density clusters, a situation that may introduce noise samples
they generally are outperformed by SMOTE technique itself, in the training set and, consequently, affect creating of the
5 6 7 8 9 10 5 6 7 8 9 10 [10] P. B. Ribeiro, L. A. Passos, L. A. da Silva, K. A. da Costa, J. P. Papa,
0.70
0.96 and R. A. Romero, “Unsupervised breast masses classification through
0.95 optimum-path forest,” in 2015 IEEE 28th International Symposium on
0.65
0.94
Computer-Based Medical Systems. IEEE, 2015, pp. 238–243.
Accuracy
Accuracy
0.60
0.93
0.55
0.92
[11] L. M. Rocha, F. A. M. Cappabianco, and A. X. Falcão, “Data clustering
0.50 O2PF as an optimum-path forest problem with applications in image analysis,”
SMOTE 0.91
0.45 BorderlineSMOTE 0.90 International Journal of Imaging Systems and Technology, vol. 19, no. 2,
ADASYN
0.40
20 40 60 80 100 20 40 60 80 100
pp. 50–68, 2009.
kmax kmax [12] L. C. S. Afonso, L. A. Passos, and J. P. Papa, “Enhancing brain
storm optimization through optimum-path forest,” in 2018 IEEE 12th
(a) (b) International Symposium on Applied Computational Intelligence and
5 6 7 8 9 10 Informatics (SACI). IEEE, 2018, pp. 000 183–000 188.
0.98 [13] R. R. Guimarães, L. A. Passos, R. Holanda Filho, V. H. C. de Albu-
0.97 querque, J. J. Rodrigues, M. M. Komarov, and J. P. Papa, “Intelligent
Accuracy