<!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>Smartwatch Activity Recognition Using Ml.net Framework∗</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Alexandru Alexan</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Anca Alexan</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>tefan Oniga</string-name>
          <email>stefan.oniga@cunbm.utcluj.ro</email>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Electric, Electronic and Computer Engineering, Technical University of Cluj-Napoca, North University Center Baia Mare</institution>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Proceedings of the 1</institution>
        </aff>
      </contrib-group>
      <fpage>39</fpage>
      <lpage>45</lpage>
      <abstract>
        <p>Nowadays wearable devices are part of our everyday lives. More and more devices that we carry every day are becoming smart and gain more and more features. One of them is the humble watch, which has been telling the time and other useful basic information for ages. Since this inconspicuous device is worn almost all the time, it can be successfully used for activity recognition. We propose a system that uses a smartwatch as a primary movement data collection device that connects to a local data hub, which acts as a data gateway. The local hub's role is to upload the data into the cloud, a MongoDB database in realtime. To recognize activities, this system will process the obtained data ofline, using the ML.net machine learning framework. This proposed activity recognition system can be easily expanded due to the local data hub and provides a non-intrusive method of collecting user's data with only a smartwatch. Combined with the machine learning data processing mechanism, this ensures a flexible activity recognition system that has a good recognition rate.</p>
      </abstract>
      <kwd-group>
        <kwd>Activity recognition</kwd>
        <kwd>smartwatch</kwd>
        <kwd>machine learning</kwd>
        <kwd>ML</kwd>
        <kwd>NET</kwd>
        <kwd>IoT</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        Wearable devices are becoming everyday objects, assisting us in many fields
including healthcare [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. One of the most popular wearable technology devices is the
smartwatch, which replaced an every-day carry device with one capable of
monitoring and assisting the wearer. This integrates very well with the smart house
ideology [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], providing a device that can control any aspect of a smart House in an
extremely small form factor. Although the initial reason for using a smartwatch[
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]
may not be health or IoT integration orientated, this small device can easily help in
these areas and do much more. Even though these devices are not medical grade,
they can help detect health problems [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ] due to their multiple integrated sensor
types and high wear time. Another area that can benefit from a small device that
has movement sensors and is worn most of the time by the user is activity
recognition. Activity recognition was extensively implemented using a smartphone [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ],
using one detection device that can record and process the user’s movement data.
      </p>
      <p>Our objective is to implement and test a data recognition system that uses a
smartwatch as the main data source. The sensor data is then uploaded to the cloud
so that the ofline data processing phase can begin. The main diference between
the proposed system and other similar systems is using the ML.NET framework
for the processing phase to obtain a portable and low footprint activity recognition
component that is .NET compatible.</p>
    </sec>
    <sec id="sec-2">
      <title>2. Related Work</title>
      <p>
        Activity recognition is done using various sensors [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] that can be roughly grouped
into two main categories: ambient sensors [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] and wearable sensors [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ]. Ambient
sensors are comprised mainly of motion sensor like PIR, infrared, or ultrasonic.
Vision based sensors are also part of this category and include video cameras and
other detection modules that use vision based identification. Since these sensor
types are part of the environment, they are fixed and cannot be used outside of the
predefined perimeter. One advantage is that they don’t have any kind of power
or size restrictions and can easily provide wired and high power wireless
capabilities. Wearable sensors are, as the name suggests, worn by the user and thus have
size, power and connectivity restrictions. Examples of everyday objects that have
activity recognition capable sensors build in are smartphones and smartwatches.
Smartphones are being used extensively for activity recognition [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] and can yield
good results. Smartwatches can be used for activity recognition and have an
advantage over smartphones due to smaller size and, higher probable wear time, and
similar characteristics. As shown in [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] activity detection is an important part of
the data mining process as it classifies the data for further actions or processing.
The accuracy of using a smartwatch for activity recognition is quite high, even
reaching an accuracy of 99% as shown in [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ].
      </p>
    </sec>
    <sec id="sec-3">
      <title>3. Proposed System</title>
      <p>Our proposed system consists in a smartwatch that is used for data acquisition and
a couple of software applications that are used to retrieve, upload data into the
cloud, and process the obtained data-set ofline. Uploading data into the cloud is
done using a middle-ware local data hub, that receives the data from the watch
and uploads it directly to the cloud. The local data hub, a raspberry pi device, is
used to overcome any networking issues and latency. The high level architecture of
the proposed system, showing the main components and their interaction, is shown
in Figure 1.</p>
      <p>The system can be used for activity recognition as a base system or can be
part of a more complex activity recognition system, synchronizing and correlating
data with other systems. Having another device, a smartwatch that is worn by the
user on his wrist, helps significantly in providing correlation data and additional
information regarding the user’s current activity. The local data hub simplifies
any future integration with other systems and allows for local data processing. It
provides a simple method for the system to be expanded. Currently the proposed
system is used standalone, without being integrated into a larger system, and only
for testing.</p>
      <sec id="sec-3-1">
        <title>3.1. Activity Detection Device</title>
        <p>
          The chosen activity detection device is the Samsung Gear S3 smartwatch. This
was chosen due to its low price, small form factor(46mm x 49mm), sensors, and
additional features. Even though this is a commercially available product, due to its
built-in sensors, it is capable of monitoring user activity [
          <xref ref-type="bibr" rid="ref3">3</xref>
          ]. It features a multitude
of useful sensors: accelerometer, barometer, gyro sensor, heart rate monitor and
ambient light sensor. Also, the provided connectivity is great, including Bluetooth
and WiFi (802.11 b/g/n 2.4GHz). Its waterproof rating of IP68 ensures that the
end-user can wear the watch all the time. Since it features a powerful processor,
1GHz, Dual Core (Exynos7270), it is capable of relaying data besides running the
standard applications.
        </p>
      </sec>
      <sec id="sec-3-2">
        <title>3.2. Data Gathering Application</title>
        <p>The data from the chosen smartwatch, the Samsung Gear S3, was gathered using
a custom Tizen app written in C#. This Tizen .NET application has access to
the underlying sensor layer and its values and runs on the watch.There are
multiple advantages of using the C# programming language, besides rapid application
development, as we benefit from the Common Language Infrastructure standards
and a managed runtime. This application handles the data gathering process from
the smartwatch device and uses a WebSocket to transfer this data to the cloud.
This process uses a middle-ware component, a simple local data hub, that handles
the cloud uploading process.The obtained data is being also displayed on the watch
face as shown in Figure 2 while the watch application is running.</p>
      </sec>
      <sec id="sec-3-3">
        <title>3.3. The Local Data Hub and Cloud</title>
        <p>The local data hub is used as a temporary data storage and includes the cloud
upload functionality. The data from the smartwatch is received using a WebSocket
and then it is relayed to a cloud-based database. The cloud database we used
for testing is a MongoDB database since it’s document orientated and allows for
rapid scaling. The local hub application runs on a Raspberry Pi computer and
is comprised currently of a basic data routing logic, taking data from the
WebSocket, storing the data in memory and uploading it immediately in the MongoDB
database.</p>
      </sec>
      <sec id="sec-3-4">
        <title>3.4. Data Processing</title>
        <p>To identify the activity that the user was executing, based on the movement data
collected from the smartwatch, we need to process this data. For the data
processing flow, we choose a .net machine learning framework, ML.Net. With this
framework, we have access to complex pipelines for machine learning processing.
Due to the emergence of .net Core, which can run on multiple operating systems,
this library can be used on a wide number of platforms. One of the most important
aspects of choosing this framework was the fact that is open source, allowing the
developer to see or even alter the source code.</p>
        <p>The gathered and processed data is comprised of accelerometer and gyroscope
data for the three axes: x, y and z. After the data is loaded into the cloud, it is
currently ofline processed using the ML.NET framework to analyze the activity
types.</p>
        <p>There are two major steps for the data processing phase: training the machine
learning algorithm and using the algorithm to detect the activity type.</p>
        <p>The machine learning training process was done using the ML.net framework,
using a very small training time, 20 seconds. If required, this training time can be
increased in order to allow more training time for each of the available algorithms
that are used by the framework. After the training completes, we obtain a
comparative list of algorithms used and their accuracy. The top five models are shown
in Figure 3 alongside the validation error, loss for each algorithm.</p>
        <p>From the above-mentioned list, the best algorithm is selected to be used and
the accuracy is displayed as the result alongside the actual training time used by
this particular algorithm. The best algorithm, as shown in Figure 4, is
FastTreeRegression with a coeficient of determination of 0.9392.</p>
        <p>The chosen FastTreeRegression algorithm is an implementation of the MART
gradient boosting algorithm and yielded good results on the used data-set. This
machine learning algorithm was trained using a small data-set of about 9000 records
and tested with an additional data-set of about 3000 records.</p>
        <p>Once the training step is complete, the machine learning component can be
used to detect the activity type for the received movement data.</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>4. Conclusions</title>
      <p>This paper presents the implementation and testing of a smartwatch based
activity detection system that process the data ofline. The usage of a commercially
available product proved to be a good choice, as it allows user activity monitoring
without many additional body worn devices or sensors.</p>
      <p>Using the ML.net framework provides a powerful sensor data analysis tool that
can be rapidly trained and used in real-time applications. It can be greatly
expanded with custom code and processing to further increase the data recognition
rate. Also to increase the current recognition rate, a pre-processing step should be
implemented as well.</p>
      <p>Thus using a smartwatch based activity recognition system proved to be a
great versatile and small footprint implementation that can easily be expanded or
modified for various applications.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>M. A. R.</given-names>
            <surname>Ahad</surname>
          </string-name>
          ,
          <string-name>
            <surname>A. Das Antar</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          <article-title>Ahmed: Devices and Application Tools for Activity Recognition: Sensor Deployment and Primary Concerns</article-title>
          ,
          <source>in: July</source>
          <year>2020</year>
          , pp.
          <fpage>77</fpage>
          -
          <lpage>94</lpage>
          , isbn:
          <fpage>978</fpage>
          - 3-
          <fpage>030</fpage>
          -51378-8, doi: 10.1007/978-3-
          <fpage>030</fpage>
          -51379-
          <issue>5</issue>
          _
          <fpage>5</fpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>A.</given-names>
            <surname>Barbu</surname>
          </string-name>
          , G. Militaru,
          <string-name>
            <surname>I.</surname>
          </string-name>
          <article-title>Savu: Factors Afecting Use of Smartwatches (Mar</article-title>
          .
          <year>2020</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>A.</given-names>
            <surname>Davoudi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Wanigatunga</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Kheirkhahan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Corbett</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Mendoza</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Battula</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Ranka</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Fillingim</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Manini</surname>
          </string-name>
          , P. Rashidi:
          <article-title>Validation of the Samsung Gear S Smartwatch for Activity Recognition (Preprint)</article-title>
          ,
          <source>JMIR mHealth and uHealth 7</source>
          (
          <year>June 2018</year>
          ), doi: 10.2196/11270.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>B.</given-names>
            <surname>Fong</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Fong</surname>
          </string-name>
          ,
          <string-name>
            <surname>C.</surname>
          </string-name>
          <article-title>Li: Wearable Healthcare</article-title>
          (May
          <year>2020</year>
          ), pp.
          <fpage>239</fpage>
          -
          <lpage>256</lpage>
          , doi: 10.1002/9781119575788.ch9.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>A.</given-names>
            <surname>Ismael</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Jayabalan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Al-Jumeily</surname>
          </string-name>
          :
          <article-title>A Study on Human Activity Recognition Using Smartphone</article-title>
          ,
          <source>Journal of Advanced Research in Dynamical and Control Systems</source>
          <volume>12</volume>
          (May
          <year>2020</year>
          ), pp.
          <fpage>795</fpage>
          -
          <lpage>803</lpage>
          , doi: 10.5373/JARDCS/V12SP5/20201818.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>S.</given-names>
            <surname>Karim</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S. A.</given-names>
            <surname>Burney</surname>
          </string-name>
          ,
          <string-name>
            <surname>N.</surname>
          </string-name>
          <article-title>Mahmood: An Analysis of Human Activities Recognition using Smartwatches Dataset</article-title>
          ,
          <source>International Journal of Advanced Computer Science and Applications</source>
          <volume>11</volume>
          .12 (
          <year>2020</year>
          ), doi: 10.14569/IJACSA.
          <year>2020</year>
          .
          <volume>0111241</volume>
          , url: http://dx.doi.org/10.14569/IJACSA.
          <year>2020</year>
          .
          <volume>0111241</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>Q.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W.</given-names>
            <surname>Huangfu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Farha</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Zhu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Yang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Ning</surname>
          </string-name>
          <article-title>: Multi-resident type recognition based on ambient sensors activity</article-title>
          ,
          <source>Future Generation Computer Systems</source>
          <volume>112</volume>
          (May
          <year>2020</year>
          ), doi: 10.1016/j.future.
          <year>2020</year>
          .
          <volume>04</volume>
          .039.
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>Y.</given-names>
            <surname>Li</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Zhao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Duan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W.</given-names>
            <surname>Shi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Lin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>X.</given-names>
            <surname>Cao</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Y.</given-names>
            <surname>Liu</surname>
          </string-name>
          ,
          <string-name>
            <surname>J</surname>
          </string-name>
          . Zhao:
          <article-title>Control Your Home with a Smartwatch, IEEE Access PP (</article-title>
          <year>July 2020</year>
          ), pp.
          <fpage>1</fpage>
          -
          <lpage>1</lpage>
          , doi: 10.1109/ACCESS.
          <year>2020</year>
          .
          <volume>3007328</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>N.</given-names>
            <surname>Mozaffari</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Rezazadeh</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Farahbakhsh</surname>
          </string-name>
          , J. Ayoade:
          <article-title>IoT-based Activity Recognition with Machine Learning from Smartwatch</article-title>
          ,
          <source>International Journal of Wireless &amp; Mobile Networks 12.1</source>
          (
          <issue>Feb</issue>
          .
          <year>2020</year>
          ), pp.
          <fpage>29</fpage>
          -
          <lpage>38</lpage>
          , doi: 10.5121/ijwmn.
          <year>2020</year>
          .
          <volume>12103</volume>
          , url: https://doi.org/10.5121%
          <fpage>2Fijwmn</fpage>
          .
          <year>2020</year>
          .
          <volume>12103</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>R.</given-names>
            <surname>Pinninti</surname>
          </string-name>
          <article-title>: test Human Activity Recognition with Smartphones (Oct</article-title>
          .
          <year>2020</year>
          ),
          <source>doi: 10.13140/RG.2.2.28869.68324.</source>
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <given-names>L.</given-names>
            <surname>Silva</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Murilo</surname>
          </string-name>
          , R. Lins: Uso de SmartWatch no Auxílio a Monitoração de Arritmias Cardíacas / Usage of SmartWatch to Assist Monitoring of Cardiac Arrhythmias,
          <source>Brazilian Journal of Development</source>
          <volume>6</volume>
          (Oct.
          <year>2020</year>
          ), pp.
          <fpage>75511</fpage>
          -
          <lpage>75525</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <given-names>Y.</given-names>
            <surname>Wang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Cang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Yu</surname>
          </string-name>
          :
          <article-title>A survey on wearable sensor modality centred human activity recognition in health care</article-title>
          ,
          <source>Expert Systems with Applications</source>
          <volume>137</volume>
          (Apr.
          <year>2019</year>
          ), doi: 10.1016/j.eswa.
          <year>2019</year>
          .
          <volume>04</volume>
          .057.
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>