Keywords

1 Introduction

Lifestyle habits and daily routine tasks have a direct impact on well-being and Cardiovascular Health. Due to lack of time and motivation, many of the actions people take in their daily lives, especially those related to diet and exercise, are not the result of thoughtful actions and do not reflect healthy choices. At this level, the existence of a recommendation system for diet and physical activity can guide its users towards healthier lifestyle habits. However, conceiving recommendation systems for these areas presents several difficulties due to the complexity of the problems, resulting from the preferences and restrictions of each individual, as well as the high uncertainty associated with the success of the recommendations.

In this domain, the Case-Based Reasoning (CBR) approach, which consists in proposing similar solutions to the previous successful cases, presents itself as a technique with identical characteristics to the human reasoning. The study of cognitive science has demonstrated that humans do not only learn concepts and tasks, but they also learn to generalize and easily adapt to novel situations. Based on their past experiences, even with few examples, they have the ability to infer new knowledge and new ways of solving problems. The human capacity for generalizing is supported, therefore, in the knowledge of similar cases that have occurred in the past. Human reasoning uses memory and by analogy or association with previous similar successful solutions, it is able to propose solutions to new problems [1]. Due to its ability to propose solutions in areas where the knowledge domain is limited and uncertain, to solve complex problems and to improve the performance of the system with experience, CBR becomes an oriented approach to artificial intelligent systems in the real world [2, 3].

The aim of the present work is to implement a recommendation system based on a CBR approach that helps its users to adopt a healthier lifestyle. The system proposes a 30-day diet and exercise recommendation plan. The paper is divided into five main sections. This first part briefly introduces the case under study and the next chapter gives an overview about different applications of CBR. In its turn, Sect. 3 describes the considered methodology for the implementation of the proposed system, whereas Sect. 4 demonstrates some functionalities of the developed system. Finally, the last section presents the main conclusions and some possible future work.

2 The Evolution of Case-Based Reasoning

The first CBR system mentioned in the literature is the program Cyrus, developed by Janet Kolodner, in 1983 [4]. Cyrus is a software that enables to retrieve events related to the former Secretary of the USA, Cyrus Vance. It acts as a program to answer questions about this political dignitary [5]. In the late 1980s, the first CBR systems for the medical field appeared, such as CASEY, which was introduced by Phyllis Koton in 1988. Casey is a CBR software that uses the United States Heart Failure Program as a model to diagnose heart problems and, as a result, to propose appropriate treatments [6]. In the field of food recommendation systems, [7] proposes Chef, a recipe recommendation system for Szechwan cuisine, based on users requests. In 2003, [8] created Mikas, a menu recommendation system, based on CBR, that takes into account the needs and preferences of the users.

An important evolution in the food recommendation systems occurred with the integration of ontologies. One of the examples of this inclusion was proposed by [9], in 2008, as part of the first Computer Cooking Contest. The authors presented ColibriCook, a CBR system that uses an ontology to adapt culinary recipes according to the requests of the users. In general, the vast amount of the developed CBR systems do not analyse the evaluation of the success of the recommendations based on quantifiable metrics. Instead, these systems typically use the feedback given by the users or experts to classify the results. In addition, there are few examples in previous research integrating ontologies with CBR presenting a comprehensive view of health and well-being, such as proposing joint recommendations of nutrition and physical exercise.

3 Methodology

3.1 The Proposed System

The developed system consists in a CBR approach that is supported by cardiovascular well-being indexes. These indexes are calculated based on a set of personal and clinical data, using an adapted methodology from QRisk2 [10], and support the evaluation of the success of the recommendations. For the implementation of the system, each case is represented by a description, containing a set of relevant attributes, a justification, a solution and a result, as listed in Table 1.

Table 1. Case representation structure.

Regarding the data, we considered a mixed persistence with two MySQL databases [11], to store and retrieve the data (a case base and a general archive), an ontology created with Protégé 5.5 [12], for adapting the solutions of the cases, and a set of Semantic Web Rule Language (SWRL) rules, for inferring knowledge based on the individual restrictions of each user. The ontology represents the available knowledge about nutrition, physical exercises, and restrictions. Since it stores the most important properties and values in these domains, the ontology serves as a basis for recommending the best options regarding diet and exercise. Considering the specificities of each user, it enables to calculate the similarity between menus and between exercises and to recommend the most similar ones. The option for a single ontology encompassing these knowledge domains allows to separate the different concepts, on the one hand, and to integrate all the knowledge required for the implementation of the system in the same structure, on the other hand.

In the food domain, the ontology is organised according to the classes Dish, Type of Dish, Type of Meal, Season, Ingredients and Nutrients. On the other hand, in the field of physical exercise, the ontology is divided considering the main types of exercises: Flexibility, Resistance, Strength and Balance [13]. Moreover, the ontology also contains the “UserRestriction” class, which is divided into two subclasses related to the dietary and physical restrictions of the users. In addition to these aspects, the ontology has a set of object and data properties that, together with SWRL rules, allow inferring knowledge. For example, in the case of a user who is lactose intolerant, it is necessary to ensure that none of the proposed menus contains any type of dairy ingredients. To address this limitation, the following rule was defined:

figure a

To infer knowledge from the ontology, axioms and rules, Pellet was the chosen reasoner.

3.2 Case-Based Reasoning Steps

Retrieve. The process of retrieving the most similar cases starts by applying the k-Nearest Neighbors (k-NN) algorithm and selecting the k cases from the case base that are most similar to the query (new case). For this purpose, the local similarities between the attributes of the query and the attributes of the cases from the case base are calculated and the global similarity for each case with respect to the query is returned. With the goal of eliminating cases that have a low global similarity with the query, we de-fined a minimum threshold and only considered the cases with a similarity above this value. Consequently, there may be Cold Start (CS) situations, in which no case is re-turned. In these cases, it is necessary to consider fixed rules to do the recommendations. Therefore, depending on whether any cases are returned, there are two different methods to consider in the process: the CS problem and the determination of the most similar case. Figure 1 schematically illustrates the main steps to retrieve the cases.

Fig. 1.
figure 1

Considered methodology for case retrieval.

The rules to be applied in CS situations have been defined based on the recommended dietary intakes indicated in [14], and vary according to the characteristics of the users.

Regarding the determination of the best case, we established Eq. 1, considering that the index variation corresponds to the average variation of the cardiovascular well-being index, and that the degree of success reflects the confidence in a successful result. Using this equation these values can be converted into a score and the best case corresponds to the returned case with the highest value.

$$Score\, = \,Similarity\, \times \,Index\, Variation\, \times \,Degree{\text{ }}of{\text{ }}Success$$
(1)

Reuse. The solution obtained in the previous step must be adapted to the new case, considering the restrictions, preferences and specificities of the new user. More concretely, to adapt the diet plan, the dietary restrictions, food preferences and recommended caloric intake of the new user must be taken into account. In this case, the methodology for adapting the solution begins with the execution of the following steps:

  1. 1.

    Retrieving the available menus: all the menus that satisfy the recommended calories intake for that user, according to the type of meal (breakfast, lunch, snack and dinner).

  2. 2.

    Retrieving the restricted menus: i.e. menus that contain at least one ingredient to which the user has an intolerance or is allergic.

  3. 3.

    Identifying the possible menus: i.e. menus that the user can eat (menus retrieved in step 1. but not indicated in step 2.).

After these steps, the methodology varies depending on the type of retrieval. Thus, towards a CS situation, the methodology is completed by the following procedures:

  1. 4.

    a) Retrieving the menus that comply with the CS rules: i.e. menus that respect the CS applicable rules.

  2. 5.

    a) Proposing menus: first, the similarity between the menus from 4.a. and the preferences of the user is calculated. Then, the results are sorted in descending order according to the similarity values obtained. Finally, the three most similar menus are selected and proposed.

  3. 6.

    a) Selecting the recommended menu: the recommended menu corresponds to the menu selected by the user among the three suggestions and becomes part of the meal plan.

Conversely, when a similar case (best case) is retrieved, the first three steps are followed by:

  1. 4.

    b) Retrieving the equivalent menus: the nutrients of each possible menu from 3. are compared to the nutrients of the reference menu (best case) using similarity measures. Only the menus with a similarity higher than a predefined threshold are returned.

  2. 5.

    b) Proposing menus: first, the similarity between the menus from 4.b. and the preferences of the user is calculated. Then, the values of similarity in terms of nutritional values and similarity in terms of preferences are weighted and the results are ranked in descending order. Finally, the top three menus are selected and presented to the user.

  3. 6.

    Selecting the recommended menu: the user selects a menu from the available options and that menu is included in the meal plan.

For the execution of these steps, we developed code in Java and constructed SPARQL statements in order to execute the connection to the ontology and to return the menus to recommend.

The adaptation process of physical activities involves a similar methodology. The first step consists in retrieving the available exercises for the user, considering his/her restrictions. These restrictions are related to injuries or physical limitations in specific parts of the body, equipment availability, and the time and intensity that the user is willing to dedicate to the exercise.

In a next step, to define the methodology for the CS problems, we followed the recommendations of [15, 16] and converted them into rules. Thus, we created SPARQL statements in order to filter only the exercises that comply with the CS rules. After, for each returned exercise, the similarity with the user’s preferences is calculated, and the exercises with the higher values are proposed for selection. On the contrary, when the best case is returned, the similarity is determined considering the proximity between the types of exercises and the user’s preferences. Again, the exercises with the highest similarities are proposed for selection.

Revise. Since in CBR approaches the correspondences between cases are not completely equal, and there is no guarantee that all cases behave the same towards the same solutions, the system requires a later validation of the proposed solutions. First, the result of the case must be classified as a success or a failure, depending on the variation of the index calculated by Eq. 2, where Vfinal is the value of the index after the end of the plan and Vinitial is the value at the beginning of the plan.

$$Index\,variation\, = \,\frac{{V_{{final}} - V_{{initial}} }}{{100}}$$
(2)

As there is no linear correspondence between a solution and the result of each user, it is possible that successful and unsuccessful results regarding the same case exist simultaneously in the case base. Therefore, an important metric to take into account is the degree of success of the cases in the case base. This metric reflects the probability of the solution to produce a successful result, considering the ratio between the number of successes and the total number of cases, as given in Eq. 3.

If the result is successful, 1 unit is added to the number of successful cases and the degree of success is updated according to the equation. On the other hand, if the outcome is not successful, 1 unit is added to the number of unsuccessful cases. In this case, if the degree of success is high, the next step is performed and, if it is low, the case is removed from the case base. This occurs because the case already contains a significant number of unsuccessful cases and, for this reason, it must not support the recommendation system.

$$ DS = \frac{numSuccess}{{numSuccess + numUnsuccess}} $$
(3)

Retain. At the end of the review phase, the new successful cases are stored in the case base and/or in the archive, as summarized in Fig. 2. In these situations, it is necessary to verify whether the 30-day plan is similar or significantly different from the plan of the best-case solution. If it is similar, the attributes of the new case are added to the best-case attributes. If not, the case is only inserted into the archive and when that case represents a considerable number of records it is inserted into the case base as a new case. The same methodology is followed when the retrieval is done using CS rules.

Fig. 2.
figure 2

Considered methodology for retaining cases.

The inclusion of a new record into one of the existing cases in the case base is done in a weighted way, taking into account the number of cases that are represented by the existing record in the case base. Considering that the case record represents n cases, then, each of its parameters will assume new values, according to the Eq. 4, where NVi represents the new value of parameter i, NCi is the value of parameter i of the new record, and IVi is the initial value of parameter i in the case base.

$$ NV_{i} = \frac{{NC_{i} + n \times IV_{i} }}{n + 1} $$
(4)

4 The Developed System

To implement the proposed system, we developed an application using Java and JavaFX in order to enable the interaction with the users. For evaluating the created program, we performed some tests inserting new queries. Each time a new case is introduced, the program asks for some personal and clinical attributes of the user, which are required for the CBR steps. In the next phase, the application performs the retrieval and the reuse stages. At the end of this step, the window depicted in Fig. 3 appears to the user indicating three alternative dishes for each meal. At this point, the user must specify his/her preferences by selecting a single option for each meal.

Fig. 3.
figure 3

Graphical interface displayed after inserting the values of the query.

After choosing the preferred menus, three types of exercises are presented. Similarly, the user should select one of the available options. Once confirmed this second choice, the system stores these data in the archive. This recommendation procedure is repeated daily until the plan is completed. At the end of the 30-day plan, the user is asked to update his/her clinical values in order to determine the success/failure of the proposed solution.

5 Conclusions and Future Work

This paper describes the development of a recommendation system in the field of nutrition and physical activity, following a CBR approach supported by databases and an ontology to adapt the cases. This work leads to the conclusion that it is possible to implement a recommendation system in the domain of Health, without requiring human intervention to verify the success/failure of the recommendation. Furthermore, the present work has highlighted that the knowledge integrated in an ontology permit an efficient adaptation of cases.

In summary, since it is not always possible to dedicate much attention to our daily choices, the proposed system can promote the adoption of healthier lifestyle habits, by proposing personalized recommendations for food and exercise. However, there are some important issues that need to be examined in future research. The most obvious is data limitation. Since no real data were used, the effectiveness of the system in promoting cardiovascular health could not be tested. Moreover, further studies in this area should consider additional aspects that were not contemplated in the present work, such as remote communication and security issues. Another opportunity for improvement in future work would be to consider the quantities of the ingredients and propose different portions of each menu according to the nutritional needs of the users. It would also be interesting to explore the combination of different workouts in the same exercise recommendation.