<!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>CAPS-PRC: A System for Personality Recognition in Programming Code</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Notebook for PAN at FIRE</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
          <xref ref-type="aff" rid="aff3">3</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Benjamin Roth Center for Information and Language Processing Ludwig Maximilian University of Munich Oettingenstr. 67 Munich</institution>
          ,
          <addr-line>Germany muenchen.de</addr-line>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Eduard Saller Center for Information and Language Processing Ludwig Maximilian University of Munich Oettingenstr. 67 Munich</institution>
          ,
          <country country="DE">Germany</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Ivan Bilan Center for Information and Language Processing Ludwig Maximilian University of Munich Oettingenstr. 67 Munich</institution>
          ,
          <country country="DE">Germany</country>
        </aff>
        <aff id="aff3">
          <label>3</label>
          <institution>Mariia Krytchak Department of Psychology Ludwig Maximilian University of Munich Leopoldstr. 13 Munich</institution>
          ,
          <country country="DE">Germany</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>This paper describes the participation of the CAPS-PRC system developed at the LMU Munich in the personality recognition shared task (PR-SOCO) organized by PAN at the FIRE16 Conference. The machine learning system uses the output of a Java code analyzer to investigate the structure of a given program, its length, its average variable length and also it takes into account the comments a given programmer wrote. The comments are analyzed by language independent stylometric features, including TF-IDF distribution, average word length, type/token ration and more. The system was evaluated using Root Mean Squared Error (RMSE) and Pearson Product-Moment Correlation (PC). The best run exhibited the following results: Neuroticism (RMSE - 10.42, PC - 0.04), Extroversion (RMSE - 8.96, PC - 0.16), Openness (RMSE - 7.54, PC - 0.1), Agreeableness (RMSE - 9.16, PC - 0.04), Conscientiousness (RMSE - 8.61, PC - 0.07).</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>machine learning; Big Five personality traits; source code
analysis; abstract syntax tree</p>
    </sec>
    <sec id="sec-2">
      <title>INTRODUCTION</title>
      <p>
        The main purpose of the task is to investigate whether
it is possible to predict personality traits of programmers
based on the source code written by them [
        <xref ref-type="bibr" rid="ref7">8</xref>
        ]. Previous
research has identi ed the relationship between personality
factors and computer programming styles having used
different measures of personality [
        <xref ref-type="bibr" rid="ref1">2</xref>
        ] [
        <xref ref-type="bibr" rid="ref3">4</xref>
        ]. The task considers
the Big Five personality traits which were assessed by the
NEO-PI-R Inventory [
        <xref ref-type="bibr" rid="ref4">5</xref>
        ] to form the training set [
        <xref ref-type="bibr" rid="ref7">8</xref>
        ]:
extroversion, emotional stability/neuroticism, agreeableness,
conscientiousness, and openness to experience. The Big Five
Model, i.e. ve broad fairly independent dimensions,
encompasses all personality traits and is considered to describe the
personality in a comprehensive way. The NEO-PI-R
Inventory is a statistically reliable and valid tool that
operationalizes the Big Five Model through self/other-assessment and is
set in various cross professional and cross cultural contexts
to describe the personality.
2.
2.1
      </p>
    </sec>
    <sec id="sec-3">
      <title>EXPERIMENTAL SETUP</title>
    </sec>
    <sec id="sec-4">
      <title>Approaching the problem</title>
      <p>
        Based on the available research on the Big Five
psychological traits [
        <xref ref-type="bibr" rid="ref4">5</xref>
        ] [
        <xref ref-type="bibr" rid="ref2">3</xref>
        ], we can see that the traits are considered to
be independent of each other. For this reason, each
psychological trait was viewed and analyzed individually. Figures
1 to 5 show the distribution of the training set for each
psychological trait by author. Table 1 shows the mean trait
distribution.
      </p>
      <p>Since each programmer/author has submitted more than
one program, we approach the problem from two di erent
angles:</p>
      <p>1) the feature vectors are extracted for each programmer,
by rst extracting them for each program and then
averaging all the underlying feature vectors into one single feature
vector for the author. The classi er learns based on a single
feature vector for each author, where the author represents
one sample in the dataset.</p>
      <p>2) the classi er is trained at the level of programs. Each
program inherits the trait value of its author. The feature
vectors are extracted for each program and then the classi er
regards each program as a training instance. To get back to
the level of authors (while the nal prediction should be
done for the author), the predictions are averaged for each
program belonging to a certain author. The nal result is
a single prediction for each author based on the predictions
produced for each underlying program.
2.2</p>
    </sec>
    <sec id="sec-5">
      <title>Feature Extraction</title>
      <p>2.2.1</p>
      <sec id="sec-5-1">
        <title>Abstract syntax tree</title>
        <p>We use a grammar speci cally designed for the
analysis of a programming language , which in the context of
the task was the Java programming language. The
grammar combined with a parser provides a semantic
representation of the source code called an abstract syntax tree
(AST). Compared to normal parse trees there are some
potential advantages. First, the generation of an AST can
be interpreted as a normalization step of our feature
generation. In contrast to the original source code, which has
inconsistencies like whitespace characters or other unneeded
characters, the AST represents a concise version of a given
program. This also makes the generation of meta-features
(compositions of di erent base features) more simple, due to
the strict representation of all, to the compiler important,
parts of the program. Additionally, the representing
syntax tree is not necessarily bound by the original syntactic
rules of the original programming language which allows
for generalizations of the source code to occur.</p>
        <p>
          In our approach, we use the frequency distribution of all
known entities in the grammar to build a feature list for a
given program. This shallow use of the AST provides 237
features for a given source code analysis. Some examples
would be the T ype of variables or the nature of a
statement(do, for, while, etc.) The implementation of the AST
is made possible with the help of ANTLR parser [
          <xref ref-type="bibr" rid="ref5">6</xref>
          ].
2.2.2
        </p>
      </sec>
      <sec id="sec-5-2">
        <title>Custom Features</title>
        <p>In addition to the AST, we used additional features for
the source code and also the comments. The following is an
exhaustive list of all additional features used.</p>
        <p>Code-based features: length of the whole program (in
lines of code, in characters), the average length of variable
names, what indentation the programmer is using (tabs or
spaces).</p>
        <p>Comment-based features: type/token ratio, usage of
punctuation marks, TF-IDF, the frequency of comments
(block comments and inline comments separately), average
word length.</p>
        <p>Author-level based features: number of programs
submitted (see Table 2), average length of programs in lines of
code.
2.3</p>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>Classification</title>
      <p>We experimented with a number of Regression classi ers
like Linear Regression, Ridge Regression, Logistic
Regression and Gradient Boosted Regression. In addition, we have
tried to detect the outliers with the RANdom SAmple
Consensus (RANSAC). The nal system implementation did not
use RANSAC, since it delivered worse results. Although,
this technique should be further investigated with a bigger
dataset.</p>
      <p>We have submitted our nal runs based on two machine
learning algorithms: Gradient Boosted Regression and
Multinomial Logistic Regression. Furthermore, Gradient Boosted
Regression was evaluated on the level of authors and the
programs level, while the Multinomial Logistic Regression</p>
      <sec id="sec-6-1">
        <title>Agreeableness</title>
        <p>Conscientiousness</p>
        <p>Extroversion
Neuroticism</p>
        <p>Openness
was implemented on the level of authors.</p>
        <p>
          The rst classi cation approach is based on Gradient Boosted
Regression with least squares regression as its loss function,
1100 estimators, 5 as the maximum depth of the
individual regression estimators, and the learning rate of 0.1. This
approach also utilized 2 test for the feature selection to
choose only the best 200 features from the AST feature
extraction pipeline. This approach was implemented using the
scikit-learn Python library [
          <xref ref-type="bibr" rid="ref6">7</xref>
          ].
        </p>
        <p>The second approach is based on the Multinomial Logistic
Regression model with the l2-regularized squared loss as its
objective function. That is, each feature was multiplied with
a trait-speci c weight, and the result of this linear
combination was the input to a sigmoid activation. As the output
of this prediction is in the range [0,1], we re-scaled the trait
values in the training data to the same range for computing
the squared loss.</p>
        <p>Training was done using stochastic gradient descent with
constant learning rate, and parameters were tuned on the
held-out development set using random search. The search
space of the parameters was: learning rate 2 0:01; 0:1; 1,
number of training epochs 2 f10; 20; 50; 100; 200; 500g,
regularization 2 f0; 0:001; 0:01; 0:1; 1g, (mini-)batch size 2 f1; allg.
The best con guration was: learning rate: 1, training-epochs:
2, regularization: 0.6, batch-size: all. This approach was
developed with theano Python library [1].
3.</p>
      </sec>
    </sec>
    <sec id="sec-7">
      <title>EXPERIMENTAL RESULTS</title>
      <p>The dataset included 49 programmers in the training set
(with 1790 programs in total) and 22 programmers in the
test set (772 programs). Final evaluation was done with
two di erent evaluation metrics: Root Mean Squared Error
(RMSE) and Pearson Product-Moment Correlation (PC).
In the Gradient Boosted Regression approach (GBR
Approach), the system was tuned to maximize both of these
metrics at the same time, while the Multinomial Logistic
Regression one (MLR Approach) concentrated on RMSE.
Table 3 gives a detailed overview of the results achieved using
Multinomial Logistic Regression at the level of authors.
Table 4 shows the results achieved using the Gradient Boosted
Regression approach at the level of authors and the level of
programs.</p>
      <p>
        In general, the results are low using both RMSE and PC
and only slightly outperform the performance of the baseline
approaches (see Table 5). Two baselines have been provided
by the task organizers [
        <xref ref-type="bibr" rid="ref7">8</xref>
        ]:
1) 3-gram character representation.
      </p>
      <p>2) always predict the mean trait value of the training
dataset.</p>
      <sec id="sec-7-1">
        <title>Agreeableness</title>
        <p>Conscientiousness
Extroversion
Neuroticism</p>
        <p>Openness</p>
      </sec>
    </sec>
    <sec id="sec-8">
      <title>CONCLUSIONS</title>
      <p>This paper describes the system that given a source code
collection of a programmer, identi es their personality traits.
While the RMSE and PC scores proved promising during
development, further investigation suggested the dataset may
be too small to create an e ective machine learning system.
The compiler style feature generation process using ASTs
combined with several custom features could serve as future
baselines for similar tasks.
4.1</p>
    </sec>
    <sec id="sec-9">
      <title>Future Work</title>
      <p>The task would bene t greatly from an expanded training
corpus (more samples per programmer, more programmers).
The value distribution of the training set is also an important
point. The current training set exhibits normal distributed
scores for each Big Five trait. A more robust system could
be created when using an equal number of samples within
low, mid and high value range.</p>
      <p>Additionally, further feature engineering, additional
statistical analysis of the AST output, and transferring
strategies of other NLP tasks involving syntax trees onto the
current task could improve the system.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>C.</given-names>
            <surname>Bishop-Clark</surname>
          </string-name>
          .
          <article-title>Cognitive style, personality, and computer programming</article-title>
          .
          <source>Computers in Human Behavior</source>
          ,
          <volume>11</volume>
          (
          <issue>2</issue>
          ):
          <volume>241</volume>
          {
          <fpage>260</fpage>
          ,
          <year>1995</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>O. P.</given-names>
            <surname>John</surname>
          </string-name>
          and
          <string-name>
            <given-names>S.</given-names>
            <surname>Srivastava</surname>
          </string-name>
          .
          <article-title>The big ve trait taxonomy: History, measurement, and theoretical perspectives</article-title>
          .
          <source>Handbook of personality: Theory and research</source>
          ,
          <volume>2</volume>
          (
          <year>1999</year>
          ):
          <volume>102</volume>
          {
          <fpage>138</fpage>
          ,
          <year>1999</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>Z.</given-names>
            <surname>Karimi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Baraani-Dastjerdi</surname>
          </string-name>
          ,
          <string-name>
            <surname>N.</surname>
          </string-name>
          <article-title>Ghasem-Aghaee, and</article-title>
          <string-name>
            <given-names>S.</given-names>
            <surname>Wagner</surname>
          </string-name>
          .
          <article-title>Links between the personalities, styles and performance in computer programming</article-title>
          .
          <source>Journal of Systems and Software</source>
          ,
          <volume>111</volume>
          :
          <fpage>228</fpage>
          {
          <fpage>241</fpage>
          ,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>F.</given-names>
            <surname>Ostendorf</surname>
          </string-name>
          and
          <string-name>
            <given-names>A.</given-names>
            <surname>Angleitner. Neo-PI-R:</surname>
          </string-name>
          Neo-Perso
          <article-title>nlichkeitsinventar nach Costa und McCrae</article-title>
          .
          <source>Hogrefe</source>
          ,
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>T.</given-names>
            <surname>Parr</surname>
          </string-name>
          .
          <article-title>The de nitive ANTLR 4 reference</article-title>
          .
          <source>Pragmatic Bookshelf</source>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>F.</given-names>
            <surname>Pedregosa</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Varoquaux</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Gramfort</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Michel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Thirion</surname>
          </string-name>
          ,
          <string-name>
            <given-names>O.</given-names>
            <surname>Grisel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Blondel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Prettenhofer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Weiss</surname>
          </string-name>
          ,
          <string-name>
            <given-names>V.</given-names>
            <surname>Dubourg</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Vanderplas</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Passos</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Cournapeau</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Brucher</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Perrot</surname>
          </string-name>
          , and
          <string-name>
            <given-names>E.</given-names>
            <surname>Duchesnay</surname>
          </string-name>
          .
          <article-title>Scikit-learn: Machine learning in python</article-title>
          .
          <source>J. Mach. Learn. Res.</source>
          ,
          <volume>12</volume>
          :
          <fpage>2825</fpage>
          {
          <fpage>2830</fpage>
          ,
          <string-name>
            <surname>Nov</surname>
          </string-name>
          .
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>F.</given-names>
            <surname>Rangel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Gonzalez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Restrepo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Montes</surname>
          </string-name>
          , and
          <string-name>
            <given-names>P.</given-names>
            <surname>Rosso</surname>
          </string-name>
          . Pan at re:
          <article-title>Overview of the pr-soco track on personality recognition in source code</article-title>
          .
          <source>In Working notes of FIRE 2016 - Forum for Information Retrieval Evaluation</source>
          , Kolkata, India, December 7-
          <issue>10</issue>
          ,
          <year>2016</year>
          ,
          <string-name>
            <given-names>CEUR</given-names>
            <surname>Workshop</surname>
          </string-name>
          <article-title>Proceedings</article-title>
          . CEUR-WS.org,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>