lot of different sensors, however for the current study
only the ones in table 1 are relevant.
Machine learning is another important concept for
this study. In summary, it is a system capable of learn-
ing from data fed to it, rather than relying on explicit
coding. One very important subcategory of machine
learning is Supervised learning. This paradigm al-
ways starts with a pre-established dataset that con-
tains some understanding of its classification. Its fo-
cus is on finding patterns in the data that can later be
used in analytical processes.
In the literature, there are articles discussing ma-
chine learning models that utilize sensors to predict
human activities. In (Su et al., 2014), the authors be-
gin by mentioning sensors that could be employed for
this purpose, including several we have already dis-
cussed. Following this, they categorize the activities
that are typically predicted into different categories,
with the activities we aim to predict mainly falling
into the simple activities category. Next, they em-
phasize the significance of the features collected for
the models, highlighting that time and frequency fea-
tures are fundamental for studies of this nature. To
conclude the article, they mention various machine
learning models that could be used, such as deci-
sion trees, SVM, neural networks, among others. In
articles (Wang and Kim, 2015) and (Vaughn et al.,
2018), they predicted human activities using smart-
phone sensors specifically, and both developed an An-
droid app for collecting the data. In article (Wang and
Kim, 2015) the results obtained were not analyzed in
terms of accuracy, whereas in article (Vaughn et al.,
2018) the best outcome reported was an 89.5636% ac-
curacy achieved by a random forest model.
3 DATA COLLECTION
3.1 Android App
In order to accomplish the first objective mentioned
earlier, an Android app was developed to collect sen-
sor data. This app is capable of collecting data
from the smartphone accelerometer, gyroscope, grav-
ity sensor, orientation sensor, luminosity sensor, prox-
imity sensor, Bluetooth sensor, and connectivity sen-
sor. Additionally, a smartphone identifier was also
collected to detect malfunctioning data collection de-
vices. It was constructed using the Android sensors
framework, enabling users to collect data for each
activity. Users can initiate data collection, stop it,
save the data to the database, or delete the current
data collection session. Since sensor data is consid-
ered sensitive by Google, it was necessary to create
a foreground service in Android that displays a noti-
fication to the user, indicating that data is being col-
lected in the background. The resulting app is avail-
able for download on the Play Store at the following
link https://play.google.com/store/apps/details?id=co
m.exercisetracker.switchingactivities&pcampaignid=
web share.
3.2 Web Server
To save the data collected by the Android app, a Java-
based app was developed to communicate with it. To
ensure that this app was always available, allowing
users to collect data at any time, it was deployed on
the Google Cloud Platform. It was developed us-
ing the Quarkus framework, typically used for build-
ing applications capable of communication via REST
APIs. In doing so, it was subdivided into four main
types of classes: entities, repositories, services, and
resources. Entities are classes that are meant to be
persisted, in other words, they are supposed to be
saved into the database. In this study, two entities
were created: an ’Activity’ that represents a data col-
lection session and a ’Timestamp’ that represents the
sensor values at each second. Repositories are classes
that allow the communication between entities and
the database. Services, on the other hand, are classes
where all the logic of the application is built. These
classes access the database through the repositories
and are then able to manipulate the entities according
to what they want to do. To conclude, the resources
are the ones capable of communicating with the out-
side, in this case, the Android app. They provide an
API that, when called, will use the services to retrieve
the desired response.
4 EXPERIMENTAL SETUP
4.1 Methodology
In order to be able to get predictions from the final
model, it was necessary to create a tunnel of commu-
nication between the data collection app and the final
model. This tunnel was a python app developed us-
ing the framework Flask so it could communicate via
a REST API. This app primarily focuses on a POST
method that receives a 6-second data sample and pro-
vides an activity prediction.When this app is called,
the first thing it does is read the JSON body of the re-
quest and transform it into a pandas dataframe. After-
ward, the dataframe undergoes the necessary data pre-
processing before being passed to the model, which
then retrieves the final prediction.
Activity Recognition in Smartphones Using Non-Intrusive Sensors
89