<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Leveraging Formal Concept Analysis to Improve n-fold validation in Multilabel Classification</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Francisco J. Valverde-Albacete</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Carmen Pela´ez-Moreno</string-name>
          <email>carmen@tsc.uc3m.es</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Depto. Teor ́ıa de Sen ̃al y Comunicaciones, Univ. Carlos III de Madrid</institution>
          ,
          <addr-line>Madrid</addr-line>
          ,
          <country country="ES">Spain</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>In this application note we revisit previous work on the exploratory analysis of Multilabel Classification (MLC) tasks in Machine Learning. We combine Information Theory and Formal Concept Analysis (FCA) to formalize the intuition that inference of classifiers in MLC tasks can only proceed when the training and testing data concerning the labels define the same Concept Lattice. We instantiate our procedure on the emotions dataset, but the procedure is independent of the dataset being explored. An R language interactive notebook carrying out the procedure is available upon request.</p>
      </abstract>
      <kwd-group>
        <kwd>Multilabel Classification</kwd>
        <kwd>Entropy-based assessment</kwd>
        <kwd>Data preprocessing</kwd>
        <kwd>n-fold validation</kwd>
        <kwd>Formal Context Analysis</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>1.1</p>
      <p>Y</p>
      <p>PY</p>
      <p>PX
observe
transform</p>
      <p>PZ
classify</p>
      <p>PYb
ˆ
Y</p>
      <p>
        The following way of solving the problem is based on the theory of Statistical
Learning [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]: consider a binary multivariate source Y , emitting binary label vectors or
labelsets from a label space Y ≡ 2mY , by virtue of the isomorphism between sets and
their characteristic vectors1. Suppose that the labelsets are hidden and we can only
access the result of an observation mechanism of the labelsets in terms of visible instance
or observation in a feature space X ≡ RmX . The multi-label classification problem is
to tag any (feature) vector ⃗x ∈ X , with a labelset ⃗y ∈ Y [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ].
      </p>
      <p>The usual way to solve the problem in the simpler, supervised setting is:
1. Model the source of labelsets as random label vectors Y ∼ PY and their
observations as the feature vectors X ∼ PX over their respective spaces.
2. Collect a (task) dataset with s samples, D = {(⃗xi, ⃗yi)}js=1 of labelsets and their
observed features to induce a classifier from observations to labelsets h : X → Y .
3. Choose the classifier type and induction scheme for it.
4. In order to assess the classifiers, choose an adequate measure of performance, and
implement (any of a number of) schemes of iterated re-sampling of the data into
sT
a set of training examples DT = {(⃗xj , ⃗yj )}j=1 and a set of test examples DE =
{(⃗xk, ⃗yk) sE</p>
      <p>
        }k=1 so that the training data are used to induce the classifiers and the
testing data to test them, and validate these results, e.g. using k-fold validation [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ].
Example 1 (emotions [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] ). A traditional dataset to test new ideas in MLC, emotions
captures mX = 72 features and the emotions they produce—as mY = 6 labels like
amazed-surprised, angry-aggressive, etc.—for a total of s = 593 song
tracks. As expected, distinct labels have distinct expressions in samples.
      </p>
      <p>
        Note that only 27 of the 26 = 64 possible labelsets occur, and as many as 4 of
them are hapaxes—they occur only once—while at least one of the labelsets appears
81 times. This wildly imbalanced behaviour is typical of MLC datasets [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ].
⊔⊓
1.2
      </p>
    </sec>
    <sec id="sec-2">
      <title>An FCA-based Interpretation of MLC</title>
      <p>Note that in the standard approach above FCA is all but absent. However, it is easy to
see that FCA and its variants are relevant in modelling this ML task.</p>
      <p>First, with the labelsets {⃗yi}is=1 of the task dataset we can build a formal context
using the set of labels L as attributes, with |L| = mY , and taking for each sample—
considered as a formal object i ∈ G with |G| = s—its labelset as a row of the incidence
matrix Ii· = ⃗yi, whence DL = (G, L, I) is the binary formal context of samples and
their labels. This context captures the information in the stochastic source Y .</p>
      <p>i s</p>
      <p>Secondly, for observation vectors {⃗x }i=1 their context DF = (G, F, R)—with F
the set of features—will not be binary, in general, but many-valued Ri· = ⃗xi. This
context captures the information in the observations X 2.</p>
      <p>With the previous modelling, relevant notions in MLC correspond to relevant
notions in FCA. For instance, labelsets are object intents, and they can be found through
the polars ⃗yi = {i}↑ . In this way, we can reason about the sampling of the stochastic
variables Y and X—the dataset—in terms of the contexts above, and vice-versa.</p>
      <p>
        For instance, each labelset present in the dataset—that is, each object-extent—may
appear with different samples (formal objects). Recall that the concept-forming function
γ induces a partition ker γ on G by equality of labelsets: (i1, i2) ∈ ker γ ⇐⇒ {i1}↑ =
{i2}↑ = ⃗yi1 . This partition is crucial for defining the entropy of the label source (see
§ 2). In the other direction, we expect the sampling to be good enough mY ≪ s so it is
2 Note that Fig. 1 suggests another context formed by the transformed observations captured by
the random vector Z, but this will not be dealt with here.
safe to suppose that no two labels are predicated of the same set of objects. Therefore
we expect the partition on labels induced by µ to be the identity ker µ = ι L, which
holds on standard testing datasets (see e.g. those in [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]).
1.3
      </p>
    </sec>
    <sec id="sec-3">
      <title>The Problem and the FCA-induced Solution</title>
      <p>
        The following problem and its theoretical solution were proposed in [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] as an example
of the above-suggested operation: The MLC classifier induction and assessment
procedures demand that we generate train and test resamplings of the original data [
        <xref ref-type="bibr" rid="ref4 ref8">8, 4</xref>
        ]. This
amounts to splitting the original context DL into two subposed subcontexts of training
DT and testing DE data: D = DT /DE . Note that
1. Since the samples are supposed to be independent and identically distributed, the
order of these contexts in the subposition—indeed the row order of I—is irrelevant.
2. The resampling of the labelset context is tied to that of the observations: we decide
on the labelset context and this carries over to the observation context.
      </p>
      <p>Since the data are a formal context we know that an important part of the
information contained in it comes from the concept lattice, hence:
Hypothesis 1. 1. (FCA intuition) A necessary condition for the resampling of the
data D into training part DT and testing part DE to be meaningful for the MLC
task, is that the concept lattices of all of these be isomorphic:</p>
      <p>B(D) ∼= B(DT ) ∼= B(DE )
2. (ML intuition) Not only the labelsets but also their ocurrence frequencies as
quantified by the cardinalities of the blocks of ker γ are important.</p>
      <p>The last consideration follows because if we only retained the meet- and
joinirreducibles to obtain these concept lattices, then the labelsets of reducible attributes
would be lost so the relative importance of the samples—both labels and observations—
would change, impacting the induction scheme of the classifiers.</p>
      <p>The above proposition suggests that the analogue of stratified sampling in MLC is
a procedure in which the stratification must proceed on a block-by-block basis with
respect to ker γ . However this comes at a price, when there are hapaxes in the data. If
we choose, for instance, to maintain 80% of the data for training and 20% for testing,
regardless of these proportions, stratified sampling will force us to include all hapaxes
with the following deleterious consequences:
– The relative frequency of the hapaxes will be distorted wrt to other labelsets.
– We will be using some data (the hapaxes) both for training and testing, which is
known to obtain too optimistic performance results in whichever measure of it.</p>
      <p>Furthermore, if we use, e.g. k-fold validation we have to repeat this procedure and
ensure that the resamplings are somehow different. A usual procedure is to distribute
the original dataset into k blocks in order to aggregate k − 1 of them into the training
dataset DT and use the leftover as the testing dataset DE . It is common to use k = 5
or k = 10. This can only compound the previous problem, therefore FCA allows us
to spot possible problems with the classifier induction and validation schemes using
resampling.</p>
      <p>In this paper we will use side-by-side FCA-based and Information Theory-based
devices to support the claim that they improve the understanding of the task when used
in synergy. For that purpose we first review an Exploratory Data Analysis (EDA)
technique in Sec. 2 to help in interpreting the experimental results in Sec. 3.
2</p>
      <sec id="sec-3-1">
        <title>Methods: Source Multivariate Entropy Triangles</title>
        <p>
          The Source Multivariate Entropy Triangle (SMET, [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ]) is a visual tool based on
Information Theory to explore the informational content of multivariate sources. It is better
suited to discrete sources—be they binary or multiclass—and optimally suited for
analyzing the set of label assignments of MLC tasks.
        </p>
        <p>
          Due to space limitations, we will only describe the graphic approach to the SMET.
We refer the reader to [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ] for its theoretical bases. In brief, the information content of a
discrete multivariate source can be depicted in the simplex of Fig. 2, where the vertices
describe extreme behaviours of the labels. If a label appears in the lowest vertex, is not
stochastic. If it appears in the right vertex, its information can be predicted from that
of the rest of the labels, whereas if it appears in the left vertex, it has a lot of private
information. The opposite sides to these vertices represent their opposite behaviours. In
general, the behaviour of labels is a mix of these three types (see Fig. 3).
        </p>
        <p>To assess the effectiveness of stratified sampling schemes for MLC, this paper
proposes to use the visualization of the information balance of a formal context of labels
DL using the SMET.
3</p>
      </sec>
      <sec id="sec-3-2">
        <title>Results: Example Data Analysis for an MLC Dataset</title>
        <p>
          SW resources. The following analysis is carried out on the Example 1 emotions
dataset [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ], as pre-processed and presented by the mldr R package [
          <xref ref-type="bibr" rid="ref6">6</xref>
          ]. The interactive
R notebook embodying the analysis is available from the authors upon request.
Basic EDA of the labels. Since we are only considering the set of labels Y , we
extracted the histogram of the labelsets {⃗yj , nj }j∈J from the dataset and considered a
set of minimal frequencies of occurrence nT ∈ {0, 1, 4, 9, 16, 25} acting as thresholds
based on it. The case nT = 0 actually represents the original dataset and Fig. 3 shows
the information balance of the six labels of emotions as well as the average
balance for them all. We see that most labels are rather random, with relaxing-calm
completely so. No label is completely specified by the rest of them, nor is any totally
independent. This in essence means that the dataset is truly multilabel.
Disposing of hapaxes to improve stratified sampling. Previous analyses of the
histogram of labelsets made us realize that this dataset is not adequate for resampling due
to hapaxes and in general low-counts of many labelsets [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ]. This applies to most MLC
datasets used at present [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ].
        </p>
        <p>To dispose of hapaxes without disposing of samples we must re-assign each to a
more frequent labelset. The rationale for this decision is because we consider hapaxes
errors in label codification, and assume that the “real” labelset is the closest non-hapax
in Hamming distance3. However, this re-assignment changes the histogram of labelsets
what results in an impoverishment of the information balance of the labels and the
dataset in general.</p>
        <p>To explore this trade-off, at each threshold nT , a labelset ⃗y was considered a
generalized hapax if ny⃗ &lt; nT . For each threshold nT we calculated the Hamming distance
between each generalized hapax ⃗ynT and the non-hapaxes, and found the set of those
closest to it. Then we re-assigned ⃗ynT to one of them uniformly at random (allowing
for repetitions) 4.
3 Recall that the Hamming distance between two sequences of bits of identical length is the
number of positions in which they differ.
4 Note that an alternative strategy would have been a scheme considering the original
frequencies in the histogram, to simulate a rich-get-richer phenomenon. But such a procedure would
decrease the source entropy more than the one we have chosen.</p>
        <p>This reassignment defined a new dataset whose information balance was
represented by the SMET, as suggested in Section 2, whence Fig. 4 ensued. What we can
see is a general tendency to the increment of the total correlation as the thresholds
increase. But this entails that the individual distinctiveness of each label is diminished.
See, for instance, the case for angry-aggressive that can actually be predicted
from the other labels when n = 25, confirming that too aggressive a threshold will
substantively change the relative information content of the labels in the dataset.
Choosing the adequate threshold. Note that a threshold of n is needed to request an
(n + 1)-fold cross-validation of any magnitude about the dataset, since all labelset will
have at least (n + 1) representatives for the stratified sampling requested by the cross
validation procedure. Is it possible to balance the identical sampling property on train
and test, yet avoid too much loss of information content?</p>
        <p>Figure 5 depicst a choice of thresholds typically used in validation—1, 4 and 9,
corresponding to 2-, 5- and 10-fold validation—for three differently behaving labels—
angry-aggressive, quiet-still and relaxing-calm—and the average of
the dataset, both for the ensembles of training and testing folds.</p>
        <p>
          – As applied to the estimation of the entropies, the (n + 1)-fold validation yields the
same result in train and test, the sought-for result.
– We can see the general drift towards increased correlation in all labels, but much
more in, say, angry-aggressive than in quiet-still.
– For this particular dataset, a threshold of nT = 4 with 5-fold validation seems to
be a good compromise for attaining statistical validity vs. dataset fidelity.
FCA confirmation. To strengthen the validity of the last two conclusions, we
calculated the number of concepts of all of the train and test label contexts using the fcaR
package [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ]. This is possible since such datasets are just binary tables. After
creating the contexts, we clarified and obtained the lists of concepts, then we compared the
cardinality of the training and test concept lattices both for the unsplit dataset—after
reassigning the generalized hapaxes, when needed—and the (n + 1)-cross validated
versions. The results are shown in Fig. 6.
        </p>
        <p>As expected, for nT = 0 the difference in number of concepts between the
nonsampled and sampled versions of the dataset make it non-adequate for appropriate
sampling5. The training and test splits had the same number of concepts for every other
threshold. For nT ∈ {1, 4, 16}, the number of concepts was constant among folds, but
due to the randomness inherent in sampling for nT ∈ {9, 25} one of the folds was
different (not shown explicitly).
4</p>
      </sec>
      <sec id="sec-3-3">
        <title>Summary and Discussion</title>
        <p>
          We have tested and strengthened a data hypothesis put forward in previous work [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ].
This hypothesis demands that the training and testing splits for solving a MLC task
have the same concept lattice associated with their multilabel contexts, and also similar
entropies in the induced partition of the sample set.
        </p>
        <p>We first explored the influence of carrying out different degrees of smoothing of the
labelset frequencies and found a balance between it and the increase in total correlation
of the labels, leading to a loss of their individual information content.</p>
        <p>We also checked that the recipe for defining an appropriate threshold n to carry out
an (n+1)-fold cross validation actually works by comparing the informational balances
of training and testing splits of the dataset as random estimates of their actual values.</p>
        <p>
          Further work should start applying this rationale to solving of the MLC task.
Preliminary work on using both FCA- and information theoretic-approaches suggest that
present-day solutions are far from satisfactory in this respect. In the future, we plan to
use more FCA-induced techniques from [
          <xref ref-type="bibr" rid="ref7">7</xref>
          ] to improve on this.
5 It is a fluke of the dataset that both the training and test subcontexts have the same number of
concepts as some of the hapaxes are singletons
        </p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <surname>Boutell</surname>
            ,
            <given-names>M.R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Luo</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Shen</surname>
            ,
            <given-names>X.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Brown</surname>
          </string-name>
          , C.M.
          <article-title>: Learning multi-label scene classification</article-title>
          .
          <source>Pattern Recognition</source>
          <volume>37</volume>
          (
          <year>2004</year>
          )
          <fpage>1757</fpage>
          -
          <lpage>1771</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <surname>Gibaja</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Ventura</surname>
            ,
            <given-names>S.:</given-names>
          </string-name>
          <article-title>A Tutorial on Multilabel Learning</article-title>
          .
          <source>ACM Computing Surveys</source>
          <volume>47</volume>
          (
          <year>2015</year>
          )
          <fpage>1</fpage>
          -
          <lpage>38</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <surname>Herrera</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Charte</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rivera</surname>
            ,
            <given-names>A.J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>del Jesus</surname>
            ,
            <given-names>M.J.: Multilabel</given-names>
          </string-name>
          <string-name>
            <surname>Classification. Problem Analysis</surname>
          </string-name>
          ,
          <source>Metrics and Techniques</source>
          . Springer (
          <year>2016</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <surname>Murphy</surname>
            ,
            <given-names>K.P.:</given-names>
          </string-name>
          <article-title>Machine Learning. A Probabilistic Perspective</article-title>
          . MIT Press (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <surname>Wieczorkowska</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Synak</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          , Ras´,
          <string-name>
            <surname>Z.W.:</surname>
          </string-name>
          <article-title>Multi-label classification of emotions in music</article-title>
          . In Kłopotek,
          <string-name>
            <surname>M.A.</surname>
          </string-name>
          , Wierzchon´,
          <string-name>
            <given-names>S.T.</given-names>
            ,
            <surname>Trojanowski</surname>
          </string-name>
          , K., eds.
          <source>: Intelligent Information Processing and Web Mining</source>
          , Springer Berlin Heidelberg (
          <year>2006</year>
          )
          <fpage>307</fpage>
          -
          <lpage>315</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <surname>Charte</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Charte</surname>
            ,
            <given-names>F.D.</given-names>
          </string-name>
          :
          <article-title>Working with multilabel datasets in R: The mldr package</article-title>
          .
          <source>The R journal 7</source>
          (
          <year>2015</year>
          )
          <fpage>149</fpage>
          -
          <lpage>162</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>Valverde</given-names>
            <surname>Albacete</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.J.</given-names>
            ,
            <surname>Pelaez-Moreno</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            ,
            <surname>Cabrera</surname>
          </string-name>
          ,
          <string-name>
            <given-names>I.P.</given-names>
            ,
            <surname>Cordero</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            ,
            <surname>Ojeda-Aciego</surname>
          </string-name>
          ,
          <string-name>
            <surname>M.</surname>
          </string-name>
          :
          <article-title>Exploratory Data Analysis of Multi-Label Classification Tasks with Formal Context Analysis</article-title>
          . In Trnecka,
          <string-name>
            <surname>M.</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Valverde</given-names>
            <surname>Albacete</surname>
          </string-name>
          , F.J., eds.:
          <source>Concept Lattices and their Applications CLA</source>
          , Tallinn University of Technology (
          <year>2020</year>
          )
          <fpage>171</fpage>
          -
          <lpage>183</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <surname>Sechidis</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Tsoumakas</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Vlahavas</surname>
            ,
            <given-names>I.P.</given-names>
          </string-name>
          :
          <article-title>On the Stratification of Multi-label Data</article-title>
          .
          <source>In: Lecture Notes in Computer Science</source>
          . Volume
          <volume>6913</volume>
          ., Berlin, Heidelberg, Springer Berlin Heidelberg (
          <year>2011</year>
          )
          <fpage>145</fpage>
          -
          <lpage>158</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <surname>Valverde-Albacete</surname>
            ,
            <given-names>F.J.</given-names>
          </string-name>
          ,
          <article-title>Pela´ez-</article-title>
          <string-name>
            <surname>Moreno</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          :
          <article-title>The evaluation of data sources using multivariate entropy tools</article-title>
          .
          <source>Expert Systems with Applications</source>
          <volume>78</volume>
          (
          <year>2017</year>
          )
          <fpage>145</fpage>
          -
          <lpage>157</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>Lopez</given-names>
            <surname>Rodriguez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            ,
            <surname>Mora</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            ,
            <surname>Dominguez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            ,
            <surname>Villalon</surname>
          </string-name>
          ,
          <string-name>
            <surname>A.</surname>
          </string-name>
          :
          <article-title>fcaR: Formal Concept Analysis</article-title>
          .
          <source>(2020) R package version 1.0.7.</source>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>