<!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>A Comparison of Machine Learning Methods of Sentiment Analysis Based on Russian Language Twitter Data</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Andrey Zvonarev[</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>] vodogrey@niuitmo.ru</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Andrey Bilyi[</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>] bilyi andrei@mail.ru</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>ITMO University</institution>
          ,
          <addr-line>49 Kronverksky Pr., St. Petersburg, 197101</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>The paper is focused on comparing the performance of different techniques of text tonality analysis, a widely used approach in business to conduct social listening research. However, there are still debates on what type of models perform better for NLP classi cation tasks. On a corpus of Russian language tweets three models were tested to solve binary classi cation problem: Logistic regression (LR), XGBoost classier and Convolutional Neural Network (CNN). The paper descriptively overviews main techniques useful for data cleaning and preprocessing for these methods and covers its possible tfalls. Based on the study CNN showed best results among chosen models, which goes in line with several articles in the eld for other than Russian languages. Together with high predictive results, neural networks exhibit a computational drawback their performance is poor in terms of timings. Besides this, all methods showed high sensitivity to the way data is preprocessed, which is a product of Russian language variability. This leads to a conclusion that there is still a room for improvement - in future research more emphasis will be put on hyper parameter tuning for "boosting type" models and extending list of applied methods.</p>
      </abstract>
      <kwd-group>
        <kwd>text tonality</kwd>
        <kwd>sentiment analysis</kwd>
        <kwd>logistic regression</kwd>
        <kwd>CNN</kwd>
        <kwd>XGBoost</kwd>
        <kwd>natural language processing</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Field overview and prediction task description</title>
      <p>Nowadays, more and more communication, services and goods transfer to the
Internet where the information is basically provided in the form of text. In this
regard, the task of determining the emotional state of a person without personal
communication is becoming increasingly crucial. The perspectives of this eld
are that, based on the textual information, it is possible to determine a mood of
a person, or to estimate a success of political or economic reforms, or to check
person's reaction to particular event or decision.</p>
      <p>Copyright c 2019 for this paper by its authors. Use permitted under Creative
Commons License Attribution 4.0 International (CC BY 4.0).</p>
      <p>Due to in practice it is not possible to identify the emotional coloring of
large number of texts available in the Internet manually and, in addition, it
is too labor-intensive, one of the possible ways to solve this problem is to use
machine learning algorithms.</p>
      <p>
        At the moment, there are several key methodologies for determining
emotional coloring of the text:
{ Analysis using pre-complied dictionary[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. Such dictionaries consist of
pre-prepared template words, phrases and their combinations with emotional
coloring characteristic of each element. Moreover, for determining emotional
coloring with improved accuracy of tonality assessment corpus linguistics can
be used[
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. Nevertheless, in paper[
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], the authors encountered di erences in
the expression of emotions in English and Russian languages when using
a bilingual corpus. The positive experience of translation of dictionaries is
presented in the paper[
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], where the authors translated the dictionary of
emotionally colored vocabulary in English into Chinese. The assessment is
made on set of positive and negative patterns found. With the explicit
allocation of one of them to the text or passage, the class that scored more
points is set. If there is no obvious predominance, the rating is set to neutral.
The main disadvantage is the procedure for compiling glossaries of terms
indicating the weight of phrases. Also, these dictionaries must be prepared for
a speci c area.
{ Analysis with the use of machine learning methods has recently
become the most widespread because of reducing the in uence factor of
human impact on the assessment. In comparison with pre-complied dictionary
method where the assessment is set by person, the assessment in machine
learning method is set by independently identi ed patterns in the text even
with achieving recognizing sarcasm and irony.
      </p>
      <p>This paper compares several machine learning techniques to solve binary
classi cation problem of text tonality analysis. The dataset used for this task is
a corpus of Russian language tweets. After several data cleaning stages logistic
regression (LR), XGBoost classi er and convolutional neural network (CNN) are
applied. The study compares those models in terms of accuracy and F1 score
and discusses possible pros and cons for these methods.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Data preprocessing and models overview</title>
      <p>
        Proposed methods are based on the use of machine learning methods. The
developed prototype allows to assess texts as `positively' or `negatively' coloured.
To train these models a set of short texts were collected. Using RuTweetCorp[
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]
dataset, which is a unique source of Russian-language tweets, collected via
twitter API interface. The dataset is valuable for being a single open source
collection of Russian language texts on the market with prede ned texts tonality.
RuTweetCorp's database allows Russian researchers to test modern modelling
approaches of NLP on their native language corpus. The dataset of 225 000
tweets2 was randomly split to the training set (70%) and test set (30%).
2.1
      </p>
      <sec id="sec-2-1">
        <title>Data cleaning and preparation</title>
        <p>
          Before applying discussed above methods, data cleaning stage should be
completed. To prepare the dataset for the models I used in the paper several classical
for the industry approaches are applied:
{ Capitalisation. The purpose of this stage is to make a proper text cleaning
and frequency calculation. Actually it makes no di erence what type of
register level to use for the modelling since, mathematically, models' algorithms
transform words into digits, thus any case type can be chosen. In the current
paper I have used lowercase register;
{ Punctuation cleaning. As a part of data preprocessing researchers usually
drop all punctuation marks, digits, links, etc. from texts since in most of the
times it does not give any impact on emotional meaning of tweets. Another
e ect of these symbols on the analysis is irrelevant results in terms of word
frequencies and a nities. Punctuation marks are comparatively often appear
in sentences which leads to extremely high metrics for them while in reality
these symbols almost always make no impact on text tonality;
{ Lemmatisation. Other well-known in the industry approaches to reduce
the number of words carrying similar emotional meanings are lemmatisation
and stemming. Both of these methods transform words from its full form
into their short parent version. The di erence between methods is that
lemmatisation derives an in nitive form of the words while stemming simply
cuts beginnings and endings of words to obtain a root. In the current paper
I use lemmatisation as I believe it to be more e cient[
          <xref ref-type="bibr" rid="ref6">6</xref>
          ];
{ Stop-words deletion. Next step making data less noisy is dropping
socalled stop-words from the dataset. \Stop-words"[
          <xref ref-type="bibr" rid="ref7">7</xref>
          ] are words that extremely
frequently appear in text but make no impact on text meanings. Classical
examples of such words are articles (such as the, is, at, which, and on).
Another type of such words may be swear words, which may have one in nitive
form but tens of word variations with both positive and negative meanings.
        </p>
        <p>
          Besides well-known in literature methods of texts cleaning in current paper I
have followed additional step improving algorithm performance - concatenation
of word \not" with the following one. It is intuitively understandable that the
negation word \not" can signi cantly change the emotional meaning of a tweet.
However, it was practically revealed that analysed models captured high
correlation between \not"[
          <xref ref-type="bibr" rid="ref8">8</xref>
          ] word and negative target value, which afterwards resulted
in high share of incorrect \negative" predictions. To overcome this issue I have
concatenated the word \not" with the following one and used it as a new word,
which led to performance growth.
2 Out of which `obviously positive' (114,911 records) and `obviously negative' (111,923
records.) observations
        </p>
        <p>Having done all that, tweets have been transformed to vectors consisting of
cleaned in nitives of words. This still resulted in huge amount of unique words,
which led to high memory and time consumption, while big chunk of words did
not give any impact on model score. To optimise the modelling process words
with frequency less than 3 were dropped. After that, a dictionary was created,
which included remaining words to which a unique ID was assigned. Using such
dictionary we have prepared two input datasets:
{ For LR and XGBoost: a TF-IDF matrix (term frequency-inverse
document frequency), which is a method of "Bag of words"(BoW) class. While
term frequency denotes how many times a word is in a document (in one
piece of text input), inverse document frequency calculates number of
documents where a text has appeared and number of total documents in data.
In this method all the words in the data are transformed into a list.
Afterwards all the words in this list are assigned to each document as a vector.
For example if there is a dataset of 5000 words, each document has a vector
of 1 row and 5000 columns. Each column in this vector de nes a word. If
the word appears in the document, number of times the word is present in
the text is assigned to the column corresponding to that word. When this
process is done for all documents, illustration of data as per text frequency is
obtained. Inverse Document Frequency (IDF) is calculated by using number
of documents where a term has appeared and total number of documents in
the data.
{ For CNN input: a Document-Term Matrix of special form - rows of this
matrix were corresponding to tweet ID, columns corresponded to the position
of the word in a tweet, while in each cell of the matrix were written an ID of
the word from dictionary. Such matrix may have large number of columns
in case of presence of very long texts. This leads to high memory and time
consumption during computation. To reduce the time, the matrix were cut
to 23 columns, which signi cantly improved model calculation time on one
side and left all relevant information on another (23 columns cover 99.65%
of all tweet lengths)
2.2</p>
      </sec>
      <sec id="sec-2-2">
        <title>Models description</title>
        <p>For the purpose of the analysis we have tested several machine learning
methods and compared its e ciency (more on this in section 3). We have compared
three typical models in the text mining eld to conduct semantic analysis of
texts: logistic regression, XGboost and CNN. Short overview of these methods
is provided below.</p>
        <p>
          Logistic regression This is a well known approach used to solve binary
classi cation problems.[
          <xref ref-type="bibr" rid="ref9">9</xref>
          ] Text mining is just one of many elds where logistic
regression may be applied once the task can be transformed to binary classi
cation type. Basically, the idea behind the method is to calculate the probability
of tweet to be positive based on rules identi ed on a large set of data. Since the
probability function (1) has a logistic form the model also got its name:
f (z) =
        </p>
        <p>
          1
1 + e x
(1)
where z is a set of model input factors (in our case these are vectors of TF-IDF
matrix). More on this type of regression is given by Cramer[
          <xref ref-type="bibr" rid="ref10">10</xref>
          ].
        </p>
        <p>
          XGBoost Another model we have decided to test on the dataset is
XGBoost, which is highly credited by machine learning competitors[
          <xref ref-type="bibr" rid="ref11">11</xref>
          ]. This
software nowadays exists for all popular data analysis languages and provides
gradient boosting framework. XGBoost is used both for regression and classi cation
problems, thus is expected to perform considerably well on binary classi cation
problem and data we use in the current paper. More on the method is in original
paper by Chen and Guestrin[
          <xref ref-type="bibr" rid="ref12">12</xref>
          ].
        </p>
        <p>
          Convolutional Neural Network (CNN) The last but not least model
type we have tested on the dataset is a CNN. Neural networks recently got high
attention among data scientist due to ability to solve almost any type of problem
once it is stated correctly. Text mining is one of the elds, where CNN showed
high performance[
          <xref ref-type="bibr" rid="ref13">13</xref>
          ].
3
        </p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Results and discussion</title>
      <p>
        To test the results of models performance we estimate shares of correct and
incorrect predictions on train and test set. It is a practical and reliable way
to deal with over- and under- tting. To measure the learning performance of
methods we use accuracy and F1-score metrics. These two metrices were chosen
based on research in the literature for binary classi cation[
        <xref ref-type="bibr" rid="ref14">14</xref>
        ].
      </p>
      <p>Below we demonstrate obtained results for all three models. Table 1 shows
Logistic Regression results:</p>
      <p>Based on the results one can make a conclusion, that model is over- tted.
This is for sure not a good sign, however, it can be ne-tuned by changing
hyperparameters of the model and using cross-validation techniques. Overall, the score
on test is considerably high. Another think to note - training of logistic regression
take very small amount of time. This makes the method a good starting model
to test how data preparation stages in uence model performance.</p>
      <p>XGBoost training took much more time. Results you can see in the table
below.</p>
      <p>This model shows worse results than logistic regression. Probably, it
happened because it needs a better setup of hyper parameters. Since in literature
XGBoost proved to be one of the best models for these type of tasks, we are
motivated to pay more attention to work with this model in the future.
The paper provides with results of applying di erent machine learning
techniques to solve the text tonality binary classi cation task. Three model types
were estimated: logistic regression, XGBoost classi er and convolutional neural
network. Each of them are well-known models among data scientists to solve
tasks of that type. However, not that much studies exist where those models are
applied and compared on social networks data and Russian language. Results
demonstrate that based on F1 measure CNN performs better. However, training
such a model needs much more time than LR. Hence, depending on available
time and computing power for modelling LR may be preferred. Also, it was
a surprise that XGBoost classi er showed signi cantly lower result than other
models, while the framework demonstrated high performance on many data
science competitions. We suspect that more time should be spent to nd optimal
hyper parameters of the model.</p>
      <p>For future research we are planning to extend the number of models tested
at least, LightGBM and Word2Vec models are interesting frameworks showing
good results for this type of problems. Besides that, more focus will be allocated
on optimal hyper parameters search, cross-validation techniques and stacking of
models. These we believe will lead to even greater model performance.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Alexeeva</surname>
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Koltsova</surname>
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Koltcov</surname>
            <given-names>S</given-names>
          </string-name>
          .
          <article-title>Linis-crowd.org: A lexical resource for Russian sentiment analysis of social media [Linis-crowd.org: lexicheskij resurs dl'a analiza tonal'nosti sotsial'no-politicheskix tekstov], Computational Linguistics and computantional ontologies: Proceedings of the XVIII joint Conference \Internet and modern society (IMS-</article-title>
          <year>2015</year>
          )
          <article-title>" [Kompyuternaya lingvistika i vyichislitelnyie ontologii: sbornik nauchnyih statey. Trudyi XVIII ob'edinennoy konferentsii Internet i sovremennoe obschestvo (IMS-</article-title>
          <year>2015</year>
          )], St. Peterburg, pp.
          <volume>25</volume>
          {
          <fpage>34</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Zagibalov</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Belyatskaya</surname>
            ,
            <given-names>K.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Carroll</surname>
            , J.: In Computational Approaches to Subjectivity and
            <given-names>Sentiment</given-names>
          </string-name>
          <string-name>
            <surname>Analysis</surname>
          </string-name>
          ,
          <year>2010</year>
          . { .
          <volume>67</volume>
          {
          <fpage>72</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Meng</surname>
            <given-names>X.</given-names>
          </string-name>
          <article-title>Lost in translations? building sentiment lexicons using context based machine translation</article-title>
          / Meng X.,
          <string-name>
            <surname>Wei</surname>
            <given-names>F</given-names>
          </string-name>
          .,etc. // COLING,
          <year>2012</year>
          . { .
          <volume>829</volume>
          {
          <fpage>838</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Pazel</surname>
          </string-name>
          <article-title>'skaya, A., Solov'ev, A.: Metod opredeleniia emotsii v tekstakh na russkom yazike</article-title>
          .
          <source>Dialog-2011. Sb. Nauchnih statei / Vip</source>
          .
          <volume>11</volume>
          (
          <issue>18</issue>
          ).- .
          <source>: RGGU</source>
          ,
          <year>2011</year>
          .{ .
          <volume>510</volume>
          -
          <fpage>523</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Rubtsova</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          :
          <article-title>A method for development and analysis of short text corpus for the review classi cation task</article-title>
          .
          <source>In: Proceedings of Conferences Digital Libraries: Advanced Methods and Technologies</source>
          , Digital Collections,
          <string-name>
            <surname>RCDL</surname>
          </string-name>
          <year>2013</year>
          , pp.
          <volume>269</volume>
          {
          <issue>275</issue>
          (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6. Stemming and
          <article-title>Lemmatization: A Comparison of Retrieval Performances</article-title>
          , http: //www.lnse.org/papers/134-
          <fpage>I3007</fpage>
          .pdf.
          <source>Last accessed 8 Nov 2019</source>
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Luhn</surname>
            ,
            <given-names>H. P.</given-names>
          </string-name>
          :
          <article-title>Keyword-in-Context Index for Technical Literature (KWIC Index)</article-title>
          .
          <source>American Documentation</source>
          .
          <volume>11</volume>
          (
          <issue>4</issue>
          ):
          <volume>288</volume>
          {
          <fpage>295</fpage>
          .
          <source>CiteSeerX 10.1.1.468</source>
          .1425. https://doi.org/10.1002/asi.5090110403.
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Sanjiv</surname>
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Chen</surname>
            <given-names>M.</given-names>
          </string-name>
          <article-title>Yahoo! for Amazon: Extracting market sentiment from stock message boards // Proceedings of the Asia Paci c nance association annual conference (APFA)</article-title>
          . |
          <year>2001</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9. Logit-analiz, .
          <source>Last accessed 12 Oct</source>
          <year>2019</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Cramer</surname>
            ,
            <given-names>J. S.</given-names>
          </string-name>
          (
          <year>2002</year>
          ).
          <article-title>The origins of logistic regression (PDF)</article-title>
          (
          <source>Technical report)</source>
          . 119. Tinbergen Institute. pp.
          <volume>167</volume>
          {
          <fpage>178</fpage>
          . https://doi.org/10.2139/ssrn.360300.
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Awesome</surname>
            <given-names>XGBoost</given-names>
          </string-name>
          , https://github.com/dmlc/xgboost/tree/master/demo# machine
          <article-title>-learning-challenge-winning-solutions</article-title>
          .
          <source>Last accessed 10 Nov 2019</source>
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <given-names>Tianqi</given-names>
            <surname>Chen</surname>
          </string-name>
          and
          <string-name>
            <given-names>Carlos</given-names>
            <surname>Guestrin</surname>
          </string-name>
          .
          <article-title>XGBoost: A Scalable Tree Boosting System</article-title>
          .
          <source>In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD '16)</source>
          . ACM, New York, NY, USA,
          <fpage>785</fpage>
          -
          <lpage>794</lpage>
          . https://doi.org/10.1145/2939672.2939785
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <given-names>Ronan</given-names>
            <surname>Collobert</surname>
          </string-name>
          and
          <string-name>
            <given-names>Jason</given-names>
            <surname>Weston</surname>
          </string-name>
          .
          <year>2008</year>
          .
          <article-title>A uni ed architecture for natural language processing: deep neural networks with multitask learning</article-title>
          .
          <source>In Proceedings of the 25th international conference on Machine learning (ICML '08)</source>
          . ACM, New York, NY, USA,
          <fpage>160</fpage>
          -
          <lpage>167</lpage>
          . https://doi.org/10.1145/1390156.1390177
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <surname>Sokolova</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Lapalme</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          (
          <year>2009</year>
          ).
          <article-title>A systematic analysis of performance measures for classi cation tasks</article-title>
          .
          <source>Information Processing Management</source>
          ,
          <volume>45</volume>
          (
          <issue>4</issue>
          ),
          <volume>427</volume>
          {
          <fpage>437</fpage>
          . https://doi.org/10.1016/j.ipm.
          <year>2009</year>
          .
          <volume>03</volume>
          .002
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>