<!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>Loss Functions for Clustering in Multi-instance Learning</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Marek Dědič</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Tomáš Pevný</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Lukáš Bajer</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Martin Holeň</string-name>
          <xref ref-type="aff" rid="aff3">3</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Cisco Systems, Inc.</institution>
          ,
          <addr-line>Karlovo náměstı́ 10, Prague</addr-line>
          ,
          <country country="CZ">Czech Republic</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Faculty of Electrical Engineering, Czech Technical University in Prague</institution>
          ,
          <addr-line>Karlovo náměstí 13, Prague</addr-line>
          ,
          <country country="CZ">Czech Republic</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Faculty of Nuclear Sciences and Physical Engineering, Czech Technical University in Prague</institution>
          ,
          <addr-line>Trojanova 13, Prague</addr-line>
          ,
          <country country="CZ">Czech Republic</country>
        </aff>
        <aff id="aff3">
          <label>3</label>
          <institution>Institute of Computer Science, Czech Academy of Sciences</institution>
          ,
          <addr-line>Pod vodárenskou věží 2, Prague</addr-line>
          ,
          <country country="CZ">Czech Republic</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>1937</year>
      </pub-date>
      <abstract>
        <p>Multi-instance learning belongs to one of re- their work significantly by deciding about whole clusters cently fast developing areas of machine learning. It is a su- of servers instead of each one individually. pervised learning method and this paper reports research A key prerequisite for the application of multi-instance into its unsupervised counterpart, multi-instance cluster-learning to clustering is that loss functions for clustering, ing. Whereas traditional clustering clusters points, multio-riginally proposed for points, are adapted for bags. In this instance clustering clusters bags, i.e. multisets of points orpaper, such an adaptation is outlined for three sophisticated of other kinds of objects. The paper focuses on the problem loss functions: contrastive predictive coding, triplet loss of loss functions for clustering. Three sophisticated lossand magnet loss. functions used for clustering of points, contrastive predic- Of the three proposed methods, triplet loss and magnet tive coding, triplet loss and magnet loss, are elaborated forloss utilize some labels as part of the training process and multi-instance clustering. Finally, they are compared on 18so are not truly unsupervised. As such, the authors expect benchmark datasets, as well as on a real-world dataset. them to outperform the method based on contrastive predictive coding, which on the other hand is the most promising and innovative approach from the theoretical point of 1 Introduction view. In the next section, basic properties of multi-instance Multi-instance learning (MIL) belongs to recently fast de-learning and clustering are briefly introduced. The adaptaveloping areas of machine learning. Though it is a super- tion of the three considered loss functions is explained in vised learning method, this paper addresses its application Section 3. A comprehensive comparison of them is then to unsupervised learning - clustering. Whereas traditionalpresented in Section 4. clustering is one of points, multi-instance clustering clusters multisets of points, also known as bags. Such a grouping of the points into bags is considered a property of the 2 Multi-instance Learning and Clustering problem at hand and therefore sourced from the input data. While there have been some previous attempts at multi- Multi-instance learning (MIL) was first described by [7]. instance clustering, they use pairwise relations between allIn its original form, it was developed and used fsourpoints in all bags, quickly becoming unwieldy and compu- pervised learning. Some prior art also exists fournsutationally infeasible. Our work uses multi-instance learnp-ervised learning, such as [5, 31], however, it uses pairing as a general toolkit for learning representations of bagswise instance distances as a basis for clustering, which and then clusters the bags using those representations. This doesn't properly utilize the inherent structure of the data builds on previous works by the authors and enables clus-and quickly becomes computationally infeasible. tering of arbitrary data-structures by expressing them as The MIL paradigm is a type of representation learning hierarchies of multi-instance problems and then using the on data which has some internal structure. Therefore, it internal structure to better solve the problems at hand. views a sample as abag (i.e. a multiset) of an arbitrary Multi-instance clustering is evaluated in Section 4 in number of objects. The basic elements of MIL are samthe application domain of computer and network security. ples from a spaceX and their corresponding labels from a While this is only one of many possible applications of space Y (a space of classes). Compared to usual supervised MIL due to its general expressive power for structured data,learning, MIL replaces individual instances with bags of it is the domain of choice for the authors. Here, MIL is instances from the spaceX such that every instance inX used to represent user activity as a bag of network con- belongs to at least one bag from the bag-spacBe. nections for each user in a fixed time window. For clus- [7] provides an example of a multi-instance problem tering, this enables detection of compromised users based where each bag represents a key chain with some keys (inon their complex behaviours. Clustering opens a new win- stances). To solve the problem of finding which key opens dow of opportunity here by e.g. grouping servers with sim- a particular lock, a “proxy” MIL problem is presented - deilar behaviour together, allowing a human analyst to boosttermining which key chain opens that particular lock. This</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Copyright ©2020 for this paper by its authors. Use permitted under line of thinking leads to the pivotal definition of the label
Creative Commons License Attribution 4.0 International (CC BY 4.0). of a bag as being positive if the bag contains at least one
positive instance. In later works such as [
        <xref ref-type="bibr" rid="ref4">23</xref>
        ], this interpre- The functionsfI and fB are realized by a deep neural
nettation of MIL is abandoned in favor of a more general one. work using ReLU as its activation function. The
aggregaAn instance is no longer viewed as having a meaning in and tion g is realized as an element-wise mean or maximum of
of itself, but only in the context of its bag. The notion of all the vectors.
an instance-level label is dropped because in this interpre- The structure of the data is highly exploited using the
tation, the bag is the atomic unit of interest. To this end, embedded-space paradigm. The approach uses multiple
the embedded-space paradigm, described in Section 2.2, is layers of MIL nested in each other – the instances of a
used. bag do not necessarily need to be feature vectors, but can
be bag in themselves. The HTTP trafic of a particular
2.1 A probabilistic formulation of multi-instance client is therefore represented as a bag of all second-level
learning domains the client has exchanged datagrams with. Each
second-level domain is then represented as a bag of
indiA probabilistic way of describing multi-instance learning vidual URLs which the client has connected to. Individual
was first introduced in [
        <xref ref-type="bibr" rid="ref4">23</xref>
        ] and builds on the previous work URLs are then split into 3 parts, domain, path and query,
[19]. and each part is represented as a bag of tokens, which can
      </p>
      <p>
        Let for the spaceX exist a measurable space(X ; A), then be broken down even further. In the end, the model
where A is a -algebra onX . Let PX denote the set of consists of 5 nested MIL problems.
all probability measures o(Xn ; A). A bag B is viewed as A benefit of MIL is also its easy use for explainability
a random sample with replacement of a random variable and interpretability. The authors of [
        <xref ref-type="bibr" rid="ref3">22</xref>
        ] present a way to
governed by a particular probability distribuptiBon2 PX , extract indicators of compromise and explain the decision
that is using the learned MIL model.
      </p>
      <p>B = fxijxi
pB; i 2 f1; : : : ; mgg wherem 2 N: (1)</p>
    </sec>
    <sec id="sec-2">
      <title>2.3 Clustering</title>
      <p>
        2.2 Embedded-space paradigm for solving Clustering is a prime example of a problem typically
assomulti-instance problems ciated with unsupervised learning. The problem at hand,
however, is not one of clustering ordinary number vectors
While it is possible to use several approaches to solv- in a linear space. Instead, a clustering of objects
repreing multi-instance problems, in this work, the embedded- sented by bags is explored, as that is the problem solved for
space paradigm was used. For an overview of the other datasets introduced later in Section 4. While [
        <xref ref-type="bibr" rid="ref9">28</xref>
        ] present a
paradigms, see [6]. clustering of bags using a modified Hausdorf distance on
      </p>
      <p>
        In the embedded space paradigm, labels are only defined bags and [17] present a clustering using maximum mean
on the level of bags. In order for these bag labels to bediscrepancy, a diferent approach to clustering of bags is
learned, an embedding function of the form: B ! X used in this work. Among the main reasons for this choice
must be defined, where X is a latent space, which may or is the prohibitively high computational complexity of the
may not be identical toX . Using this function, each bag previously mentioned approaches on large datasets and the
can be represented by an object (B) 2 X , which makes it possibility of utilizing the representations previously
intropossible to use any of-the-shelf supervised learning algo- duced in [
        <xref ref-type="bibr" rid="ref3">22</xref>
        ].
rithm acting onX . Among the simplest embedding func- An approach based on the embedded-space paradigm for
tions are, e.g. element-wise minimum, maximum, and MIL was chosen. In order to utilize the structure of the
mean. A more complicated embedding function may for data, a MIL model is used to represent each bag in the
laexample apply a neural network to each instance of the bag tent spaceX . This presents the issue of how to train the
emand subsequently pool the instances using one of the afore- bedding function , because its learning in standard MIL
mentioned functions. is supervised.
      </p>
      <p>
        Specifically to the experiments presented in Section 4, The embedding function can be actually written as
[
        <xref ref-type="bibr" rid="ref3">22</xref>
        ] present an approach to learning to classify HTTP traf- = (B; ) whereB 2 B and are the parameters of the
ifc by utilizing sets of URLs. Neural networks are used embedding, typically learned during the training phase. In
to transform both instance-level and bag-level representa-the context of clustering, these parameters still need to be
tions. The model is as follows: A neural netwofrIk: learned over some kind of training. This itself presents
anX1 ! X2 is used to transform instances, followed by an other challenge though – of-the-shelf algorithms typically
aggregation function work in some constant Hilbert space, whereas the latent
space needs to change over the learning period. As is the
g : BX2 ! X1: case for MIL itself, end-to-end learning is used. A
clusterFinally, a second deep neural netwofrBk : X1 ! X2 is loss functionLC : B ! R is chosen and used to express
used to transform the representation of each bag. Combin- the actual loss for the embedding modeland its
parameing these functions gives the embedding function ters as
(B) = fB (g (ffI (x)jx 2 Bg)) :
      </p>
      <p>L ( ; ) = LC (f (B; )jB 2 Bg) :
(2)
If the cluster-losLsC is chosen correctly, minimizinLg high-quality embeddings would need only a small amount
over the learning period will yield a latent spXacine which of seed data points to reach relatively high accuracy. For
the bags are already naturally clustered according to thethis measure, the kNN algorithm was run thrice and the
redesign of the cluster-loss function. Applying any of-the- sults averaged to compensate for high dependence on the
shelf clustering algorithm Xonwill then give good results. particular seed points chosen.</p>
      <p>How to choose the cluster-loss functioLnC is the focus of
Section 3.</p>
      <sec id="sec-2-1">
        <title>3 Investigated Loss Functions</title>
        <p>2.4 Clustering evaluation metrics In Section 2.4, a method for learning a representatiownas
described. In order to learn the parameters of the
represenIn our research, several clustering evaluation metrics havetation, a clustering-loss function is required in the form
been used. The primary metrics are based on the
Silhouette coeficient, the secondary ones on the kNN algorithm. LC : PM X ! R:
The metrics are somewhat diferent to the ones traditionally
used in evaluating clustering methods as all the datasets In this section, three ways of constructing such a
clusteringused in this work are originally classification datasets and loss function are explored. First, an unsupervised method
therefore have classes available. Each class can then be constructing a clustering loss-function is presented,
folviewed as a cluster target and the learned clustering evalu-lowed by two supervised methods.
ated against these targets.</p>
        <p>
          The first two metrics measure thehomogeneity of clus- 3.1 Contrastive Predictive Coding
ters (that is the property of instances of one cluster being
close to one another) and thesireparation (that is the prop- Contrastive predictive codingC(PC) is a technique first
erty of instances of diferent clusters being far apart), see introduced by [
          <xref ref-type="bibr" rid="ref2">21</xref>
          ]. The method builds the model on the
[9]. To measure the non-homogeneity of a cluster, the av- ideas from predictive coding [8]. CPC represents time
seerage distance between items in a cluster is measured and ries by modelling future data from the past. To this end, the
averaged over all clusters, giving the following metric formodel learns high-level representations of the data and
disitems xj in clustersCi: cards noise. The further in the future the model predicts,
the less shared information is available and thus the global
nonhomo(C1; : : : ; Cn) = n1 Xn X kxj (Ci)k ; strTuhcetucroerneeecdosnctoepbtetiankfeenrrferdombetCtePrC. is a loss function
i=1 xj2Ci called InfoNCE in the prior art. Given a time series of
where valuesxt, an autoregressive model produces a contecxtt
(Ci) = 1 X xj; from allxi up to the pointt. For a training seXt, predicted
jCij xj2Ci future valuext+k, the current contexctt, and a modelfk,
        </p>
        <p>the InfoNCE loss is defined as
with jCij being the number of instances in the baCgi.</p>
        <p>To measure the separation of clusters, the average
distance between cluster centres was taken:
sep (C1; : : : ; Cn) =</p>
        <p>2
n (n
1) i;j2n^
i&lt;j
X k (Ci)</p>
        <p>(Cj)k :</p>
        <sec id="sec-2-1-1">
          <title>The final primary metric is the Silhouette coeficient:</title>
          <p>2
EX 4logfk (xt+k; ct) log X fk (xj; ct)5 :
xj2X</p>
          <p>3
Optimizing this value will resultfink modelling the
density ratio
fk (xt+k; ct) /
p (xt+kjct)
p (xt+k)
sep (C1; : : : ; Cn) and therefore in maximizing the mutual information
besilhouette(C1; : : : ; Cn) = nonhomo(C1; : : : ; Cn) : (3) tween xt+k and ct.</p>
          <p>The actual application to MIL is based on the following</p>
          <p>For the secondary metrics, the kNN algorithm in the rep- idea. If a bag is split into two parts, it is reasonable to
exresentation space is used and its accuracy measured. While pect that the representations of these two parts would be
the primary metric measures the quality of the clustering close to one another. On the other hand, if a random bag
in general, this metric focuses on the utility of the learned were to be drawn from the data (assaimple random sample
representation to a specific and useful task - classification. with replacement), it is reasonable to expect it to be
relaThe training data of the kNN classifier is chosen randomly tively far from any actual bag present in the data. These
asand is in this work referred to saesed data to avoid confu- sumptions can be proven correct by using the probabilistic
sion with the data used to train the embedding. The value formalism for MIL (see Subsection 2.1). Given that each
of k = 3 was chosen by experimental evaluation. This bag Bk is viewed as a set of realizations of a probability
gives an insight into the robustness of the clustering, as distributionPk 2 PX , it follows that the two parts of the</p>
          <p>K
logX
j=1</p>
          <p>B(1)
k</p>
          <p>B0
j</p>
          <p>
            :
bag, B(1) and Bk(2), are sets of realizations from the same Euclidean distance is used. However, ideally, the metric
k
distributionPk and therefore should be statistically indis- should adapt to the problem at hand. [
            <xref ref-type="bibr" rid="ref10">29</xref>
            ] present a way to
tinguishable. On the other hand, a randomly sampled bag learn a Mahalanobis distance for kNN such that it has the
Bj0 does not share the same probability distribution. Us- homogeneity and separation properties of clustering. This
ing these assumptions, the following clustering loss is con-distance, the description of which follows, has been
utistructed: lized in this work as the basis for the desired loss function
LCPC = log Bk(1) Bk(2) 2 LCL.et f(xi; yi)gin=1 be a training dataset withxi 2 Rd and
yi discrete class labels. In the original work, the goal is to
2 learn a linear transformation
0
          </p>
          <p>1
n n wherec &gt; 0 is a hyper-parameter of this method.</p>
          <p>LCPC = n1 Xi=1 @BBlog(Dii) logXj=1 DijACC ; (5) moTdoifieaddatoptltehveeroargigeitnhaelbmagegthinogd,otfhtehededfinaittai.onTshenemeadtrtoixybe
j6=i is defined in the same way, only with labels on the level of
wheren is the number of bags. bags. The value ij = 1 if the bag Bj is a target
neigh</p>
          <p>Out of the three methods presented in this section, the bour for the bagBi. Then, using the matrixD defined in
approach based on contrastive predictive coding seems the equation 4 directly instead of the linear transformation, the
most promising, as it is the only unsupervised method and loss function can be expressed as
could therefore be used in a broader class of applications.</p>
          <p>This, however, also has its drawbacks – unsupervised
methods are generally harder to learn correctly. For that reasonL,triplet= X ijDij+
ij
the two supervised methods were selected as a safer option.</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>3.2 Triplet Loss</title>
      <p>where c &gt; 0 is again a hyper-parameter of the method.</p>
      <p>
        The performance of thek-nearest neighbour algorithm de- Although [
        <xref ref-type="bibr" rid="ref10">29</xref>
        ] suggest finding as the k-nearest
neighpends heavily on the distance metric used. Typically, the bours of a data point, the loss has been simplified by setting
1On the of-chance a random bag would be close toBk(1), this would
be outweighed by the other terms.
ij = yij fori; j = 1; : : : ; n in this work, making all the
neighbours of a cluster its target neighbours.
      </p>
      <p>B(1)</p>
      <p>i
where the valueK 2 N is a hyper-parameter of this
method. The first term of the loss function depicts the
notion that the representations of the two parts of the bag distances as
should be close to one another and corresponds to the first
term of InfoNCE, which maximizes the prediction of a D (xi; xj) = kL (xi xj)k2 :
matching future sample from the current context. The sec- A helper matrixy is used such that
ond term depicts the notion that a random bag should be
far from all the bag1sand corresponds to the second term (0 for yi 6= yj
of InfoNCE, which minimizes the prediction of a random yij = 1 for yi = yj :
sample from the current context. Choosing to only use the
ifrst part of the bag in the second term has no efect as the In addition to this, for each inpuxti, k target neighbours
two parts are chosen randomly. are defined that are supposed to be close toxi. Euclidean</p>
      <p>This method can be further modified to make it less com- distance may be used to find the target neighbours. A
maputationally complex. In order not to have to draw a lot oftrix is used to indicate target neighbours whereij = 1
random bags, it can be reasonably expected that, on aver- if xj is a target neighbour oxfi and 0 else.
age, the representations of two parts of two mismatched The cost function features two competing terms. The
bags Bk(11) andBk(22) should be far apart. A matrDix is con- ifrst term depicts the notion that an input should be close
structed as to its target neighbours. The second term depicts the
no2 tion that inputs of a diferent class should be far from one
Dij = : (4) another. The loss is of the form</p>
      <sec id="sec-3-1">
        <title>This linear transformation is then used to compute squared</title>
        <p>B(2)
j</p>
      </sec>
      <sec id="sec-3-2">
        <title>The distances of the corresponding halves are found on the</title>
        <p>diagonal ofD, whereas the distances of mismatched halves
are in the rest of the matrix. Under this assumption the final
loss for the CPC method is
n
X
i;j=1
ij kL (xi</p>
        <p>n
xj)k2 + c X
i;j;l=1
ij (1</p>
        <p>yil)
max 0; 1 + kL (xi
xj)k2
kL (xi</p>
        <p>xl)k2 ;</p>
        <p>L : Rd ! Rd:
+c X
ijl
ij (1
yil) max (0; 1 + Dij</p>
        <p>Dil) ; (6)</p>
        <p>The magnet loss is then defined as
tlMroiaspgslnefetutlnlocostsisos, nifirsseatsnsineenntrhtoiaadnlucleycmedgeonbetyso[fo2tv6he]er.parWlelvhieotrrueispalslyetthdseesotcfrriapibldeedattaLmagnet = n1 Xi=n1 max 0; 1 + logexp 2M12iNi !(7);
point, its target neighbour and a point from a diferent class where 2 R is a hyper-parameter of the method. Since
and optimizes their distances, magnet loss maintains an the method standardizes both of the terms of the innermost
explicit model of the distributions of diferent classes in fraction by 2, is the desired cluster separation gap
exthe representation space. To capture the distributions, the pressed in the units of the variance.
model uses simple clustering models for each class. Dif- The magnet loss is taken almost verbatim from the
origferently to triplet loss, for which the target neighbourhoodinal article. The only change needed is a diferent way to
is set a priori and is based on similarity in the original in- obtain the representation space by taking
put space, magnet loss uses similarity in the space of
representations and updates it periodically. Magnet loss also ri = (Bi) :
pursues local separation instead of global – representations
of diferent classes should be separated, but can be inter- In this usage, yi is the class label assigned to the baBgi
leaved. (making magnet loss a supervised method) annd is the</p>
        <p>Let f(xi; yi)gin=1 be a training dataset wherexi 2 Rd number of bags in the dataset.
and yi are one ofC discrete class labels. A general param- Due to the choice of the hyper-parameteKr being
noneterized mapf ( ; ) embeds the inputs into a representa- obvious for most problems, alternative clustering
methtion space: ods that would not need hyper-parameter tuning were
exri = f (xi; ) : plored. One such methods,elf-tuning spectral clustering</p>
        <p>
          [
          <xref ref-type="bibr" rid="ref11">30</xref>
          ] was implemented as a replacement for the K-means
alFor each classc, K cluster assignments are obtained with gorithm used in the original method. Section 4.3 presents
the K-means++ algorithm [18, 2] wherKe 2 N is a hyper- a comparison of the performance of these two methods.
parameter of the method: Since magnet loss is an enhancement of triplet loss, it
I1c; : : : ; IKc = arg min XK X r 1 X s 2 :
tihesirgrheteharasnonnutarmbipblleeerttoolfaoshssysup.meOre-npietarwdaormuaweltdberapcsekwrfohofircmhmantgehneedesttaolmobesesotuirsnbtehedte
        </p>
        <p>
          I1c;:::;IKc k=1 r2Ikc jIkcj s2Ikc in order for the method to work correctly. This problem is
The centre of each cluster is denotedck: partially solved by the introduction of self-tuning spectral
clustering [
          <xref ref-type="bibr" rid="ref11">30</xref>
          ], however, that is outside the scope of this
paper.
ck =
1
c
jIkj r2Ikc
        </p>
        <p>X r:
Ni = kri</p>
        <p>ik2 :</p>
      </sec>
      <sec id="sec-3-3">
        <title>For each input, the centre of the cluster in which its repre</title>
        <p>sentation falls is denoted as
The three loss functions presented in Section 3 were
experimentally evaluated on 18 publicly available datasets and
i = argcminkri ckk on a corporate dataset from the domain of computer
secuk rity. The 2 metrics presented in Section 2.4 were used, i.e.
and the squared distance of its representation from the cen- the Silhouette coeficient and the accuracy of a kNN
clastre of the cluster is denoted as sifier built on the embedding. Both of these metrics were
tracked over the learning period to also evaluate how the
models are learning in addition to their final performance.</p>
        <sec id="sec-3-3-1">
          <title>4 Experimental Comparison</title>
          <p>The variance of the distance of the representations from 4.1 Datasets
their respective centres can then be calculated as</p>
        </sec>
      </sec>
      <sec id="sec-3-4">
        <title>The evaluation was done on a set of 18 publicly available</title>
        <p>2 = 1 Xn Ni: datasets, listed in Table 1. All the datasets as used were
n 1 i=1 alsTohemmadoedpelusblwi2ec.re also evaluated on a proprietary dataset
Forri, the dissimilarity to all the inputs of diferent classes provided by Cisco Cognitive Intelligence, consisting of
is calculated as records of network connections from clients (e.g. user
computers or mobile devices) to some on-line services.</p>
        <p>
          K
Mi = X X exp
c6=yi k=1
Source Datasets of a bag. This is a natural embedding of a bag as its
expected value. This model is referred to as tmhean model
[4] BrownCreeper, WinterWren in the rest of this work. A classification model has been
[1] Elephant, Fox, Tiger introduced as a target to beat. This model was realised by
[7] Musk1, Musk2 a MIL neural network identical to the previously described
[
          <xref ref-type="bibr" rid="ref8">27</xref>
          ] Mutagenesis1, Mutagenesis2 one, with a final layer of 2 output neurons with an
iden[
          <xref ref-type="bibr" rid="ref14">33</xref>
          ] Newsgroups1, Newsgroups2, Newsgroups3 tity activation function added. The accuracy of the model
[
          <xref ref-type="bibr" rid="ref5 ref6">24, 25</xref>
          ] Protein has been evaluated by selecting the optimal threshold on its
[15] UCSBBreastCancer output. This model mirrors the model used in the proposed
[
          <xref ref-type="bibr" rid="ref13">32</xref>
          ] Web1, Web2, Web3, Web4 methods, but replaces the clustering with simple
classification. This model is referred to as tchleassification model
Table 1: The 18 publicly available datasets used. in the rest of this work.
        </p>
        <p>Some of the three proposed clustering-losses have some
The dataset represents HTTP trafic of more than 100 com- hyper-parameters which need to be tuned. A range of
valpanies. Two datasets were collected, each spanning 1 day ues was tried for each hyper-parameter in order to select
of trafic. The training data was trafic from 2019-11-18, the best configuration for each on each of the datasets.
while the data used for testing was collected the follow- For Ltriple,t the values c 2 f0:01; 0:1; 1; 10; 100g have
ing day, 2019-11-19. For each connection, a proprietary been tested. ForLmagnet, the valuesK 2 f2; 3; 8; 16g,
classification system based on [14] provided labels, clas- 2 f0; 0:1; 0:5g and the cluster index update frequency
sifying the connections either as legitimate or malicious in f5; 10; 25; 70g have been tested.
(connected to malware activity). The data was sampled to
include 90 % of negative bags and 10 % of positive bags. 4.3 Comparison of Results
For each connection, 20 connection features were used, as
well as a MIL model of the server URL, which is visualized Table 2 lists the accuracy of a kNN classifier build on the
in Figure 1. embedding for all of the methods and all of the datasets.</p>
        <p>Figure 2 shows the value of the Silhouette coeficient and
the accuracy on 3 selected datasets. As can be seen, CPC
4.2 Experimental Design is the worst performing of the methods overall, and, more
significantly, shows no clear improvement over the
learnThe models for evaluation were implemented in the Julia ing periods for both the Silhouette coeficient and the kNN
programming language [3] using the Flux.jl framework forclassifier accuracy. Between triplet loss and magnet loss,
machine learning [13] and the Mill.jl framework for multi-magnet loss is somewhat better in the classification
accuinstance learnin3g. racy, whereas triplet loss is somewhat better in the
Silhou</p>
        <p>
          The particular architecture of the models was chosen ette coeficient, indicating better separation of individual
based upon previous experience with using neural net- clusters. Of note is also the difering behaviour for
varworks in multi-instance setting [
          <xref ref-type="bibr" rid="ref3">22</xref>
          ]. Several architec- ious datasets, for example the clear dominance of triplet
tures were tested and the best one selected for the exper- loss w.r.t. the Silhouette coeficient on the Web3 dataset.
iments. The embedding was realised by a MIL neural This shows that none of the methods is a clear winner in all
network consisting of 2 per-instance layers of 30 neurons,scenarios and the best one needs to be carefully selected.
followed by aggregation formed by concatenating
elementwise mean and element-wise maximum of all instances in
a bag, followed by 2 per-bag layers of 30 neurons. All the4.4 Statistical significance of the results
neurons used the ReLU activation function [12]. Layer The null hypothesis that all three methods are the same as
weights were initialized using Glorot initialization [11], measured by the accuracy can be rejected at a 5 % level
bias vectors were initialized to zeros. ADAM [16] was used of significance by the Friedman two-way analysis of
varias the optimization method. ance by ranks [10]. Triplet and magnet losses are better
        </p>
        <p>
          For each of the datasets, 80 % of bags were randomly than CPC at a 5 % level of significance by the post-hoc
chosen as the training data, with the rest being testing data. Nemenyi pairwise test [
          <xref ref-type="bibr" rid="ref1">20</xref>
          ]. However, the null hypothesis
The models were trained using 100 mini-batches of size of that magnet loss and triplet loss are the same cannot be
re50.
        </p>
        <p>jected at the 5 % significance level by this test. This further</p>
        <p>In order to provide some baseline against which the supports the difering results between these two methods as
models could be compared (as there is no prior art formentioned in the previous subsection.
this problem), two other models were introduced. A
non-machine-learning model was introduced as a baseline,
which all models should surpass. This model implements4.5 HTTP dataset
the embedding as an element-wise mean of all instances Table 3 compares the three methods on the proprietary
3https://github.com/pevnak/Mill.jl dataset from Cisco Cognitive Intelligence. Here, magnet
designed token features learned features of URL parts learned features of an URL
learned features of a SLD
evil
com
path
ifle
key=val
get=exploit.js</p>
      </sec>
      <sec id="sec-3-5">
        <title>In our work, the underexplored research area of multi</title>
        <p>instance clustering was investigated. Three methods for
clustering of bags were introduced, of which one is
unsupervised (CPC) and two are supervised (Triplet loss and
Magnet loss). For each of the methods, the prior art it
builds on was presented, along with its modification for
the purposes of multi-instance clustering. All three
methods were theoretically and experimentally evaluated and
compared. The experiments were conducted first on
publicly available datasets in a reproducible fashion.
Following that, a corporate dataset of network security data was
used as it is the intended application domain for this work.</p>
        <p>Comparing the methods on the publicly available
datasets shows the method based on contrastive predictive
coding to perform the worst, with the other having no
statistically significant diference between them. Similar results
were also obtained on the corporate dataset of HTTP trafic,
albeit none of the results were as good as anticipated. The
method based on contrastive predictive coding performed
Table 2: The accuracy of the final models for the publicly poorly on both the publicly available datasets and the
coravailable datasets. porate one, however, the comparison might not be fair as
the CPC method is unsupervised, whereas the other two
Variant CPC Triplet loss Magnet loss can utilize labels on the training data, giving them a strong
advantage.
2 classes 0.920 0.910 0.930 The initial expectation of CPC being outperformed
20 classes 0.893 0.868 0.904 proved to be true. Even as such, the result is interesting
and has a value of its own in providing a baseline and a
Table 3: The accuracy of the final models for the corporate comparison for these and future methods.
datasets.</p>
        <p>Acknowledgement
loss is the best of the three methods, however, only by a The research reported in this paper has been supported by
small margin over the other 2 methods. Since the datasets the Czech Science Foundation (GAČR) grant 18-21409S
consisted of 90 % of negative samples however, none of the and partially supported by the GAČR grant 18-18080S.
results is particularly remarkable and some further tuning
would be needed if any of the methods were to be used in
real environment.</p>
        <p>50
Learning step
75</p>
        <p>100
(a) Musk2, Silhouette coef.</p>
        <p>50</p>
        <p>Learning step
(b) Musk2, accuracy
50
Learning step
75
100</p>
        <p>50
Learning step
(c) UCSBBreastCancer, Silhouette coef.
(d) UCSBBreastCancer, accuracy</p>
        <p>CPC
Triplet</p>
        <p>Magnet
Classification model
75</p>
        <p>100
CPC
Triplet</p>
        <p>Magnet
Classification model
75
100
1:5
io1:0
t
a
R
0:5
0:0
2:0
1:5
o
i
t
aR1:0
0:5
0:0
100
75
o
i
t
a
R 50
25
0
0
0
[3] J. Bezanson et al. “Julia: A Fresh Approach to
Numerical Computing”. In:SIAM Review 59.1 (Jan.
2017), pp. 65–98. issn: 0036-1445. doi: 10.1137/
141000671. url: https : / / epubs . siam .
org / doi / 10 . 1137 / 141000671 (visited on
09/01/2018).
[13] Mike Innes. “Flux: Elegant machine learning with</p>
        <p>Julia”. In:Journal of Open Source Software (2018).
doi: 10.21105/joss.00602.
[4] Forrest Briggs, Xiaoli Fern, and Raviv Raich. [14] Ján Jusko. “Graph-based Detection of Malicious
“Rank-loss support instance machines for MIML Network Communities”. PhD thesis. Prague: Czech
instance annotation”. In:Proceedings of the ACM Technical University in Prague, 2017u.rl: https:
SIGKDD International Conference on Knowledge //dspace.cvut.cz/handle/10467/73702
(visDiscovery and Data Mining. Aug. 2012. doi: 10 . ited on 04/02/2019).
1145/2339530.2339616.</p>
        <p>[15] Melih Kandemir, Chong Zhang, and Fred A.
[5] Ying Chen and Ou Wu. “Contextual Hausdorf Hamprecht. “Empowering Multiple Instance
dissimilarity for multi-instance clustering”. In: Histopathology Cancer Diagnosis by Cell Graphs”.
Fuzzy Systems and Knowledge Discovery (FSKD). In: Medical Image Computing and
ComputerSichuan, China: IEEE Computer Society Press, May Assisted Intervention – MICCAI 2014. Ed. by
2012, pp. 870–873. isbn: 978-1-4673-0024-7. doi: Polina Golland et al. Lecture Notes in Computer
10.1109/FSKD.2012.6233889. url: https:// Science. Cham: Springer International Publishing,
ieeexplore.ieee.org/abstract/document/ 2014, pp. 228–235. isbn: 978-3-319-10470-6. doi:
6233889/ (visited on 05/14/2018). 10.1007/978-3-319-10470-6_29.
[6] Marek Dědič. “Optimalization of distances for [16] Diederik P. Kingma and Jimmy Ba. “Adam:
multi-instance clustering”. MA thesis. Prague: A Method for Stochastic Optimization”. In:
Czech Technical University in Prague, Jan. 2020. arXiv:1412.6980 [cs] (Jan. 2017). arXiv:
[7] Thomas G. Dietterich, Richard H. Lathrop, and 1412.6980. url: http : / / arxiv . org / abs /
Tomás Lozano-Pérez. “Solving the multiple in- 1412.6980 (visited on 06/25/2020).
stance problem with axis-parallel rectangles”. In:[17] J. Kohout and T. Pevný. “Network Trafic
FinArtificial Intelligence 89.1 (Jan. 1997), pp. 31–71. gerprinting Based on Approximated Kernel
Twoissn: 0004-3702. doi: 10.1016/S0004-3702(96) Sample Test”. In:IEEE Transactions on Information
00034-3. (Visited on 05/31/2017). Forensics and Security 13.3 (Mar. 2018), pp. 788–
801. issn: 1556-6013. doi: 10.1109/TIFS.2017.
2768018.
[18] J. MacQueen. “Some methods for classification and
analysis of multivariate observations”.
IPnr:oceedings of the Fifth Berkeley Symposium on
Mathematical Statistics and Probability. Vol. 1.
Berkeley, California: University of California Press, 1967,
pp. 281–297.
[8] P. Elias. “Predictive coding–I”. InI:RE Transactions
on Information Theory 1.1 (Mar. 1955), pp. 16–
24. issn: 2168-2712. doi: 10 . 1109 / TIT . 1955 .</p>
        <p>1055126.
[9] Brian S. Everitt, Sabine Landau, and Morven Leese.</p>
        <p>Cluster Analysis. 4th ed. Taylor &amp; Francis, 2001.</p>
        <p>isbn: 978-0-340-76119-9.
[10] Milton Friedman. “The Use of Ranks to Avoid the</p>
        <p>Assumption of Normality Implicit in the Analysis of [19] Krikamol Muandet et al. “Learning from
DistriVariance”. In:Journal of the American Statistical butions via Support Measure Machines”.
InA:dAssociation 32.200 (Dec. 1937). Publisher: Taylor vances in neural information processing systems.
&amp; Francis, pp. 675–701.issn: 0162-1459. doi: 10. 2012, pp. 10–18. url: http://papers.nips.cc/
1080/01621459.1937.10503522. url: https:
paper/4825-learning-from-distributions</p>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [20]
          <string-name>
            <given-names>PB</given-names>
            <surname>Nemenyi</surname>
          </string-name>
          .
          <article-title>“Distribution-free multiple comparisons (doctoral dissertation</article-title>
          , princeton university,
          <year>1963</year>
          )
          <article-title>”</article-title>
          .
          <source>In: Dissertation Abstracts International 25.2</source>
          (
          <issue>1963</issue>
          ), p.
          <fpage>1233</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [21]
          <string-name>
            <surname>Aaron</surname>
            <given-names>van den Oord</given-names>
          </string-name>
          , Yazhe Li,
          <string-name>
            <given-names>and Oriol</given-names>
            <surname>Vinyals</surname>
          </string-name>
          . “
          <article-title>Representation Learning with Contrastive Predictive Coding”</article-title>
          . In:arXiv:
          <year>1807</year>
          .03748 [cs, stat] (
          <year>Jan</year>
          .
          <year>2019</year>
          ). arXiv:
          <year>1807</year>
          .03748. url: http://arxiv. org/abs/
          <year>1807</year>
          .03748 (visited on 12/29/
          <year>2019</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [22]
          <string-name>
            <given-names>Tomas</given-names>
            <surname>Pevny</surname>
          </string-name>
          and
          <string-name>
            <given-names>Marek</given-names>
            <surname>Dedic</surname>
          </string-name>
          . “
          <article-title>Nested Multiple Instance Learning in Modelling of HTTP network trafic”</article-title>
          . In: arXiv:
          <year>2002</year>
          .04059 [cs] (
          <year>Feb</year>
          .
          <year>2020</year>
          ). arXiv:
          <year>2002</year>
          .04059. url: http : / / arxiv . org / abs/
          <year>2002</year>
          .04059 (visited on 06/25/
          <year>2020</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [23]
          <string-name>
            <given-names>Tomáš</given-names>
            <surname>Pevný</surname>
          </string-name>
          and
          <string-name>
            <given-names>Petr</given-names>
            <surname>Somol</surname>
          </string-name>
          . “
          <article-title>Using Neural Network Formalism to Solve Multiple-Instance Problems”</article-title>
          .
          <source>In: Advances in Neural Networks - ISNN 2017</source>
          . Springer, Cham,
          <year>June 2017</year>
          , pp.
          <fpage>135</fpage>
          -
          <lpage>142</lpage>
          . isbn:
          <fpage>978</fpage>
          -3-
          <fpage>319</fpage>
          -59072-1. doi:
          <volume>10</volume>
          . 1007 / 978 - 3 -
          <fpage>319</fpage>
          - 59072 - 1 _
          <fpage>17</fpage>
          . url: https : / / link . springer.com/chapter/10.1007/978-3-
          <fpage>319</fpage>
          - 59072-1_17 (visited on 05/23/
          <year>2018</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [24]
          <string-name>
            <given-names>Soumya</given-names>
            <surname>Ray</surname>
          </string-name>
          and
          <string-name>
            <given-names>Mark</given-names>
            <surname>Craven</surname>
          </string-name>
          .
          <article-title>“Learning Statistical Models for Annotating Proteins with Function Information using Biomedical Text”</article-title>
          .
          <source>InB:MC Bioinformatics 6</source>
          .1 (May
          <year>2005</year>
          ),
          <article-title>S18</article-title>
          . issn:
          <fpage>1471</fpage>
          -
          <lpage>2105</lpage>
          . doi:
          <volume>10</volume>
          .1186/
          <fpage>1471</fpage>
          -2105-6-S1-S18. url: https: //doi.org/10.1186/
          <fpage>1471</fpage>
          -2105-6-S1-S18
          <source>(visited on 01/01/</source>
          <year>2020</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [25]
          <string-name>
            <given-names>Soumya</given-names>
            <surname>Ray</surname>
          </string-name>
          and
          <string-name>
            <given-names>Mark</given-names>
            <surname>Craven</surname>
          </string-name>
          . “
          <article-title>Supervised versus multiple instance learning: An empirical comparison”</article-title>
          .
          <source>In: Proceedings of the 22nd International Conference on Machine Learning. Jan</source>
          .
          <year>2005</year>
          , pp.
          <fpage>697</fpage>
          -
          <lpage>704</lpage>
          . doi:
          <volume>10</volume>
          .1145/1102351.1102439.
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [26]
          <string-name>
            <given-names>Oren</given-names>
            <surname>Rippel</surname>
          </string-name>
          et al. “
          <article-title>Metric Learning with Adaptive Density Discrimination”</article-title>
          .
          <source>Ina:rXiv:1511.05939 [cs, stat] (Mar</source>
          .
          <year>2016</year>
          ). arXiv:
          <volume>1511</volume>
          .05939.url: http: / / arxiv . org / abs / 1511 . 05939 (visited on 06/05/
          <year>2020</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [27]
          <string-name>
            <given-names>A.</given-names>
            <surname>Srinivasan</surname>
          </string-name>
          , Stephen Muggleton, and
          <string-name>
            <given-names>Robert</given-names>
            <surname>King</surname>
          </string-name>
          .
          <article-title>“Comparing the use of background knowledge by inductive logic programming systems”</article-title>
          .
          <source>In: Proceedings of the 5th International Workshop on Inductive Logic Programming</source>
          .
          <year>1995</year>
          , pp.
          <fpage>199</fpage>
          -
          <lpage>230</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [28]
          <string-name>
            <given-names>Jun</given-names>
            <surname>Wang</surname>
          </string-name>
          and
          <string-name>
            <surname>Jean-Daniel Zucker</surname>
          </string-name>
          . “
          <article-title>Solving Multiple-Instance Problem: A Lazy Learning Approach”</article-title>
          .
          <source>In: Proceedings of the Seventeenth International Conference on Machine Learning. Ed. by Pat Langley</source>
          . Stanford University, Stanford, CA, USA: Morgan Kaufmann,
          <year>2000</year>
          , pp.
          <fpage>1119</fpage>
          -
          <lpage>1125</lpage>
          . url: http : / / cogprints . org / 2124/ (visited on 07/01/
          <year>2017</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [29]
          <string-name>
            <surname>Kilian</surname>
            <given-names>Q Weinberger</given-names>
          </string-name>
          , John Blitzer, and
          <string-name>
            <surname>Lawrence</surname>
            <given-names>K.</given-names>
          </string-name>
          <string-name>
            <surname>Saul</surname>
          </string-name>
          . “
          <article-title>Distance Metric Learning for Large Margin Nearest Neighbor Classification”</article-title>
          .
          <source>In:Advances in Neural Information Processing Systems</source>
          <volume>18</volume>
          . Ed. by
          <string-name>
            <given-names>Y.</given-names>
            <surname>Weiss</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Schölkopf</surname>
          </string-name>
          , and
          <string-name>
            <given-names>J. C.</given-names>
            <surname>Platt</surname>
          </string-name>
          . MIT Press,
          <year>2006</year>
          , pp.
          <fpage>1473</fpage>
          -
          <lpage>1480</lpage>
          . url: http : / / papers . nips . cc / paper / 2795 - distance - metric
          <string-name>
            <surname>-</surname>
          </string-name>
          learning
          <string-name>
            <surname>-</surname>
          </string-name>
          for
          <string-name>
            <surname>-</surname>
          </string-name>
          large
          <string-name>
            <surname>-</surname>
          </string-name>
          margin
          <string-name>
            <surname>-</surname>
          </string-name>
          nearest
          <string-name>
            <surname>-</surname>
          </string-name>
          neighbor-classification.pdf.
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [30]
          <article-title>Lihi Zelnik-manor and Pietro Perona. “Self-Tuning Spectral Clustering”</article-title>
          .
          <source>InA:dvances in Neural Information Processing Systems</source>
          <volume>17</volume>
          . Ed. by
          <string-name>
            <given-names>L. K.</given-names>
            <surname>Saul</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Weiss</surname>
          </string-name>
          , and
          <string-name>
            <given-names>L.</given-names>
            <surname>Bottou</surname>
          </string-name>
          . MIT Press,
          <year>2005</year>
          , pp.
          <fpage>1601</fpage>
          -
          <lpage>1608</lpage>
          . url: http : / / papers . nips . cc / paper / 2619 - self - tuning
          <string-name>
            <surname>-</surname>
          </string-name>
          spectral - clustering .
          <source>pdf (visited on 01/06/</source>
          <year>2020</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [31]
          <string-name>
            <surname>Min-Ling Zhang</surname>
          </string-name>
          and
          <string-name>
            <surname>Zhi-Hua Zhou</surname>
          </string-name>
          . “
          <article-title>Multiinstance clustering with applications to multiinstance prediction”. en</article-title>
          .
          <source>In:Applied Intelligence</source>
          <volume>31</volume>
          .1 (
          <issue>Aug</issue>
          .
          <year>2009</year>
          ), pp.
          <fpage>47</fpage>
          -
          <lpage>68</lpage>
          . issn:
          <fpage>1573</fpage>
          -
          <lpage>7497</lpage>
          . doi:
          <volume>10</volume>
          . 1007 / s10489 - 007 - 0111 - x. url: https : / / doi . org / 10 . 1007 / s10489 - 007 - 0111 - x (visited on 07/30/
          <year>2020</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [32]
          <string-name>
            <surname>Zhi-Hua</surname>
            <given-names>Zhou</given-names>
          </string-name>
          , Kai Jiang, and
          <string-name>
            <given-names>Ming</given-names>
            <surname>Li</surname>
          </string-name>
          .
          <article-title>“MultiInstance Learning Based Web Mining”</article-title>
          .
          <source>InA:pplied Intelligence</source>
          <volume>22</volume>
          .2 (
          <issue>Mar</issue>
          .
          <year>2005</year>
          ), pp.
          <fpage>135</fpage>
          -
          <lpage>147</lpage>
          . issn:
          <fpage>1573</fpage>
          -
          <lpage>7497</lpage>
          . doi:
          <volume>10</volume>
          .1007/s10489-005-5602-z. url: https://doi.org/10.1007/s10489-005- 5602-z (visited on 01/01/
          <year>2020</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [33]
          <string-name>
            <surname>Zhi-Hua</surname>
            <given-names>Zhou</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Yu-Yin Sun</surname>
          </string-name>
          , and
          <string-name>
            <surname>Yu-Feng Li</surname>
          </string-name>
          .
          <article-title>“Multi-Instance Learning by Treating Instances As Non-I.I.D. Samples”</article-title>
          .
          <source>In:Proceedings of the 26th International Conference On Machine Learning, ICML 2009 (July</source>
          <year>2008</year>
          ).doi:
          <volume>10</volume>
          .1145/1553374. 1553534.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>