PISIoT: A Machine Learning and IoT-Based Smart Health Platform for Overweight and Obesity Control

: Overweight and obesity are a ﬀ ecting productivity and quality of life worldwide. The Internet of Things (IoT) makes it possible to interconnect, detect, identify, and process data between objects or services to fulﬁll a common objective. The main advantages of IoT in healthcare are the monitoring, analysis, diagnosis, and control of conditions such as overweight and obesity and the generation of recommendations to prevent them. However, the objects used in the IoT have limited resources, so it has become necessary to consider other alternatives to analyze the data generated from monitoring, analysis, diagnosis, control, and the generation of recommendations, such as machine learning. This work presents PISIoT: a machine learning and IoT-based smart health platform for the prevention, detection, treatment, and control of overweight and obesity, and other associated conditions or health problems. Weka API and the J48 machine learning algorithm were used to identify critical variables and classify patients, while Apache Mahout and RuleML were used to generate medical recommendations. Finally, to validate the PISIoT platform, we present a case study on the prevention of myocardial infarction in elderly patients with obesity by monitoring biomedical variables.


Introduction
Worldwide obesity has nearly tripled since 1975. In 2016, more than 1.9 billion adults aged 18 years and older were overweight, and of these, over 650 million were obese. In percentage terms, 39% of adults aged 18 years and over were overweight, and 13% were obese. In addition, 41 million children under the age of 5 were overweight or obese, and over 340 million children and adolescents aged 5 to 19 were overweight or obese. Most of the world's population lives in countries where being overweight and obese kills more people than being underweight. Overweight and obesity are defined as abnormal or excessive fat accumulation that impairs the health, productivity, and quality of life of people all over the world [1]. Likewise, the body mass index (BMI) is a simple weight index that takes into account height to determine overweight and obesity in adults. For adults, the BMI provides the most useful population-level measure of overweight and obesity, as it is the same for both sexes and all ages. Although considered characteristic of developed countries, this health problem is increasingly prevalent in underdeveloped countries, especially in urban environments. The fundamental cause of obesity and overweight is an energy imbalance between calories consumed and calories burned. Globally, people have increased their intake of energy-dense foods that are high in fat and engage in

Related Work
The use of IoT-based devices is changing people's lifestyles, particularly in activities related to healthcare. In this sense, IoT-based devices monitor, analyze, diagnose, and contribute to the generation of medical recommendations for various health conditions, such as overweight and obesity. For this reason, this topic has become the focus of much attention in recent research [9]. In this section, we present a review of the state of the art of research involving the IoT in healthcare, particularly with respect to overweight, obesity, and chronic degenerative diseases.
Vasquez et al. [10] proposed "mhealth", a health platform that contributes to improving child nutrition by monitoring intake and sends notifications and informative messages based on the choice of food. In addition, Vilallonga et al. [11] presented a study conducted on a group of obese patients having undergone surgery, who found it very motivating to observe, easily and quickly, a consistent graphic representation of their activities. Mun-Lee and Ouyang [12] presented a study that sought to identify correlations between the risks of developing certain diseases and used healthcare devices in the context of the IoT. By contrast, Zaragozá et al. [13] presented a platform that uses intercommunicated sensors to monitor the activities of children with obesity problems.
Additionally, Mun-Lee and Ouyang [14] proposed a collaboration protocol to send risk notifications to smart devices used in the IoT, along with a new service application algorithm that was used in devices linked to patients with blood pressure problems, obesity, and diabetes. Hiremath et al. [15] presented a proposal for the conceptualization of wearable IoT (WIoT) in terms of applications, functions, and design. In addition, they proposed a system for WIoT that recommends new directions regarding clinical and operative procedures. Likewise, Vázquez et al. [16] proposed new mobile health architecture to prevent childhood obesity through healthy eating suggestions using mobile health alternatives. In addition, they considered messages and notifications for a healthy diet for adults. Kim et al. [17] presented the iN Touch mobile application to monitor the daily activities of underprivileged young people with overweight and obesity who participated in a health apprenticeship program.
Alloghani et al. [18] presented a mobile application to increase children's and parents' awareness of the consequences of being overweight and obese, while providing information on how to sustain a healthy and balanced diet. By contrast, Wibisono and Astawa [19] proposed a web page and a mobile application for the treatment of weight reduction through machine-to-machine (M2M) information exchange or communication, in which a specific proportion of weights was used to achieve a healthy diet. Dobbins et al. [20] proposed a method to obtain physiological data from devices linked to triaxial accelerometers and a heart rate monitor, in order to detect physical activity. Likewise, they evaluated the performance of the classifiers in relation to the physical activities of the patients. Additionally, Shin et al. [21] defined a new concept of IoT-learning, with which a health application was developed using a combination of the IoT and architecture supported by the IoT. Likewise, they proposed a patient-focused treatment using IoT-learning to maintain weight.
On the other hand, Aupetit et al. [22] described the design of a biometric data display board for a childhood obesity camp in Qatar. The dashboard was validated by a health expert, and the health status of one patient was evaluated against another individual from another group to identify activity recommendations to be improved. Additionally, Yang et al. [23] presented a study to evaluate the effectiveness of the prevention of obesity in children 10 to 12 years of age with a mobile platform system called HAPPY ME, a smartphone application together with a portable device designed to improve healthy behaviors to prevent childhood obesity. In addition, Laing et al. [24] presented a Appl. Sci. 2019, 9,3037 4 of 23 study on the effectiveness of an experimental intervention based on diet recommendations given by means of a smart application for weight loss in overweight and obese patients over 18 years of age. Ahmed et al. [25] presented an overview of existing health monitoring systems, taking into account the IoT approach, and discussed recent trends and the development of health monitoring systems in terms of health parameters and frameworks, wireless communication, and security issues, while identifying limitations and advantages.
In addition, Fernández-Caballero and Fern [26] presented the project "Improvement of the Elderly Quality of Life and Care through Smart Emotion Regulation", which sought solutions to improve the quality of life and care of elderly people using cameras, sensors and emotion regulation techniques. Chetty et al. [27] presented a new data analytic scheme for the smart recognition of human activities (e.g., activities by elderly people), using smartphone inertial sensors with classification algorithms based on information theory and classifiers based on random forests, learning by sets, and slow learning. Hussain et al. [28] presented a screening framework for medical care for the elderly and disabled. The platform made it possible to monitor the health of the elderly and disabled and provided an emergency alert in the event of a health condition outside normal values. Likewise, Muralidharan et al. [29] proposed a conceptual model to identify and classify the barriers to physical activity for patients with type 2 diabetes to establish the basis for the development of an ontology of diseases and patient activities.
Mathai et al. [30] presented a scenario-based design approach to develop new cases for better diabetes management. The approach identified the patient's exercise, food, and emotional habits using mobile devices and sensors. Miah et al. [31] designed and evaluated an innovative mobile decision support solution (MDSS) to support the health decisions of rural citizens and the dissemination of information. The solution was developed using a design science approach, allowing general practitioners, based on consultation and information support, to virtually assess patient conditions and provide a diagnosis or treatment. In addition, Lim et al. [32] proposed an unsupervised machine learning model that has the ability to identify latent infectious diseases in the real world by extracting data from social media. Likewise, de Ramón-Fernández et al. [33] presented an integrative architecture that addresses the various deficiencies of current systems in terms of security, scalability, integration, flexibility, interoperability or data standardization to monitor hypertensive patients.
Jeong et al. [34] proposed the development of iotHEALTHCARE, describing its architecture as a smart alternative for healthcare. iotHEALTHCARE used sensors connected to a network to collect medical variables; later, the data were analyzed through algorithms validated by health personnel to generate recommendations. By contrast, Gupta et al. [35] proposed architecture supported by embedded sensors in the equipment, avoiding the use of wearable sensors or smartphone sensors, with the purpose of safeguarding basic health-related medical information. Chen et al. [36] proposed smart clothes, which, in combination with innovative procedures in clothes manufacturing, are used to monitor health status. In addition, Jung [37] proposed a framework to perform a context analysis of health parameters collected by WIoT devices that make it possible to monitor patients' health. Santos et al. [38] presented a mobile gateway supported by the IoT and used in various cases directly related to m-Healthcare (mobile health).
Hossain and Muhammad [39] described a framework designed specifically for the healthcare industrial IoT (HealthIIoT), in which information was obtained through sensors and smart devices. Likewise, Ganzha et al. [40] presented research to create procedures and instruments that benefit semantic interoperability in mobile health through the "INTER-IOT" project. Raza et al. [41] provided a general overview of telehealth and considered new telehealth technologies and tools to increase the quality of healthcare services. In addition, Camara [42] described future trends in wireless communication with a focus on 5G networks, in which the benefits for the IoT and e-health are notable. Further, Ifrim et al. [43] presented a study focusing on the use of IoT in e-Health, along with future guidelines and the evolution of the IoT in the field of health. This analysis of related work has shown that there are tools or applications in the IoT seeking to reduce the prevalence of overweight or obesity. Likewise, studies were found that use smart, mobile or sensor devices and machine learning algorithms to improve the healthcare of patients with chronic degenerative diseases such as diabetes and high blood pressure. However, we found that some studies use wearable devices to monitor biomedical variables. Likewise, some studies do not consider the connectivity, interoperability, and integration of heterogeneous devices, and few works use machine learning algorithms for data analysis. Moreover, only a few studies make medical recommendations. In this sense, PISIoT is a user-centered solution that provides access to and integrates information from various sources and device providers in the IoT. Likewise, it analyzes the information collected machine learning techniques and provides expert knowledge through recommendations, rules, and alerts. Furthermore, PISIoT performs patient monitoring in real time, provides medical recommendations based on the detection of risk values or situations and facilitates the relationship between patients and the specialists responsible for their health. PISIoT does not intend to replace the health specialist but rather serve as a support tool for healthcare. The following section describes the PISIoT architecture and functionality, as well as the case study used.

Materials and Methods
IoT-based healthcare applications improve the quality of patient care at a low cost. Currently, smart devices in the IoT are used to monitor patients' biomedical variables. In addition, progress in telecommunications has significantly facilitated the use of IoT-based solutions in overweight and obesity [44]. Likewise, wearables allow biomedical variables to be collected in real time (for example, stress levels, sleep quality, blood sugar levels, heart rate, and calories burned) regardless of where the patient is located (at home or in the hospital) [45]. From this perspective, healthcare benefits greatly from the IoT because different solutions are linked to sensors or smart devices, improving patient care and the efficiency of health personnel [46]. In this section, we describe the PISIoT architecture and functionality and offer a case study for preventing myocardial infarction in elderly patients with obesity by monitoring biomedical variables.

Architecture Description
PISIoT is a smart healthcare platform that uses IoT-based devices and machine learning techniques to help manage weight and obesity. PISIoT allows real-time monitoring of a patient's biomedical variables through wearables and smart devices. All the data collected are processed and analyzed using machine learning algorithms to identify critical variables and make relevant recommendations for the loss or control of patients' weight.

PISIoT: Architecture and Functionality
PISIoT is based on a layered architecture, which provides a clear definition and description of the activities and functions of each module. This facilitates maintenance and allows for high scalability. Figure 1 presents the PISIoT architecture, which is made up of five layers: the presentation layer, monitoring network layer, integration layer, data management layer, and IoT-based services layer. Each layer is composed of various components with a specific functionality and relationship. A general description of the layers is presented below.

•
Presentation layer. Through this layer, communication is made between the patient and the platform, thus facilitating a web application and a mobile application through which patients are able to view and track their biomedical variables, available IoT-based services, medical history, and recommendations. In addition, the platform allows manual input of water and food consumed during the day. When patients enter food or drinks consumed using a smartphone or computer with Internet access linked to the wearable device, calories, carbohydrates, fat, and proteins are automatically obtained from the database of the device provider. Nevertheless, in PISIoT, it is possible to enter food or a beverage not included in the provider's database, in addition to any physical activity performed by the patient. • Monitoring network layer. This layer is made up of different IoT-based devices such as wearable and smart devices linked to telecommunication equipment, which have communication interfaces that facilitate the exchange of information. These devices make it possible to collect information on the patient's biomedical variables (heart rate, calories burned, sleep, minutes of physical activity and weight), based on the activities performed during a day. All the information collected is sent to the data management layer for further processing and analysis.

•
Integration layer. This layer is made up of the wearable and smart device providers and receives the patient's data and consultations to generate the requested answers. In addition, this layer is responsible for requesting services from the IoT-based services layer based on the PISIoT recommendations. • Data analysis layer. This layer is responsible for identifying critical variables and generates medical recommendations. In addition, this layer protects useful information for the PISIoT and patients' medical history.

•
IoT-based services layer. This layer is responsible for linking, invoking, selecting and confirming the availability of IoT-based services. • Data management layer. This layer is responsible for the storage and backup of the patient's medical history and the data collected by the devices used.
Appl. Sci. 2019, 9, x 6 of 23 • Monitoring network layer. This layer is made up of different IoT-based devices such as wearable and smart devices linked to telecommunication equipment, which have communication interfaces that facilitate the exchange of information. These devices make it possible to collect information on the patient's biomedical variables (heart rate, calories burned, sleep, minutes of physical activity and weight), based on the activities performed during a day. All the information collected is sent to the data management layer for further processing and analysis.

•
Integration layer. This layer is made up of the wearable and smart device providers and receives the patient's data and consultations to generate the requested answers. In addition, this layer is responsible for requesting services from the IoT-based services layer based on the PISIoT recommendations. • Data analysis layer. This layer is responsible for identifying critical variables and generates medical recommendations. In addition, this layer protects useful information for the PISIoT and patients' medical history.

•
IoT-based services layer. This layer is responsible for linking, invoking, selecting and confirming the availability of IoT-based services. • Data management layer. This layer is responsible for the storage and backup of the patient's medical history and the data collected by the devices used. The following subsections describe the most important aspects of the PISIoT, as a fundamental part of this work.

Monitoring Network Layer
The availability of a reliable platform, the particular device characteristics (brand, model, and battery life) and data access permissions by suppliers must all be considered in order to guarantee optimal monitoring of patients' biomedical variables. On the other hand, data acquisition by smart devices depends on various factors such as compatibility between the devices used, the wearable device's portability during the day, the correct positioning of the wearable device at night, continual reporting of weight, and patients' honesty in reporting food and water ingested. For this reason, a monitoring network is required that allows PISIoT to monitor and collect patients' biomedical variables and identify daily eating habits and physical activity with the purpose of motivating patients to maintain or reduce their weight, thus contributing to reducing the prevalence of overweight and obesity. Therefore, PISIoT uses an IoT-based monitoring network that allows smart devices to link up and communicate. The main purpose of the monitoring network is to collect The following subsections describe the most important aspects of the PISIoT, as a fundamental part of this work.

Monitoring Network Layer
The availability of a reliable platform, the particular device characteristics (brand, model, and battery life) and data access permissions by suppliers must all be considered in order to guarantee optimal monitoring of patients' biomedical variables. On the other hand, data acquisition by smart devices depends on various factors such as compatibility between the devices used, the wearable device's portability during the day, the correct positioning of the wearable device at night, continual reporting of weight, and patients' honesty in reporting food and water ingested. For this reason, a monitoring network is required that allows PISIoT to monitor and collect patients' biomedical variables and identify daily eating habits and physical activity with the purpose of motivating patients Appl. Sci. 2019, 9, 3037 7 of 23 to maintain or reduce their weight, thus contributing to reducing the prevalence of overweight and obesity. Therefore, PISIoT uses an IoT-based monitoring network that allows smart devices to link up and communicate. The main purpose of the monitoring network is to collect patients' biomedical and other variables from wearable devices. In particular, the monitoring network is made up of IoT-based smart devices that are divided into three categories: • Wearable devices. Wearable devices are responsible for monitoring and collecting most of the biomedical variables, as well as other variables generated from the patient's actions. The wearable devices in the IoT provide a high-tech infrastructure that enables communication and links between portable sensors to monitor a person's activities, including but not limited to the person's biomedical variables, behavior, and welfare, with the purpose of improving quality of life [15]. Wearable devices are classified according to their appearance, functionality, portability on the body, characteristics, and functional capacity in order to provide a better description of different sectors. For this reason, the authors of [47] classified wearable devices into smartwatch, smart eyewear, fitness tracker, smart clothing, wearable camera, and wearable biomedical device. PISIoT works with devices from some suppliers, but its scalability makes it possible to consider wearable devices from other suppliers. • Smart devices. These devices are responsible for the smart collection of weight or other variables not identified by wearable devices (e.g., smart scale, temperature sensor, motion sensor). Smart devices are the driving force of the IoT because they provide fast and accurate information in real time and identify various patterns. In this sense, PISIoT includes some smart device suppliers but ensures that other smart device providers can be incorporated.

•
Smartphones. Smartphones are in charge of maintaining communication between the devices, the providers, and PISIoT. The wearable devices used in the IoT lack an operating system as such; therefore, they must be linked to a smartphone or a computer with Internet access because the information collected by the devices must be safeguarded by the storage and support scheme of PISIoT and of its suppliers. PISIoT is multiplatform; however, depending on the model and provider of the wearable device that you wish to use, there are specific compatible smartphone models.

Data Analysis Layer
This layer identifies critical variables and classifies patients according to their level of obesity through Weka API based on version 3.8 of Java, since this is the latest stable version and is open-source software that is easy to integrate with PISIoT and meets the required functionality parameters. In addition, to perform the BMI classification, identify critical variables, and generate medical recommendations, PISIoT uses the machine learning algorithm J48, which is an open-source implementation in Java of the C4.5 algorithm. This means that both C4.5 and J48 are classification algorithms used to generate decision trees. The classification algorithms are useful for the diagnosis of hepatitis [48], cancer of the biliary tract [49], and lung cancer [50]; support vector machines used for the prediction of cancer growth [51] and stage I ovarian cancer [52]; for the prediction of cardiac diseases [53] and classification of eye disease [54]; to differentiate malignant, benign, and advanced pulmonary nodules [55]; and in the classification of tumors in digital mammograms [56] and diagnosis of pancreatic cancer [57]. In addition, J48 was selected because it has been used to build predictive models in similar classification problems and has shown better performance than other algorithms. For instance, in [58], J48 produced meaningful and useful predictions with better performance (larger area under the curve) than other decision tree algorithms like random forest and CART (classification and regression tree) models. Moreover, in [59], a J48 decision tree was used to classify users into different categories, and experimental results showed that the J48 decision tree classifier has higher accuracy and a lower response time in determining the category of a user compared to other classification algorithms like REPTree, fuzzy C-means, and random tree. By contrast, PISIoT was developed and implemented modularly and generically, with a view to high performance, ease of implementation, and better extensibility of the application. Figure 2 presents the four classes developed for the machine learning module.

1.
ClsModel.java serves primarily to generate the model from the training set. In addition, it contains two methods, one to receive the data set and another to generate the model based on the data set received. The class starts with an instance of the "Instances" type called "train". Likewise, the ClsModel constructor is sent, which, through the generateModel method, indicates the destination and the algorithm used. In addition, the searchAlgorithm method is invoked.

2.
InstanceAlgorithm.java contains the selection of the algorithm to be used. The method search Algorithm receives the algorithm selection and the model path.

3.
Clsalgorithms.java processes the data set, the model, and the incoming information to apply the corresponding algorithm, in addition to providing a timely response to the request. This class starts with a classifier of the "Classifier" type, train of the "Instances" type, and data object of the "Instances" type. In addition, it uses the applyInstance method to apply the changes made and designate the information to be analyzed. The ClsAlgorithms method also receives the model, the data set, and the algorithm to process the information and generate a response.

4.
ClsInstanceWeka.java generates an instance based on incoming information; this class is responsible for selecting the set of parameters to be processed. The CreateInstance method uses the Instances object and the number of elements contained in the data set, ignoring the class label.
Appl. Sci. 2019, 9, x 8 of 23 the data set received. The class starts with an instance of the "Instances" type called "train". Likewise, the ClsModel constructor is sent, which, through the generateModel method, indicates the destination and the algorithm used. In addition, the searchAlgorithm method is invoked. 2. InstanceAlgorithm.java contains the selection of the algorithm to be used. The method searchAlgorithm receives the algorithm selection and the model path. 3. Clsalgorithms.java processes the data set, the model, and the incoming information to apply the corresponding algorithm, in addition to providing a timely response to the request. This class starts with a classifier of the "Classifier" type, train of the "Instances" type, and data object of the "Instances" type. In addition, it uses the applyInstance method to apply the changes made and designate the information to be analyzed. The ClsAlgorithms method also receives the model, the data set, and the algorithm to process the information and generate a response. 4. ClsInstanceWeka.java generates an instance based on incoming information; this class is responsible for selecting the set of parameters to be processed. The CreateInstance method uses the Instances object and the number of elements contained in the data set, ignoring the class label. To carry out the recommendations, the daily values and the weekly averages of each variable are considered. This makes it possible to establish the rules (maximum and minimum values allowed per variable) in the algorithm. Therefore, each day, the patient is classified based on BMI as normal, overweight, obese 1, obese 2 or obese 3. Once the type of classification has been identified using J48, the established rules are selected depending on the type of obesity. In addition, the person's ideal weight is calculated based on age and height, in order to generate recommendations from health professionals according to pre-established rules. The rules generated identify and describe how the recommendation process operates, which aims to improve quality of life in a simple, progressive, and non-invasive manner using values obtained by the devices and entered by the patient. Apache Mahout and RuleML were used to generate medical recommendations. Apache Mahout is a free software library that offers scalable implementations of machine learning algorithms. RuleML is an XML-based language that serves to specify the immediate exchange of rules. In addition, together with the recommendations, suggested medical services are displayed depending on the patient's progress or health status.

IoT-Based Services Layer
This layer describes the set of representational state transfer (REST) services developed with the purpose of providing the platform with information for those who request it and have access permissions. This facilitates the development of future applications using the information provided by the platform. The services are divided into downloadable information from wearable device providers and biomedical variable services, recommendations, IoT-based services, and services associated with other patient variables stored in the platform. To carry out the recommendations, the daily values and the weekly averages of each variable are considered. This makes it possible to establish the rules (maximum and minimum values allowed per variable) in the algorithm. Therefore, each day, the patient is classified based on BMI as normal, overweight, obese 1, obese 2 or obese 3. Once the type of classification has been identified using J48, the established rules are selected depending on the type of obesity. In addition, the person's ideal weight is calculated based on age and height, in order to generate recommendations from health professionals according to pre-established rules. The rules generated identify and describe how the recommendation process operates, which aims to improve quality of life in a simple, progressive, and non-invasive manner using values obtained by the devices and entered by the patient. Apache Mahout and RuleML were used to generate medical recommendations. Apache Mahout is a free software library that offers scalable implementations of machine learning algorithms. RuleML is an XML-based language that serves to specify the immediate exchange of rules. In addition, together with the recommendations, suggested medical services are displayed depending on the patient's progress or health status.

IoT-Based Services Layer
This layer describes the set of representational state transfer (REST) services developed with the purpose of providing the platform with information for those who request it and have access permissions. This facilitates the development of future applications using the information provided by the platform. The services are divided into downloadable information from wearable device providers and biomedical variable services, recommendations, IoT-based services, and services associated with other patient variables stored in the platform.
The principal REST services developed to download data from providers were "downloadSleep" for sleep, "downloadWeight" for weight, "downloadSteps" for steps, and "downloadHeart" for heart rate. In the same way, other REST services were developed to download the data for each variable monitored by the smart devices. To invoke the services, the jQuery library is used for asynchronous calls, which generates a response in JSON format that is made up of two nodes. One node corresponds to the error and takes the value of "0" if everything was satisfactory and "1" if an error occurred. The second is a message node that indicates why the error, if any, occurred, or provides a complete process notice when the operation is satisfactory.

Integration Layer
This layer is responsible for making the request for monitoring data obtained by the wearable device or the smart device to the corresponding provider. This is achieved through an access token and following the access and permissions policies of each provider, in order to then send the data to the data management layer for analysis and storage. Figure 3 shows the general workflow of PISIoT implemented in this layer.
Appl. Sci. 2019, 9, x 9 of 23 The principal REST services developed to download data from providers were "downloadSleep" for sleep, "downloadWeight" for weight, "downloadSteps" for steps, and "downloadHeart" for heart rate. In the same way, other REST services were developed to download the data for each variable monitored by the smart devices. To invoke the services, the jQuery library is used for asynchronous calls, which generates a response in JSON format that is made up of two nodes. One node corresponds to the error and takes the value of "0" if everything was satisfactory and "1" if an error occurred. The second is a message node that indicates why the error, if any, occurred, or provides a complete process notice when the operation is satisfactory.

Integration Layer
This layer is responsible for making the request for monitoring data obtained by the wearable device or the smart device to the corresponding provider. This is achieved through an access token and following the access and permissions policies of each provider, in order to then send the data to the data management layer for analysis and storage. Figure 3 shows the general workflow of PISIoT implemented in this layer. As can be seen, wearable devices play an important role in monitoring several variables, particularly biomedical variables, since they collect data in real time and non-invasively, allowing the analysis and identification of critical variables to later generate medical recommendations and invoke medical services (clinical analysis, nutritionist, cardiologist, and general doctor). Patients are thus able to view, at any time, their progress or the day's data and can adjust and optimize their consumption of food or physical activity according to the recommendations provided by the platform. Additionally, in this layer, the patient's consultations are received, meaning that each time the patient accesses the PISIoT platform, a request for information is generated to visualize the biomedical variables and all other variables monitored by wearables and smart devices. In addition, based on the recommendations of medical services made in the data management layer, this layer is in charge of requesting available medical services from the IoT-based services layer to display them to patients so they can select the most appropriate based on availability of time, confidence, and cost.

Presentation Layer
PISIoT provides a mobile application that allows patients to interact with the platform. Figure  4a shows the main interface where the calories consumed, calories burned, heart rate, steps, and minutes of activity variables can be viewed. Additionally, it has a menu to access the patient profile, the types of synchronized devices or the option to add a new one, an option to view the biomedical variables monitored, recommendations, and IoT-based services. Figure 4b shows the recommendations generated for each of the biomedical variables (heart rate, sleep, calories burned, minutes of physical activity, and weight). As can be seen, wearable devices play an important role in monitoring several variables, particularly biomedical variables, since they collect data in real time and non-invasively, allowing the analysis and identification of critical variables to later generate medical recommendations and invoke medical services (clinical analysis, nutritionist, cardiologist, and general doctor). Patients are thus able to view, at any time, their progress or the day's data and can adjust and optimize their consumption of food or physical activity according to the recommendations provided by the platform. Additionally, in this layer, the patient's consultations are received, meaning that each time the patient accesses the PISIoT platform, a request for information is generated to visualize the biomedical variables and all other variables monitored by wearables and smart devices. In addition, based on the recommendations of medical services made in the data management layer, this layer is in charge of requesting available medical services from the IoT-based services layer to display them to patients so they can select the most appropriate based on availability of time, confidence, and cost.

Presentation Layer
PISIoT provides a mobile application that allows patients to interact with the platform. Figure 4a shows the main interface where the calories consumed, calories burned, heart rate, steps, and minutes of activity variables can be viewed. Additionally, it has a menu to access the patient profile, the types of synchronized devices or the option to add a new one, an option to view the biomedical variables monitored, recommendations, and IoT-based services. Figure 4b shows the recommendations generated for each of the biomedical variables (heart rate, sleep, calories burned, minutes of physical activity, and weight).  Additionally, Figure 5a shows a graph displaying the correlation of the biomedical variables (heart rate, sleep, calories burned, weight, and minutes of physical activity) with other variables collected by the wearable device and the smart device (steps, floors, and water consumed). Additionally, a button is displayed to enter the patient's medical service. Figure 5b shows the medical services available (clinical analysis, nutritionist, cardiologist, and general doctor). Thanks to the use of IoT technologies and machine learning techniques, PISIoT allows patients to visualize in an easy, user-friendly way and in real time their biomedical variables and classification, together with medical recommendations for weight loss or control. Additionally, the mobile application also provides a set of user interfaces that allow patients to view and request available medical services in the IoT, such as clinical analysis services or nutritionist, cardiologist or general practitioner services.  Additionally, Figure 5a shows a graph displaying the correlation of the biomedical variables (heart rate, sleep, calories burned, weight, and minutes of physical activity) with other variables collected by the wearable device and the smart device (steps, floors, and water consumed). Additionally, a button is displayed to enter the patient's medical service. Figure 5b shows the medical services available (clinical analysis, nutritionist, cardiologist, and general doctor). Thanks to the use of IoT technologies and machine learning techniques, PISIoT allows patients to visualize in an easy, user-friendly way and in real time their biomedical variables and classification, together with medical recommendations for weight loss or control. Additionally, the mobile application also provides a set of user interfaces that allow patients to view and request available medical services in the IoT, such as clinical analysis services or nutritionist, cardiologist or general practitioner services.  Additionally, Figure 5a shows a graph displaying the correlation of the biomedical variables (heart rate, sleep, calories burned, weight, and minutes of physical activity) with other variables collected by the wearable device and the smart device (steps, floors, and water consumed). Additionally, a button is displayed to enter the patient's medical service. Figure 5b shows the medical services available (clinical analysis, nutritionist, cardiologist, and general doctor). Thanks to the use of IoT technologies and machine learning techniques, PISIoT allows patients to visualize in an easy, user-friendly way and in real time their biomedical variables and classification, together with medical recommendations for weight loss or control. Additionally, the mobile application also provides a set of user interfaces that allow patients to view and request available medical services in the IoT, such as clinical analysis services or nutritionist, cardiologist or general practitioner services.  In addition, patients can be monitored by a trusted doctor and a relative they link to their profile.

Case Study: Prevention of Myocardial Infarction in Elderly Patients with Obesity by Monitoring Biomedical Variables
In this section, we present a case study to validate the contribution of PISIoT to weight control or loss in elderly patients with obesity, who are more prone to myocardial infarction. The case study focused on monitoring biomedical variables in obese elderly patients with a view to weight loss, thus reducing the likelihood of myocardial infarction. The scenario is as follows: • Elderly people with obesity need to know the number of calories ingested, calories burned, sleep, heart rate, the amount of water consumed, daily steps, and necessary physical activity to achieve gradual weight loss without health complications, helping to avoid myocardial infarction.
According to the WHO [60], cardiovascular diseases (CVDs) are disorders of the heart and blood vessels and include coronary heart disease, cerebrovascular disease, rheumatic heart disease, myocardial infarction, and other conditions. Individuals at risk of CVD have exhibited raised blood pressure, glucose, and lipids, as well as overweight and obesity. Identifying those at highest risk of CVDs and ensuring they receive appropriate treatment can prevent premature deaths, yet CVDs continue to cause many deaths worldwide. Figure 6 shows the scenario of elderly people with obesity who exhibit symptoms associated with myocardial infarction or have already had a myocardial infarction and who need to lose weight. The biomedical variables (heart rate, sleep, calories burned, weight, and minutes of physical activity) and other variables (steps, floors, calories consumed, distance traveled, water consumed, and exercise) are collected through a wearable device and a smart scale, which are linked to and synchronized with a smartphone. Through the smartphone linked to each patient, the wearable device and smart scale send the collected data to the corresponding provider. PISIoT requests each patient's data from the device providers for analysis in order to identify possible critical variables, generate the recommendations, and present the additional IoT-based services (clinical analysis, nutritionist or cardiologist) that the patient requires to achieve their weight loss goal.
Appl. Sci. 2019, 9, x 11 of 23 In addition, patients can be monitored by a trusted doctor and a relative they link to their profile.

Case Study: Prevention of Myocardial Infarction in Elderly Patients with Obesity by Monitoring Biomedical Variables
In this section, we present a case study to validate the contribution of PISIoT to weight control or loss in elderly patients with obesity, who are more prone to myocardial infarction. The case study focused on monitoring biomedical variables in obese elderly patients with a view to weight loss, thus reducing the likelihood of myocardial infarction. The scenario is as follows: • Elderly people with obesity need to know the number of calories ingested, calories burned, sleep, heart rate, the amount of water consumed, daily steps, and necessary physical activity to achieve gradual weight loss without health complications, helping to avoid myocardial infarction.
According to the WHO [60], cardiovascular diseases (CVDs) are disorders of the heart and blood vessels and include coronary heart disease, cerebrovascular disease, rheumatic heart disease, myocardial infarction, and other conditions. Individuals at risk of CVD have exhibited raised blood pressure, glucose, and lipids, as well as overweight and obesity. Identifying those at highest risk of CVDs and ensuring they receive appropriate treatment can prevent premature deaths, yet CVDs continue to cause many deaths worldwide. Figure 6 shows the scenario of elderly people with obesity who exhibit symptoms associated with myocardial infarction or have already had a myocardial infarction and who need to lose weight. The biomedical variables (heart rate, sleep, calories burned, weight, and minutes of physical activity) and other variables (steps, floors, calories consumed, distance traveled, water consumed, and exercise) are collected through a wearable device and a smart scale, which are linked to and synchronized with a smartphone. Through the smartphone linked to each patient, the wearable device and smart scale send the collected data to the corresponding provider. PISIoT requests each patient's data from the device providers for analysis in order to identify possible critical variables, generate the recommendations, and present the additional IoTbased services (clinical analysis, nutritionist or cardiologist) that the patient requires to achieve their weight loss goal.  PISIoT provides the possibility to establish a link with a private doctor and a relative of the patient for constant monitoring of the patient's achievement of daily objectives.

Methodology
This case study was conducted to monitor 40 obese elderly people from 60 to 80 years old (20 female and 20 male) who showed symptoms associated with myocardial infarction (e.g., pain in the center of the chest, difficulty breathing, numbness or pain in the right arm, sweating, paleness, dizziness) or had already experienced a myocardial infarction, and who needed to lose weight. A wearable device was assigned to each patient to obtain the biomedical variables (heart rate, sleep, calories burned, weight, and minutes of physical activity) and other variables (steps, floors, calories consumed, distance traveled, water consumed, and exercise). In addition, a smart scale was assigned to each patient to periodically record weight. For the purposes of this case study, it was necessary to obtain information about eating habits, water consumption, minutes of activity, calories burned, sleep, number of steps per day, and heart rate, both before and after implementation of PISIoT. For this reason, we followed the methodology described below: • Initial monitoring was performed over a period of two months (August-September 2018) using the wearable device; at the end of that period, weight was obtained with the smart scale. Both devices were linked to a smartphone to send the data to the device provider. A relative of the patient recorded food and water consumption using the platform for the wearable device. During this period, only the mobile application for the wearable device and smart scale were used. These focused only on monitoring the patient's biomedical variables and did not provide any type of alert or medical recommendation to lose weight. • Implementation of PISIoT. Afterwards, a second monitoring period ran for four months (October 2018-January 2019); the biomedical variables of the elderly people were requested from the device providers. Subsequently, the elderly patients' BMI was calculated using the formula BMI = weight (kg) ÷ height 2 (m) [1,61]. Then, the patients were classified to predict obesity with the classes ClsModel.java, Clsalgorithms.java, ClsInstanceWeka.java, and InstanceAlgorithm.java using the machine learning algorithm J48. Table 1 shows the classification used to determine the type of obesity according to the World Health Organization (WHO) [61]. In addition, the patient's biomedical variables (heart rate, calories burned, sleep, minutes of physical activity, and weight) and other variables (steps, floors, calories consumed, distance traveled, water consumed, and exercise) were considered in the classification to describe the behavior of elderly patients with obesity. With the data obtained by the wearable device and smart scale, a dataset was created with 17 predictor attributes (calories consumed, calories burned, carbohydrates, fat, proteins, water consumed, exercise duration, heart rate during exercise, resting heart rate, minutes of physical activity at peak level, minutes at cardio level, minutes at fat burning level, steps, floors, distance traveled, sleep duration, and weight), one class label attribute (obesity), and 7200 instances; daily data were registered for each patient and classified as the type of obesity that patients will exhibit, according to the values of the predictor attributes, if they maintain this behavior. • This made it possible to perform an analysis to identify possible critical variables that influence the emergence of obesity in elderly people, generate recommendations, and propose the IoT-based medical services that patients require to lose weight. The J48 algorithm has been adopted in PISIoT using the data set to obtain the predictive model with the 10-fold cross-validation technique. This kind of validation was used because, in general, it is recommended for estimation accuracy (even if computational power enables the use of more folds) due to its relatively low bias and variance [62]. Moreover, the J48 algorithm was selected since it was proven in previous studies to have performed better than other algorithms [63][64][65][66].

•
Once the type of classification has been identified, the established rules are selected depending on the type of obesity. Likewise, with the formula weight = (height − 40)/2 [2], the patient's ideal weight is identified, which serves as a basis to identify critical variables that are greater or smaller than the values permitted in each classification. Figure 7 shows the classification rules for obesity 1 and also includes recommendations based on the critical variables detected on a daily basis.

•
The medical recommendations section is complex, as they influence different factors. For this reason, the decrease in calories should be gradual, that is, portions of 500 kcal every 2 weeks to avoid any decompensation. Patients should not attempt to accelerate the process or exceed the limits established by the PISIoT.

•
If the patient does not follow the daily recommendations issued by the PISIoT, after a period of time, a greater medical recommendation is generated. Table 2 presents the rules for recommendations for patients with any type of obesity, which were made by specialized healthcare personnel (two doctors, a nutritionist with a master's degree in food and nutritional health, and a nurse with a master's degree in public health). The table includes the column "Variable", which gives the variable used; "Rule", which specifies the rule for the recommendation; "Frequency", which is how often the analysis is made; and "Recommendation", which contains the recommendation to be given if the rule is not met. The rules described above identify and describe the operation of the medical recommendation process, which aims to improve quality of life in a manner that is simple, gradual and non-invasive, and the use of the values obtained by the smart devices and those entered by the patient or the patient's family member.

•
These recommendations also include the medical services that patients require to achieve their goal of weight control or loss (clinical analysis, nutritionist or cardiologist). The medical recommendations and suggested medical services were validated by specialized healthcare personnel. The elderly patients monitored in this second period showed progress in weight loss from using PISIoT, which performs real-time monitoring, identifies critical variables that lead to weight gain, analyzes biomedical variables through machine learning techniques, provides recommendations for weight loss, and is monitored and supported by experts in healthcare.

•
Finally, the elderly people were monitored again for four more months (February-May 2019) to evaluate PISIoT's contribution and impact on the elderly patients' weight loss and health. This third period was proposed to verify PISIoT's contribution to weight loss and/or an improvement to elderly people's health, reducing the risk of a myocardial infarction or obesity-related diseases. In addition, in this period, the increase in elderly people's outlook and quality of life was evaluated following the recommendations provided by PISIoT.
on the type of obesity. Likewise, with the formula weight = (height − 40)/2 [2], the patient's ideal weight is identified, which serves as a basis to identify critical variables that are greater or smaller than the values permitted in each classification. Figure 7 shows the classification rules for obesity 1 and also includes recommendations based on the critical variables detected on a daily basis. • The medical recommendations section is complex, as they influence different factors. For this reason, the decrease in calories should be gradual, that is, portions of 500 kcal every 2 weeks to

Results and Discussion
The IoT and machine learning allow PISIoT to obtain and analyze biomedical variables and other variables collected by the smart devices in the monitoring network with the purpose of contributing to overweight and obesity control. In the case study, the data collected by the smart devices were analyzed in order to gain insight into the patients' eating habits, determine the patients' status according to their BMI, and identify critical variables and possible recommendations that help patients to control or lose weight and improve their health. This section discusses the results and the findings from this case study.

Monitoring Analysis
The data obtained from the elderly people were analyzed to identify critical variables according to the values of the biomedical variables (heart rate, sleep, calories burned, weight, and minutes of physical activity) and other variables (steps, floors, calories consumed, distance traveled, water consumed, and exercise) collected by the wearable device and smart scale. In addition, the information was analyzed to gain an insight into the eating patterns and physical activity of the elderly people. For this reason, three periods were established for patient monitoring.
In the first period (August-September 2018), only the smart device (wearable device and smart scale) providers' platform was used to understand the data collection process and the variables collected by each device, as well as to identify food intake, the amount of water ingested by the elderly people, and the values generated for each variable. An exploratory analysis of the data collected identified some disadvantages or limitations in the providers' devices and platforms. For example, when the wearable device battery is empty, data collection is lost during power charging and due to device inactivity; this is reported as sleep time. The same happens when the patient takes a shower and the device is not water-resistant, as it must be removed. In addition, the device providers' platforms only show the data obtained and do not generate any kind of medical recommendation. At the beginning of this first period, 100% of the elderly people had a high weight and a BMI between 30 and 35, and unfortunately, at the end of the period, none of the elderly people presented a weight decrease. Figure 8 shows the weekly average for each variable for each of the 40 elders monitored in the last week of the first period.
Appl. Sci. 2019, 9, x 15 of 23 according to their BMI, and identify critical variables and possible recommendations that help patients to control or lose weight and improve their health. This section discusses the results and the findings from this case study.

Monitoring Analysis
The data obtained from the elderly people were analyzed to identify critical variables according to the values of the biomedical variables (heart rate, sleep, calories burned, weight, and minutes of physical activity) and other variables (steps, floors, calories consumed, distance traveled, water consumed, and exercise) collected by the wearable device and smart scale. In addition, the information was analyzed to gain an insight into the eating patterns and physical activity of the elderly people. For this reason, three periods were established for patient monitoring.
In the first period (August-September 2018), only the smart device (wearable device and smart scale) providers' platform was used to understand the data collection process and the variables collected by each device, as well as to identify food intake, the amount of water ingested by the elderly people, and the values generated for each variable. An exploratory analysis of the data collected identified some disadvantages or limitations in the providers' devices and platforms. For example, when the wearable device battery is empty, data collection is lost during power charging and due to device inactivity; this is reported as sleep time. The same happens when the patient takes a shower and the device is not water-resistant, as it must be removed. In addition, the device providers' platforms only show the data obtained and do not generate any kind of medical recommendation. At the beginning of this first period, 100% of the elderly people had a high weight and a BMI between 30 and 35, and unfortunately, at the end of the period, none of the elderly people presented a weight decrease. Figure 8 shows the weekly average for each variable for each of the 40 elders monitored in the last week of the first period. In the second period (October 2018-January 2019), PISIoT was introduced to monitor the elderly people. In the first instance, PISIoT requested, through the REST services developed, the data collected by the smart devices from each provider for the first period for each patient (August-September 2018). Based on this, PISIoT obtained the elders' BMI, which was between 30 and 35, classifying them at obesity level 1, and the second monitoring period began. Figure 9a shows the biomedical and other variables monitored by the smart devices in PISIoT during one week for a 76year-old obese elder with a height of 1.66 m, weight of 91 kg, and a BMI of 33.1, in which high values were observed in calorie consumption and daily average resting heart rate. Additionally, low values In the second period (October 2018-January 2019), PISIoT was introduced to monitor the elderly people. In the first instance, PISIoT requested, through the REST services developed, the data collected by the smart devices from each provider for the first period for each patient (August-September 2018). Based on this, PISIoT obtained the elders' BMI, which was between 30 and 35, classifying them at obesity level 1, and the second monitoring period began. Figure 9a shows the biomedical and other variables monitored by the smart devices in PISIoT during one week for a 76-year-old obese elder with a height of 1.66 m, weight of 91 kg, and a BMI of 33.1, in which high values were observed in calorie consumption and daily average resting heart rate. Additionally, low values were identified for physical activity, daily steps, floors, calories burned, sleep, and water consumption. Based on the recommendation rule tree for obesity 1 presented in Figure 7, PISIoT provided the recommendations according to the critical variables identified each day. When the daily recommendations made for certain variables were not fulfilled for three days, PISIoT generated a greater medical recommendation. Figure 9b shows the weight-related recommendations for the 76-year-old obese elder.
Appl. Sci. 2019, 9, x 16 of 23 were identified for physical activity, daily steps, floors, calories burned, sleep, and water consumption. Based on the recommendation rule tree for obesity 1 presented in Figure 7, PISIoT provided the recommendations according to the critical variables identified each day. When the daily recommendations made for certain variables were not fulfilled for three days, PISIoT generated a greater medical recommendation. Figure 9b shows the weight-related recommendations for the 76year-old obese elder. Additionally, in the case of the 76-year-old obese elder, PISIoT recommended requesting clinical analysis and nutritionist services. The IoT-based medical services are automatically suggested by PISIoT to allow elders to select the service they prefer based on time availability, location, cost, and confidence. Likewise, PISIoT notifies the doctor associated with the patient. The clinical analysis results were high due to poor diet and poor mobility. For this reason, the elder received his new diet plan in the first week of the second period of monitoring, with the purpose of reducing his weight, BMI, and the likelihood of a myocardial infarction. Subsequently, following the new nutritional plan and PISIoT recommendations, the monitoring process was continued. By the end of the second period, the 76-year-old elder managed to lose 5 kg, achieving a weight of 86 kg and a BMI of 31.2.
On the other hand, at the end of the second period, it was identified that 100% of the elderly people monitored managed to lose weight (from 1 to 5 kg) and lower their BMI. Figure 10 presents the weekly average for each variable for each of the 40 elderly people in the last week of the second period. Additionally, in the case of the 76-year-old obese elder, PISIoT recommended requesting clinical analysis and nutritionist services. The IoT-based medical services are automatically suggested by PISIoT to allow elders to select the service they prefer based on time availability, location, cost, and confidence. Likewise, PISIoT notifies the doctor associated with the patient. The clinical analysis results were high due to poor diet and poor mobility. For this reason, the elder received his new diet plan in the first week of the second period of monitoring, with the purpose of reducing his weight, BMI, and the likelihood of a myocardial infarction. Subsequently, following the new nutritional plan and PISIoT recommendations, the monitoring process was continued. By the end of the second period, the 76-year-old elder managed to lose 5 kg, achieving a weight of 86 kg and a BMI of 31.2.
On the other hand, at the end of the second period, it was identified that 100% of the elderly people monitored managed to lose weight (from 1 to 5 kg) and lower their BMI. Figure 10 presents the weekly average for each variable for each of the 40 elderly people in the last week of the second period.
Additionally, it was found that weight loss was achieved largely thanks to real-time monitoring and the recommendations by health professionals that were generated by PISIoT, once the risk variables of weight gain had been identified. In addition, after data analysis, it was found that the patients fulfilled some or most of the recommendations issued by PISIoT, which was subsequently reflected in a positive change in the variables related to the recommendations.
In the third period (February-May 2019), although the weight and BMI of the elderly people decreased, they remained at obesity level 1. Figure 11a shows the biomedical and other variables monitored in this period for the 76-year-old obese elder (now weighing 86 kg), in which it can be observed that there was a decrease in caloric intake and an improvement in the average resting heart rate. Additionally, an increase in daily steps, calories burned, minutes of activity and water consumption was identified. However, it was also observed that the elder got less than eight hours of sleep. Again, PISIoT provided the corresponding recommendations based on the recommendation rule tree for obesity 1. Additionally, it was found that weight loss was achieved largely thanks to real-time monitoring and the recommendations by health professionals that were generated by PISIoT, once the risk variables of weight gain had been identified. In addition, after data analysis, it was found that the patients fulfilled some or most of the recommendations issued by PISIoT, which was subsequently reflected in a positive change in the variables related to the recommendations.
In the third period (February-May 2019), although the weight and BMI of the elderly people decreased, they remained at obesity level 1. Figure 11a shows the biomedical and other variables monitored in this period for the 76-year-old obese elder (now weighing 86 kg), in which it can be observed that there was a decrease in caloric intake and an improvement in the average resting heart rate. Additionally, an increase in daily steps, calories burned, minutes of activity and water consumption was identified. However, it was also observed that the elder got less than eight hours of sleep. Again, PISIoT provided the corresponding recommendations based on the recommendation rule tree for obesity 1.  Additionally, it was found that weight loss was achieved largely thanks to real-time monitoring and the recommendations by health professionals that were generated by PISIoT, once the risk variables of weight gain had been identified. In addition, after data analysis, it was found that the patients fulfilled some or most of the recommendations issued by PISIoT, which was subsequently reflected in a positive change in the variables related to the recommendations.
In the third period (February-May 2019), although the weight and BMI of the elderly people decreased, they remained at obesity level 1. Figure 11a shows the biomedical and other variables monitored in this period for the 76-year-old obese elder (now weighing 86 kg), in which it can be observed that there was a decrease in caloric intake and an improvement in the average resting heart rate. Additionally, an increase in daily steps, calories burned, minutes of activity and water consumption was identified. However, it was also observed that the elder got less than eight hours of sleep. Again, PISIoT provided the corresponding recommendations based on the recommendation rule tree for obesity 1.  On the other hand, upon failure to meet certain daily recommendations for certain variables in a three-day period, PISIoT generated new recommendations. The sleep-related recommendations for the 76-year-old obese elder are presented in Figure 11b. PISIoT recommended the nutritionist's service in order to draw up a new eating plan.
In the first week of the third period of monitoring, the obese elder received his new diet with the aim of continuing to lose weight, lowering his BMI, and reducing the likelihood of a myocardial infarction, thereby improving his health. Therefore, monitoring continued using PISIoT, and at the end of the third period, the elder lost another 7 kg, achieving a new weight of 79 kg and a BMI of 28.7. As a result, PISIoT reclassified him as overweight.
PISIoT recommended clinical analysis and nutritionist services for the 76-year-old elder to confirm he was in good health for his new weight and to draw up a new nutritional plan in order to maintain this weight, as drastic changes in weight in such a short time are not recommended due to the risk of decompensation or other complications. Finally, at the end of the third period, it was identified that, fortunately, 40% of the elderly people monitored achieved weight loss (from 1 to 7 kg) and a lower BMI. Accordingly, PISIoT reclassified them; that is, they went from obesity 1 to overweight. Weight loss with PISIoT considerably reduced the probability of myocardial infarction for the elderly people, improved their health, and increased their quality of life.
This is a result of the fact that PISIoT uses a combination of wearable devices, smart devices, machine earning, and the IoT to prevent, treat, and monitor overweight, obesity, and associated diseases or health problems.

Findings
By using PISIoT in the case study presented, it was possible to identify a correlation between the biomedical variables (heart rate, sleep, calories burned, weight, and minutes of physical activity) and the other variables (steps, floors, calories consumed, distance traveled, water consumed, and exercise) detected by the smart devices (wearable device and smart scale). This correlation is presented in Table 3, where, in addition, the variables were placed in relation to the highest correlation identified for each biomedical variable. Some correlations are described below: • Weight gain in patients is due to an increase in calorie consumption, few or no minutes of physical activity, a reduction in the number of steps and floors, little exercise, little or no water consumption, and a decrease in calories burned, and this is likely to produce an increase in heart rate.

•
High cardiac frequency in patients correlates with other variables such as an increase in sleep and, hence, in weight due to a decrease in minutes of physical activity, exercise, steps, floors, and calories burned.

•
Little sleep correlates with an increase in heart rate and, consequently, increased calorie consumption. Likewise, there is a decrease in calories burned and, consequently, a possible increase in weight.

•
A lack of calories burned correlates with low physical activity, steps, and exercise, and there is an increase in heart rate, sleep, and possibly weight. • Increased physical activity contributes to an increase in the number of steps, floors, and exercise, and an improvement in heart rate is possible. In addition, there is an increase in calories burned, and if the same calorie intake is maintained, weight decreases. The elderly people's weight loss was a result of their discipline and readiness to follow the dietary plans and comply with PISIoT recommendations during the monitoring periods, and their honesty in reporting food and drinks consumed.
In this sense, it was found that support from family members is vital because members of this age group have difficulties using new technologies, especially applications of this type. In some other cases, elderly people might forget to record food. For this reason, family members recorded food and drinks, assisting the elders and providing greater motivation to achieve their loss weight objective and reduce the likelihood of experiencing a myocardial infarction or other diseases associated with overweight and obesity.

Conclusions
The human body is constantly providing information about one's state of health. This information is obtained through systems or devices that measure, capture or detect values and variables at specific points of the body in an invasive or non-invasive manner. Healthcare personnel use the values of biomedical variables to make decisions on diagnoses and treatments in order to improve patients' health. Across the world, quality of life, particularly among the elderly, is being affected considerably by overweight and obesity. The IoT makes it possible to interconnect, detect, identify, and process data between objects or services to fulfill a common objective. The main advantages of IoT in healthcare are the monitoring, analysis, diagnosis, and control of conditions such as overweight and obesity, and the generation of recommendations to prevent them. However, the objects used in the IoT have limited resources, so it is necessary to consider other alternatives for data analysis, such as machine learning. Machine learning is a subset of artificial intelligence that consists in studying the algorithms and statistical models used in computer systems in order to achieve specific objectives effectively, based on patterns and inferences.
At present, there are several challenges in the health sector that provide areas of opportunity for the IoT and machine learning to provide solutions or alternatives that contribute to improving healthcare and quality of life. In this work, we have presented PISIoT: a machine learning and IoT-based smart health platform for the prevention, detection, treatment, and monitoring of overweight and obesity. Weka API and the J48 machine learning algorithm were used to identify critical variables, while Apache Mahout and RuleML were used to generate medical recommendations. Finally, to validate the PISIoT platform, we presented a case study on the prevention of myocardial infarction in elderly patients with obesity by monitoring biomedical variables. The main limitations of PISIoT are that, at the moment, it focuses only on the detection, prevention, treatment, and monitoring of overweight and obesity. Likewise, it uses a type of wearable device and smart scale and only uses the J48 machine learning algorithm.
In the future, we intend to consider monitoring other chronic degenerative diseases and conditions associated with overweight and obesity, such as high blood pressure, diabetes, cardiovascular diseases, and cancer (of the endometrium, breasts, ovaries, prostate, liver, gallbladder, kidneys, and colon). Likewise, we intend to use other wearable and smart devices to collect various biomedical variables related to chronic degenerative diseases. In addition, we hope to use other machine learning algorithms in order to evaluate and identify those that perform best.