<!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>Local n-grams for Author Identification</article-title>
      </title-group>
      <contrib-group>
        <aff id="aff0">
          <label>0</label>
          <institution>Internet Commerce Security Laboratory University of Ballarat</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Robert Layton</institution>
          ,
          <addr-line>Paul Watters, and Richard Dazeley</addr-line>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2013</year>
      </pub-date>
      <abstract>
        <p>Our approach to the author identification task uses existing authorship attribution methods using local n-grams (LNG) and performs a weighted ensemble. This approach came in third for this year's competition, using a relatively simple scheme of weights by training set accuracy. LNG models create profiles, consisting of a list of character n-grams that best represent a particular author's writing. The use of a weighted ensemble improved upon the accuracy of the method without reducing the speed of the algorithm; the submitted solution was not only near the top of the leaderboard in terms of accuracy, but it was also one of the faster algorithms submitted.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>Authorship attribution for a test document is performed by comparing the profile
for the document with the profiles of each of the candidate authors using equation 1 (
where Pi(x) is the frequency of n-gram x for a given profile). The most similar profile
is considered the author of the test document.
(1)
dK (P1; P2) =</p>
      <p>X
2 (P1(x)</p>
      <p>P2(x)) !2</p>
      <p>
        P1(x) + P2(x)
x2XP1 [XP2
[
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] identified that a much simpler algorithm was capable of comparable results,
called Source Code Author Profiling (SCAP). Rather than use the frequency of the
most frequent n-grams, two profiles are compared simply by the size of the intersection
of the n-grams in the profiles. While this does reduce the accuracy, the net result is often
quite small and the algorithm is significantly faster. As an empirical result, our code for
CNG performs a profile comparison in about three milliseconds, while for SCAP it is
less than one millisecond (our testing framework does not give better precision).
      </p>
      <p>
        Further variations were developed by [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ], who focused on variations of CNG for
unbalanced datasets. The first variation, d1 has a single subtle change, using only the
n-grams in the test document for comparison. The second variation, d2 proposed in [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ]
is to use a training corpus profile, called PC , which is composed of all the documents
in the training set. The distance is given as the dot product of the d1 distance from the
document to author and the d1 distance of the document to the language profile. These
alterations to CNG proved to be more accurate than ‘standard’ CNG when there was
a limited number of documents for an author. However when an adequate number of
documents per author is reached, the results reverse and standard CNG, using equation
1, proves to be more accurate.
      </p>
      <p>
        Another variation was developed by [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ] named Recentred Local Profiles (RLP).
While the distance metric was different from CNG and SCAP, using a variation of the
cosine distance metric, the main difference was the use of a language default value,
similar to [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ]. Rather than profile using the most frequent n-grams for an author or
document, the most distinctive n-grams are chosen. An n-gram is more distinctive than
another if the absolute distance to the expected value for the language is higher. The
expected value for an n-gram can be calculated from a corpus of text in the language,
and has the benefit of being able to use unlabelled data. RLP was shown to have a high
quality on many datasets, including the AAAC corpus [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ].
      </p>
      <p>
        LNG methods have been used for a significant number of tasks. Some successful
applications include authorship of twitter posts [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ], student coding essays [
        <xref ref-type="bibr" rid="ref2 ref3">2,3</xref>
        ], software
forensics [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], internet relay chat logs [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ], malware profiling [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] and has been extended
into automated unsupervised applications [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ]. LNG based approaches are highly
applicable to any language, as the notion of a character is quite prolific. In cases where a
character can be hard to define, often examining the bytes of a representation (such as
unicode) can provide an adequate substitution [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ].
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Methodology</title>
      <p>The LNG methods described in the literature are mostly developed for authorship
attribution and not authorship identification. Intuitively, we created an algorithm that
identifies if the test document compares to the training set in the same way as documents in
the training set compare to each other - i.e. if it looks like a training document, it was
probably written by the same person. To convert the methods to an authorship
identification task, we applied the following procedure.
1. Calculate the pairwise distance between all documents in the training set and call
this distribution du.
2. Calculate the distance between the test document and each of the training
documents, and call this distribution dt.
3. Compute the number of elements in dt that are less than the mean of du and call
this p.
4. If p &lt; t for some t (set to 0.5 by default), then the test document is considered a
match. Otherwise, it is not a match.</p>
      <p>Formally, a ‘problem’ is defined as a set of documents from the same author (the
training set) and a document of unknown authorship (the test document). The aim is to
determine if the author of the training set wrote the test document.</p>
      <p>
        The ensemble method was inspired by [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], which used a weighted voting model
with local n-grams, including a ‘reject’ option, indicating if no match was found. In
that work, a large number of CNG models were used with different parameters, and the
weights were assigned based on the ratio r = 1 ab , where a is the distance between the
test profile and the best matching author profile and b is the distance to the second best.
Note that this application is valid for authorship attribution tasks, and not for authorship
identification, as we only have one candidate author.
      </p>
      <p>Instead, the method we used was to assign each model a weight according to its
accuracy in the training set. Any model with a weight of less than 0.4 is reduced to 0.
The reason for this is that in the author identification task, there are only two
possible answers - match or no match. This gives a baseline accuracy of 0.5, assuming the
test dataset contains equal numbers of problems of each type. We decided that models
scoring under 0.4 were a hindrance rather than a help.</p>
      <p>To summarise, out approach was to use a set of LNG models and ask each whether
they thought the document was from the same author or not. This used the approach
given in section 2. Each model’s prediction was weighted according to their accuracy in
the training set, with models scoring less than 0.4 given a weight of 0. The weights for
both options (match or no match) were summed and the option with the highest weight
was chosen as the final answer. The models included in the ensemble were the CNG,
SCAP, RLP, d1 and d2 models. The parameters were n 2 f3; 4; 5g and L = 1000 for
each of the five models. We hypothesise that a larger number of models would have
improved accuracy, but was not able to test this hypothesis for this competition.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Results</title>
      <p>The competition organisers released a set of problems for training, which were used in
a cross-fold methodology to evaluate the algorithms. The results for each fold are given
in table 3 and the overall accuracy was 71.25%. For the competition, the algorithm
achieved and f1-score of 0.671, which placed it in third. In addition, the algorithm was
the forth fastest in the competition.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Alazab</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Layton</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Venkataraman</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Watters</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          :
          <article-title>Malware detection based on structural and behavioural features of api calls (</article-title>
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Burrows</surname>
            ,
            <given-names>S.:</given-names>
          </string-name>
          <article-title>Source Code Authorship Attribution</article-title>
          .
          <source>Ph.D. thesis</source>
          , RMIT University (
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Burrows</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Uitdenbogerd</surname>
            ,
            <given-names>A.L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Turpin</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>Application of information retrieval techniques for source code authorship attribution</article-title>
          .
          <source>In: Database Systems for Advanced Applications</source>
          . pp.
          <fpage>699</fpage>
          -
          <lpage>713</lpage>
          . Springer (
          <year>2009</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Frantzeskou</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gritzalis</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Macdonell</surname>
            ,
            <given-names>S.G.</given-names>
          </string-name>
          :
          <article-title>Source code authorship analysis for supporting the cybercrime investigation process</article-title>
          .
          <source>In: Proceedings of the first International Conference on e-business and Telecommunications Networks (ICETE04)</source>
          , Vol. pp.
          <fpage>85</fpage>
          -
          <lpage>92</lpage>
          (
          <year>2004</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Frantzeskou</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Stamatatos</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gritzalis</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Chaski</surname>
            ,
            <given-names>C.E.</given-names>
          </string-name>
          :
          <article-title>Identifying authorship by bytelevel n-grams: The source code author profile (SCAP) method</article-title>
          .
          <source>Int. Journal of Digital Evidence</source>
          <volume>6</volume>
          (
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Frantzeskou</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Stamatatos</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gritzalis</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          :
          <article-title>Supporting the cybercrime investigation process: effective discrimination of source code authors based on byte-level information</article-title>
          .
          <source>In: E-business and Telecommunication Networks</source>
          , pp.
          <fpage>163</fpage>
          -
          <lpage>173</lpage>
          . Springer (
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Juola</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          :
          <article-title>Ad-hoc Authorship Attribution Competition</article-title>
          .
          <source>In: Proceedings of 2004 Joint International Conference of the Association for Literary</source>
          and
          <article-title>Linguistic Computing and the Association for Computers and the Humanities (ALLC/ACH</article-title>
          <year>2004</year>
          )
          <article-title>(</article-title>
          <year>2004</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Kešelj</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cercone</surname>
          </string-name>
          , N.:
          <article-title>Cng method with weighted voting</article-title>
          . In: P. Joula,
          <article-title>Ad-hoc Authorship Attribution Competition (ALLC/ACH</article-title>
          <year>2004</year>
          ), Göteborg, Sweden (
          <year>2004</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Kešelj</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Peng</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Cercone</surname>
          </string-name>
          , N.,
          <string-name>
            <surname>Thomas</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          :
          <article-title>N-gram-based author profiles for authorship attribution</article-title>
          .
          <source>In: Proceedings of the Pacific Association for Computational Linguistics</source>
          (
          <year>2003</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Layton</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>McCombie</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Watters</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          :
          <article-title>Authorship attribution of irc messages using inverse author frequency</article-title>
          .
          <source>In: Cybercrime and Trustworthy Computing Workshop (CTC)</source>
          ,
          <year>2012</year>
          Third. pp.
          <fpage>7</fpage>
          -
          <lpage>13</lpage>
          . IEEE (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Layton</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Watters</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dazeley</surname>
          </string-name>
          , R.:
          <article-title>Authorship attribution for twitter in 140 characters or less</article-title>
          .
          <source>In: 2010 Second Cybercrime and Trustworthy Computing Workshop</source>
          . pp.
          <fpage>1</fpage>
          -
          <lpage>8</lpage>
          . IEEE (
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>Layton</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Watters</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dazeley</surname>
          </string-name>
          , R.:
          <article-title>Automated unsupervised authorship analysis using evidence accumulation clustering</article-title>
          .
          <source>Natural Language Engineering</source>
          , Available on CJO (
          <year>2011</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <surname>Layton</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Watters</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dazeley</surname>
          </string-name>
          , R.:
          <article-title>Recentred Local Profiles for Authorship Attribution</article-title>
          .
          <source>Journal of Natural Language Engineering</source>
          (
          <year>2011</year>
          ), available on CJO 2011
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <surname>Stamatatos</surname>
          </string-name>
          , E.:
          <article-title>Author identification using imbalanced and limited training texts</article-title>
          .
          <source>In: Database and Expert Systems Applications</source>
          ,
          <year>2007</year>
          . DEXA'
          <volume>07</volume>
          . 18th International Workshop on. pp.
          <fpage>237</fpage>
          -
          <lpage>241</lpage>
          . IEEE (
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>