In-home monitoring system based on WiFi fingerprints for ambient assisted living

This paper presents an in-home monitoring system based on WiFi fingerprints for Ambient Assisted Living. WiFi fingerprints are used to continuously locate a patient at the different rooms in her/his home. The experiments performed provide a correctly location rate of 96% in the best case of all studied scenarios. The behavior obtained by location monitoring allows to detect anomalous behavior such as long stays in rooms out of the common schedule. The main characteristics of the presented system are: a) it is robust enough to work without an own WiFi access point, which in turn means a very affordable solution; b) low obtrusiveness, as it is based on the use of a mobile phone; c) highly interoperable with other wireless connections (bluetooth, RFID) present in current mobile phones; d) alarms are triggered when any anomalous behavior is detected.


I. INTRODUCTION
According to United Nation Population Division of the Department of Economic and Social Affairs 1 , by 2050, the number of older persons in the world will exceed the number of young for the first time in history, the proportion of older persons is projected to reach 21 per cent in 2050, in the case of developed countries this ratio will reach on third of the population. The world urban population in expected to increase by 84% by 2050. This grow will be faster in developing countries than in developed countries. On the contrary, rural population is expected to decrease slowly after 2020 2 . Elder population in urban areas is rising, because of the decline in the birth rate and population movements from rural to urban areas. This is true even in developing countries.
There is a short-term impact on jobs of their families and caregivers, as well as a long-term impact in their career and retirement savings. As an example, it has been estimated that unpaid caregivers provide 17.5 billion hours which can be valued in terms of money as much as 216. 5

billion dollars in 2012 3 in USA.
Several studies have shown that age people want to live at home as long as possible [1], [2]. Aging in place (AIP) 4 is defined as the ability to live in one's own home and community safely, independently, and comfortably, regardless of age, income, or ability level. Age people living in home represents a short-term challenge in developed countries and a medium-term challenge in developing countries. Caregivers are mainly family and friends which cause loss of productivity and income, as well as stress related illnesses [3].
In-home monitoring systems has become a valuable tool for elder people to live in their own homes while providing supportive services for healthcare illness prevention. Following the systems classification given in [4], we present a system for independent living and remote monitoring. Consumers of the data provided by the monitoring system are not the individual being monitored, but the healthcare practitioners, caregivers, families and friends, which will receive the longterm trends and automatic alarms triggered in case of anomalous behaviour.
Most of the in-home monitoring systems already presented, are based on sensor networks deployed at home. Main sensor types used in these networks range from inexpensive passive infra-red motion sensors to video cameras. Some of these technologies are seen obtrusive, specially in the case of video cameras. Moreover, such solutions, based on ad-hoc hardware deployment are seen uncomfortable, impractical and expensive in some cases.
Ambient Assisted Living (AAL) aims enhancing the quality of older people by means of the use of Information and Communication Technologies (ICT) 5 .
In this paper, we present a non-obtrusive, inexpensive and easy to use in-home monitoring system based on Wi-Fi fingerprints registered by a smartphone. Although there are other technologies available for in-home monitoring, such as bracelets and watches, smartphones has the advantage of being a tool for human communication, since direct communication can be established between the user and any person, institution, organization or company in charge. Figure 1 shows the growth in the use of Internet connection by year and age group, it can be seen that more age people is using Internet at home, and most of them are using Wireless Access Points (WAPs) for that. Moreover, the current trend is that age people is adopting the use of smartphones to keep in contact with relatives and friends. Current data provided by Eurostat 6 states that 64.5% of the population in Spain live in flats, and 21.1% in attached houses, and 20% of the population between 65 and 74 years old, retired or inactive access to the Internet using mobile devices. The proposed system is able to locate a person within a room under a few margin of error, so continuous indoor monitoring of person's location can be done in real time. By comparing the current and expected person's location along the day, anomalous behavior can be detected which in turn, could switch on some alarms. The systems has been validated in seven different real scenarios (urban flats in Spain), including location and behavioral checking. The system is able to locate the person at the correct room at a rate of 96% in best case, and 73% in the most challenging scenario, due to its room layout. If the access point at housing is not considered, the percentages diminish in 2% in the best case, which means that the system is feasible enough in those cases without an own at housing WiFi.
The rest of the paper is structured as follows, Section II presents works related with in home monitoring, gives a characterisation based on eight items and classifies these works according with this characterisation; Section III gives and overview of the system presented highlighting the main points according the characterisation given in the previous section; Section IV describes the materials used to deploy the system and the methods used to acquire the data; Section V presents the experiments performed to validate our system; conclusions and lines of future work are given in Section VII.

II. STATE OF THE ART
This section introduces first WiFi-based Fingerprint positioning systems, and review some presented works on the topic. Then, some directly related work on in-home monitoring is reviewed in this section. Main characteristics or theses works are extracted for a later classification, which is summarized in Table I. Finally, a comparison between all these works and ours is presented at the end of this section.
WiFi-based Fingerprint positioning systems are based on the Received Signal Strength Indicator (RSSI) level from the Wireless Access Points (WAPs). One of the major advantages of the methods based on WiFi fingerprints is that they do not require the installation of any additional hardware since they use the existing WiFi infrastructure. Therefore, the location of the user can be obtained without additional infrastructures and costs. However, WiFi was not natively designed to support a positioning function. Taking into account the existing obstacles introduced by the indoor environment (including reflections and multi path interference) the spread of radio signal in indoor environments is very hard to predict [5]. In addition, in WiFi-based positioning systems, the user typically carries the smartphone with him, being his motion or how the device is carried an important factor that affects the measured RSSI values [6].
There are some indoor location solutions, such as [7], [5], [8], [9]. In [5] a new WiFi-based fingerprint method was proposed which uses a previously stored map of the signal strength at several positions and determines the position using similarity functions and majority rules. In [8] a different approach that uses only the rankings of the RSSI values is used. Authors argue that their method is better to avoid the well known problem of having hardware and software differences between user devices. There are other alternative technologies to obtain indoor localization, such as [7] which uses a RF-based method, and [9] which performs localization with a Frequency Modulation (FM) signal-based method.
There exist some papers that review the works presented in the field of AAL, some of them extensively review the works directly related with fall detection, while others review wearable sensor based systems. Axisa et al. [10] present a review of smart clothing technologies for healthcare, illness prevention and citizen medicine. These technologies are based on devices directly attached to the human body and are able to measure some physical constants as skin temperature and conductivity. Some of the reviewed solutions can also determine the location of a patient (user) inside a building and to use Global System for Mobile communications (GSM) smartphone networks to notify alarms. It is worth noting that most of the reviewed works in this paper are proprietary solutions.
User requirements for wearable health monitoring sensors are explored in [4]. From the authors point of view, the most challenging points when developing wearable sensor for in home health monitoring are: reliability and robustness, unobtrusiveness, user identification, communication, zero maintenance and fault recovery. Communication approaches are review in detail as it plays a central role in the independence of living in home.
A survey of fall detection technologies is presented in [11]. The analysed methods can be grouped into three main category: wearable device, ambiance device and camera-based. All of these methods have multiple drawbacks and require the user to acquire some special equipment or accessory as wearable sensors or video cameras.
Taking into account the previously mentioned classification, the most representative works are commented. To recall, the ambiance device approach is to use a variety of sensors installed in the house. These sensors detect when a person is close enough and, therefore, detect the location of the person. In [12], InfraRed (IR) sensors are used to monitor the presence in rooms with no doors, while magnetic switch sensors are used in rooms with doors. Falls are detected using an ad-hoc sensor which bases its operation on the data fusion coming from three different sensors: accelerometer, tilt and vibration sensors. All information is transmitted using RF signals to an in-home or remote processor unit. IR and magnetic switch sensors are cheap, but the ad-hoc sensor to detect falls could be expensive. Communications are performed using RF, so some adapter device would be needed to interconnect to the Internet. Demongeot et al. present in [13] a system to monitor patients in home. Passive InfraRed (PIR) sensors attached to each room are used for patient location, generic accelerometer sensors are used to detect falls, and specific sensor are used to measure the respiratory rhythm, blood pressure and cardiac parameters. Communications between sensors and a processor unit are established by means of the Controller Area Network (CAN) [14]. XML format is used to transmit and store data, but any other neutral language could be used, for example json. Data is taken each hour, and used to detect deviation from a predefined behaviour which, in case, set off alerts to note them. In [15] a method for helping in the medicine intake management task is presented. This system check the possibles conflict in the prescribed medicines of elder people. The medicines information registration is automated using a RFID card. Additionally, the data of the system can feed other subsystems in a Smart House. The work in [16] describes a flexible floor-based indoor localization. This system is based on capacitive sensing that is specifically designed to detect position and potential falls of users in a home environment. They are using passive floor mats of a rectangular shape equipped with active sensor elements on two adjacent outer sides. In [17], the authors have developed n-Core Polaris. This system defines a sensor network thought Zigbee sensors. The sensor network comprises tags, readers and sensor controllers. A web server connects to readers and offers the location info to a wide range of possible client interfaces. A database is created to register historical data, such as alerts and location tracking. In [18], the authors present iLoc. iLoc uses an ultrasound ranging for indoor localization. This system comprises badges, detector nodes (located at known fixed positions) and a position server. The badge is an ultrasound transmitter. It emits ultrasound pulses. The detector nodes receive these pulses and send the reception times to the server. The server calculates badge position. The work in [19] presents a method for indoor positioning using microwave signals. For this purpose, they use beacons and transponders. The beacons are located in different reference points. The transponders are placed on objects (elders). Each beacon selects the low frequency difference signals. Based on these measurements the distances to transponders are calculated.
Some other works in the AAL field use some kind of wearable device plus a camera device. A smart home based health for monitoring diabetes patients is presented in [20]. The system is able to integrate data coming from wearable sensor, environmental sensor (temperature, humidity, light, etc.) and cameras. Local transmission is wireless and can be securely provided by means of Internet services. Analytic is used on the raw gathered data to recognize the activity of the monitored patient, and to give feedback to the patient in form of recommendations about food habits. The work presented in [21] uses different data sources to determine whether a person falls. This data sources consists of motion information, audio stream and video images. The data are obtained from wearable device such as overhead cameras, microphone arrays and body sensors. The analysis of this data detects a fall. Furthermore, this system estimates the gravity of the fall monitoring the data after the fall. It uses a ontology and rule-based evaluation for the purpose. Ozcan et al. [22] propose another video camera-based approach for fall, sit and lying down detection. In this system, the user wear CITRIC camera and the computation needed analysis is performed with an embedded microprocessor. The image analysis method is based on the oriented image gradients, which takes into account the orientation of the camera frame during a fall.
A different approach is proposed in [23]. Owl Positioning System (OwlPS) is a WiFi based for indoor positioning. This system is composed of a smartphone, WAPs, aggregation server and positioning server. The smartphone sends different packages and each WAP extracts the corresponding RSSI. Next, the aggregation and position servers recollect and anal-yses the packets and obtain smartphone's position.
In order to compare the formerly reviewed works, we propose the following characteristics as they well describe them in the context of AAL: • Sensor Type: refers to the type or types of sensors used for ambient monitoring. • Cost: the cost in terms of money and efforts to deploy the monitoring system. Scale: Expensive, Average, Cheap, Inexpensive. • Scalability: how easy it is to add new rooms/ambients to already monitored areas. Scale: High, Medium, Low. • Obtrusive: the feelings of the users about their privacy invasion: High, Medium, Low. • Connection: how the sensors are connected with the monitoring system. Scale: WiFi, Zigbee, Ultrasound, others. • Interoperable: could be the system described interconnected with other monitoring systems: glucose, heartbeat, and others. Scale: Yes/No. • Extensible: can be the system used in other kind of monitoring use. Scale: Yes/No. • Alarms: how the user is connected with the people in charge of the monitoring system. Scale: SMS, e-Mail, phone call, others. Table I shows the classification of works reviewed according the above characteristics.
As it has shown in Table I, most of the works use systems that requires to add new sensors. Our system does not require neither new underlying infrastructures or new sensors. The only device needed is a smartphone, which, in most of the cases, is funded by the telephony provider company. The proposed system works through WiFi in the neighborhood. Even, it can work correctly without own WiFi. Thus, our system is cheaper than other works.
The patients must carry only their own smartphone and it does not require new additional sensors, then the patients do not feel that our system is obtrusive. As formerly said, 20% of the population between 65 and 74 years old, retired or inactive access to the Internet using mobile devices, so they already use to carry a smartphone in their daily lives. Other works install different sensors or gadgets and they can interrupt the normal life of patients.
In comparison with other works, another aspect that our system improves is the interoperability with other sensors. Nowadays the smartphones offer different kinds of connections, like Bluetooth, Wi-Fi, NFC, etc. These connections can be used to add new sensors data that will potentially improve the monitoring of the patient. For instance, it may be added a pulse sensor connected to the smartphone using Bluetooth, and the pulse readings could be sent through the smartphone.
Moreover, it allows the extensibility in other kind of monitoring use. In this case, elders monitoring has been chosen, but the system allows monitoring other people/things. Based on our location method, and addressed to AAL, we have developed an alarm system in charge of notifying anomalous behavior in the day-life of elder people.
Our alarm system, in contrast to other works, allows to use different kinds of alarms, depending on its warning level. A emergency notification protocol has been defined to notify if any kind of alarm has happened.

III. SYSTEM OVERVIEW
The proposed system aims to localize a patient (user) inside her/his home (flat) by a WiFi Fingerprint-based positioning system. It is based on the Received Signal Strength Indicator (RSSI) value of all the WAPs present in a neighborhood. These values can be captured using a smartphone. A fingerprint consists of a vector with the RSSI value of all the detected WAPs. The WiFi fingerprints change depending on multiple variables. One of the most important variables is the position where the fingerprint is taken.
The main conceptual parts of the proposed methodology are shown in Figure 2 and explained as follows: • WiFi signals: these are emitted by each WAP that it is accessible to the patient's smartphone. This will include the user's WAP if it exists. The method does not require to know the physical location of each WAP. For the proper functioning of the system, no additional installation is required. • Mobile client: the patient must carry the mobile when she/he is at home or at least the smartphone must be in the same space. This client is the first entry point to launch alarms to the patient. • Cloud services: these services are divided into two modules, positioning module and behavioral module. The positioning module receives a WiFi-based fingerprint and processes the fingerprint to finally obtain the user's current location. The behavior module is connected with the positioning module to compare the user's current behavioral pattern with a predefined and specific pattern for the user. If some remarkable discrepancy between the two patterns is found, an alarm is triggered. These cloud services can be concurrently used by different patients at the same time. • Alarms: when the behavior module detects an anomalous pattern an alarm can be triggered.
In order to deploy the system in a particular scenario, two main stages are required. They are configuration stage and operation stage. The configuration stage is necessary to provide information about the scenario (patient's flat) and to create a fingerprint database (prior knowledge), in order to establish a relation between a fingerprint and a flat's room. The operation stage is responsible to periodically send the fingerprints to the cloud services to locate patient's position at any time. This period is typically of two minutes, although can be configured to save the smartphone battery life. The received fingerprints in the operation stage, in the simplest way, are compared to the fingerprint database to predict their position. The behavioral module is also included in the operation stage, and is used to detect any anomalous pattern. When this module recognizes such anomaly, it triggers the corresponding alarm. Different alarms receptors can be defined, they are the own patient, her/his family or a health practitioner.

A. Indoor positioning
A spectacular growth of indoor localization studies has been witnessed during the last decade. There are also many works dealing with the indoor localization problem by using WiFi-based techniques. However, the concept of localization in the herein proposed system is simpler than those multiuser multi-building multi-floor indoor positioning systems. In fact, the proposed system can be considered a single-user single-building single-floor localization problem which has the following features: • The scenario is a flat which is anonymously identified by a unique identifier of the user's device. • Location is based on labels, not in X/Y/Z coordinates. • The device used in both stages (configuration and operation) is always the same: the user's smartphone. First, the system is only able to localize the user inside her/his scenario, which corresponds to a single flat. Second, we do not need the exact coordinates of the person inside the flat, our system only predicts the place (room of the house) where the person is. Finally, location completely relies on the device used. According to prior experiments we performed, the WiFi-based fingerprint values partially depends on the device used. Depending on the brand and device model, the number of WAP detected and the obtained intensity levels vary. With this device-based location, the device's brand and model effects on fingerprints is completely minimized.
In the configuration stage, a radio map (or training database) of the area where the users should be detected is constructed. Several samples in each space are taken to create a database where the WiFi intensities and the ground truth (space where it was taken) are known. Later, during the operation stage, a user obtains the signal strength of all the visible WAP's that can be detected from her/his position and creates a test sample which is compared to the training set. In the simplest solution, the user's location corresponds to the position associated with the most similar sample in the radio map.
The configuration stage has two different steps: Setup and Training. The Setup step is required to establish the basic data required for the location system: number of rooms, label for each room (e.g, Kitchen), photography for each space (e.g, Living-room) and personalized alarms.
In the training step a WiFi-based fingerprint database (radio map) is generated which is the basis of the localization performed in the operation stage. Since the aim of this step was to store several WiFi-based fingerprints correctly labeled (space/room where the user is), a smartphone application was developed (see some examples in Figure 3). This application allows the user to get space-labeled fingerprints. In particular, it allows the user to select where it is located, and it also allows to send to a centralized server 10 different WiFibased fingerprints measurements by pressing a user-friendly interface. It is necessary to take several fingerprints (10 in our case) since Wi-Fi signal is harsh and it varies across time even if the time period is quite small (e.g. less than 1 second). The application changes the background image according to the space (kitchen/wc/...) where the user is to provide a visual representation of the space and, therefore, avoid errors in labeling. On the server side, a web service has been deployed to store the fingerprints sent by the smartphone into a database. All the fields sent by the device were kept unchanged, but a server-based timestamp was included.
The operation stage was developed in order to periodically send a WiFi fingerprint to the server for localization purposes. This service is run on background in the patient's smartphone, so it does not require any interaction with the user. The localization and further analysis are fully performed in the server side.
In this contribution, indoor location is dealt as a machine learning problem. Instead of providing explicit rules to predict the current room for an operational fingerprint, we use machine learning techniques to create a mathematical model that learns the rules from the fingerprints taken at the configuration stage. In this particular problem, room-based location can be considered a classification problem where the machine learning model has to classify the fingerprint into as many categories as rooms are in the flat. The advanced classifiers based on machine learning are generic and they usually require a training procedure to set the optimal internal parameters to apply it in a particular problem, such as the indoor location inside a flat.
To perform an assessment of the proposed space-based location, the following well-known advanced classifiers were used: the learning-based classifier Multilayer Perceptron with Backpropagation (MLP) [24], [25], the distance-based classifier k-Nearest Neighbor (kNN) [26], the learning-based classifier Support Vector Machine (SVM) (with Linear Function (LF) and Radial Basis Function (RBF) function kernels) [27], and the ensemble learning-based classifier Random Forest (RF) [28]. All these classifiers needed to adjust some internal parameters, which was done via cross validation [29] for MLP, SVM and RF. For kNN, k was established to 1.

B. Behavior modeling
A new functionality has been implemented to capture the behavior of the users. This service uses the localization system presented in the previous section to obtain the location of the user into the house each n minutes, being n a configurable parameter in the application. For instance, n has been set to 2 minutes in our experiments. In our proposed methodology, users wear the mobile phone with her/him or at least the mobile phone must to be in the same room that the user. Then, following this rule, it is possible to obtain the location of the user along a complete day.
All the information regarding the location of the user in a day is stored in the server as a matrix When enough data is available (for instance, after several days) a behavioral model M can be estimated using the probabilities that the user is into each of the spaces of the house given each time period. M is modeled as a matrix with R rows and T columns, and each element of the matrix M (r, t) stores the probability of the user staying at room r at time period t. It can be estimated as follows: where D is the set of days taking into account to build the model M . Figure 4 shows an illustrative example of the behavior modeled for an hypothetical user. In this figure, it is assumed that the 100% of the time the user is at home and always in some of the four (R = 4) following spaces: Living Room, Kitchen, Bathroom or Bedroom. Model showed in Figure 4 has T = 24, i.e. it shows the probability of staying in some of the four spaces each hour (n = 60). The user behavior can be explained as follows: she/he gets up between 7am and 8am, spends most of the morning time in the living room, has lunch between 2pm and 3pm, takes a nap after having lunch, after nap goes to the living room, takes a bath around 7pm, has dinner at 9pm and finally goes to bed between 9pm and 10pm. This is only an illustrative example of how the behavior of the user can be modeled. In real cases, it is preferable to use small time periods for better modeling the user behavior.
A model M can be updated at the end of the day when new B D+1 data is available as follows: with α being a factor to weight how new information contributes to the actual model. People are habitual [30] and elders tends to be even more habitual. Therefore, it is expected that the most of the days the user behavior will be similar. However some different patterns can appears, as for instance, in weekend, where user can change the usual behavior. For these cases, more than one model M for each user can be modeled. Let's define Λ u as the set of all model behaviors for estimated for an user u, i.e. Λ u = {M 1 , . . . , M m , . . . , M λ u ], being λ u the total number of different models needed to explain the behavior of the user u. Usually, only two models are enough to model the most of the users, the first one for a normal day and the second one for a holidays or weekend one.

C. Alarms
As it has previously commented, it is possible to estimate in which space of the house the user stays at any moment of the day. In addition, the probability of staying in each space given a time period is also known (models Λ u ). Therefore when, in a particular time moment, the user stays in a space not in the spaces with high probability, then it can be assumed that something strange is happening. In particular, if this situation happens for a big enough number of consecutive times periods, then an alarm can be trigger. The exact number of consecutive times periods needed to trigger the alarm depends of the cases and it is configurable in the proposed methodology. Figure 5 shows and example of the activation of an alarm. It shows the behavior captured for an user between 7pm and 8pm (i.e. using n = 1). In this case, the user tends to stay at bathroom in the first half of the hour. However, she/he remains at the bathroom more time that expected. It is expected that approximately at 7:30pm user leaves the bathroom to go to the living room. However, after 10 consecutive time periods (i.e. after 10 minutes) the estimated location is different from the expected one, then a problem in the bathroom alarm could be activated.

A. Assessment of the proposed WiFi-based fingerprint Indoor positioning system
In this section, the experiments to validate the feasibility of the proposed system are introduced. First, the experimental setup is described. Second, the main results about indoor positioning with the advanced classifiers are shown. Then, we analyze the results provided by the different machine learning techniques on seven scenarios. Finally, we show the accuracy of the Indoor Positioning System based on WiFi fingerprints, after removing the signals provided by the user's Internet WAP.
1) Experimental setup: Seven completely different scenarios have been considered for the proposed system's evaluation. Those scenarios were provided by different volunteers with different locations, different smartphones, among other features. They are totally independent since: • Distance between scenarios is considerable. Even, the scenarios are dispersed/scattered in three different towns. • Features (detected WAPs) are different in all the scenarios. None of the WAPs has been detected in more than one scenario. • Users are different in each scenario. • The device was different in the seven scenarios changing brand, model and/or OS version. The WiFi-based fingerprints on those scenarios were mapped by means of the training application (see Figure 3). Captures were taken to completely cover the spaces of the scenarios. Then, two weeks later, a one-week period was established to obtain a new set of fingerprints that will be used for validate the performance of the proposed indoor localization system. This new set is call the validation set. The validation captures were taken covering the whole scenario at different time-slots (mornings, evenings, midnight, ...). Table II introduces the features (total number of WAP's detected, mean of WAP's detected per fingerprint, and number of captures per room) of each scenario. Table II shows that we have also covered different strategies in performing the captures. Also was the number of captures considered for our study, Scenarios 2 and 3 were mapped less times (there are less than 2,000 samples in total) where other scenarios, such as Scenario 1 with more than 10,000 captures, were fully sampled. In total, the whole database contains 31,501 samples (17,229 for training, 14,272 for validation). It is worth mentioning that the training samples and the validation samples were acquired in different days, with a time separation between them of, at least, two weeks. Therefore it could be big differences between fingerprints captured at training one with respect to the ones captured at validation time, simulating a real case.
Maps of Scenarios 1, 3 and 4 are shown in Figure 6. In all the maps: orange stands for Kitchen and Laundry-room, green for Living-room, yellow for Hall/Entrance/Corridor, red for Rooms (Bedrooms), blue for Bathrooms and pink for the Closets. In gray, there are spaces outside this apartment (stairs, elevator, the neighbor's home, among other spaces).
In Scenario 1, from top to bottom of the map, there are Room 1, Room 2 and Room 3. From left to right sides of the map, there are WC 2 and WC 1. In this scenario, the second bathroom is inside the third room. Finally, this flat is between two neighbor's flats as can be seen in the top and bottom sides of the map. Moreover, the left side of the map faces to street whereas the right side faces to an interior open space.
In Scenario 3 and 4, the colored rooms have the same meaning. For Scenario 3, the rooms (from top to bottom) are: Room 3, Room 2, and Room 1. Similarly, the bathrooms (also from top to bottom) are: WC 2, and WC 1. Also is the WC 2 inside Room 3 in this scenario. Note that this flat is between two neighbor's flats. In fact, the structure of Scenario 3 resembles Scenario 1 in some key features. For instance, it is between two neighbor's flats. Moreover, one side faces the street and the opposite side faces an interior open space and another neighbor's flat. However, there are also some major differences between these two scenarios distribution.
In Scenario 4, which radically differs from the two previous scenarios, the first room is the one located on the right side of the map, then the second room is the one with a bathroom inside, so the third room is the one located, in the map, below the second room. WC 1 is located in front of Room 1 and it can be accessed through the corridor, whereas WC 2 is located inside Room 2. Only one side of the flat is shared with a neighbor's flat and building stair, the other three face a street.
2) Classification results: Table III introduces the classification results obtained with the 5 different classification approaches mentioned in Section IV-A. The performance shown corresponds to the percentage of correctly classified samples (fingerprints) included in the validation set. Only samples of the training phase were considered to generate/train the base classifiers. Since SVM, RF and MLP classifiers use some random processes in the training phase, the experiments have been repeated 10 times.
The results provided in Table III shows that the accuracy of indoor location is, in general, very good. For instance, the highest overall accuracy (96.01%) is provided by RF in Scenario 4. Comparing the five classifiers in all the scenarios, 1NN is outperformed by SVMLF, SVMRBF, RF and MLP.
Although the best classification rates tends to be provided by RF and SVMRBF, the other two classification alternatives SVMLF and MLP also provide high performance.
3) Analysis of results: From the seven scenarios, three of them were selected to perform a more precise analysis. In particular, they were scenarios 1, 3 and 4 since they reported an intermediate, the worst and the best classification rates using RF as base classifier respectively. The maps of these three scenarios were shown in Figure 6. We selected the RF classifier because it provided high classification rates in the seven scenarios, it is the best performing classifier in four scenarios, and it provides the highest overall performance (96.01% ± 0.08% in Scenario 4). Table IV introduces the real confusion matrix of three spaces using the RF classifier. The columns represent the fingerprints in the predicted spaces, while the rows represent the instances in the actual spaces. For instance, Scenario 1 had 1257 instances (validation fingerprints) taken at the Living-Room which were correctly labeled (predicted) by the RFbased classifier, but 139 instances also taken in the Livingroom were wrongly predicted to belong to WC 1.
According the three matrices introduced in Table IV, it can be seen that the majority of instances (fingerprints) are in the main diagonal. It denotes that our system, based on a RF classifier, correctly predicts the actual space.
The confusion matrix of Scenario 1 shows that 87.85% of measurements are correctly predicted (the predicted space corresponds to the actual space). Kitchen and Living-room provided similar fingerprints in a few cases (3.6% of total fingerprints), this misclassification was expected since both spaces are quite close and they share a common wall. It was also the case for the two bathrooms (1.8%), Room 2 & Room 3 (1.2%), and Living-room & WC 1 (3.2%). There was a special case, which represent only the 1.3% of fingerprints, where WC 2 was confused with Room 1. This special case is due to the proximity of Room 1 and WC 1 whose doors are facing the another.
The performance in Scenario 3 was 72.64% (spaces correctly predicted). In this scenario, both WC's provided similar fingerprints (almost 4%). It was also the case for Room 1 & Room 2 (1.9%), and Room 2 & Room 3 (4.5%). Some measures taken in WC 2 were predicted to belong to Room 3 (3.1%). In the previous cases, misclassification was expected due to the location of the actual and predicted spaces (e.g, WC 2 is inside Room 3). However, there were a few spaces (WC 1 and WC 2 mainly) with very low WiFi coverage, and they reported the major part of misclassifications (but they only represent the 7.7% of total cases).
The last scenario, Scenario 4, was the one which provided the best classification results (96% of correctly classified fingerprints). The misclassifications mainly corresponded to confusion among Kitchen, Laundry-room and Living-Room (1.7%). Those three spaces are quite close so samples near the wall can be misclassified. Moreover, there existed confusion between Room 1 & WC 2 (0.5%), and Room 2 & WC 2 (0.8%). In these two last cases, the distance between the predicted and actual spaces was also very low.
In general, the confusion matrices graphically reported that the majority of spaces are well predicted. Moreover, with the help of the scenario's maps, it can be seen that the majority of misclassifications are due to the low distance between the predicted space and the actual space. As commented before, we consider that the results obtained are a success since the proposed system correctly works with the sensors already present at the scenario and it is unnecessary to include extra devices which could increase the implantation costs. 4) Results without user's Internet Router: After performing the main location with the different classifiers, a few extra location experiments were performed on all scenarios using RF as base classifier. These special experiments consisted in performing the whole classification procedure without considering the user's Internet WAP. So, in those cases the MAC associated to the user's WAP was removed from the training and validation fingerprints. With this procedure, we simulated the behavior of the indoor location in those scenarios in which the user has not an ADSL/Cable Internet connection or the modem/router does not allow wireless connections. The results of this experiment are shown in Table V.
The results in the experiment without user's WAP also provided high classification rates. In fact, the classification rate was higher than 85% in 5 out of 7 scenarios. The results in Scenario 2 were also good (a classification rate of 75.15% ± 0.27%) and the lowest value corresponded to Scenario 3 (60.10% ± 0.10%). The differences between the normal and modified location system was low in 4 cases (a difference around 2%). Although the difference was higher in two cases (around 5% for Scenario 2 and Scenario 4), the classification rate provided by the modified system was good enough in those two cases (75.15% ± 0.27% and 90.60% ± 0.07% respectively).
The classification rate without user's WAP was 60.10% ± 0.10% in Scenario 3. Although the difference with respect to the full classification was high −12.42%, this scenario had very low WiFi coverage in some areas and the number of detected WAP's per fingerprint was low. Table VI is introduced to explain better this low coverage. Concretely, it introduces the distribution of fingerprints according to the number of WAP's detected. Only Scenario 3 (with and without user's WAP) and Scenario 4 are shown in this table.
Note in Table VI that the number of WAP's detected per fingerprint is very low in Scenario 3. In fact, there were detected five or less WAP's in more than 60% of captured fingerprints. On the other hand, approximately 95% of total captured fingerprints detected more than 10 different WAP's in Scenario 4. This percentage for Scenario 4 decreased to 91.6% after removing the user's WAP. Moreover, after removing the user's WAP, the 70% of captured fingerprints reported five or less WAP's in Scenario 3, being void (no WAP was detected) 4.1% of total captures. It is important to mention that, even this major drawback in Scenario 3, the classification rate remained in a reasonable percentage for an 8-class classification problem, and the confusions in location were expected due to the proximity between the actual and the predicted space.

B. Experiments on detecting anomalous behavior
The experiments on detecting anomalous behavior have also been done for Scenarios 1, 3 and 4. Each user has been interviewed to obtain an initial estimation of her/his behavioral model. After the interviews, two different user-based models have been obtained for each user: the first one for regular days, and the second one for weekends and holiday days.
Once the two models for the three users have been obtained, three possible standard alarm situations have been simulated.
1) Problem in the bathroom: The first alarm is similar to the one showed in Section IV-C. The user stays in the bathroom much more time than expected in the time slot. 2) Waking-up problem: The second alarm consists on a situation where the estimation of the position of the user is still into the bedroom in the early morning when the expected space from the model is a different space. E.g, the user is expected to have breakfast or watch TV on the living-room but she/he is still sleeping. 3) Unexpected home leaving: The third alarm focuses on the situation that the user leaves home when the model has predicted that the user should be at home. E.g., when the user leaves home at 3 A.M., which is a very unexpected situation. The simulation consisted in performing some abnormal actions to test if the alarms are correctly activated. In particular, each alarm situation was simulated 20 times. All the parts (morning, evening and night) and types (regular and holiday) of the day, and all their combinations, have been considered in the different repetitions. E.g. the user stayed much more time in the bathroom than expected to test the first alarm situation. The alarms for the 60 simulated abnormal behaviors (20 for each alarm) were always correctly activated in the three scenarios, since the estimated space provided by the location system is different enough from the expected space obtained from the behavioral model. Moreover, 10 normal behaviour days (seven regular days and three holiday days) were also evaluated on the three scenarios. The system reported that the user's behaviour was totally normal and none alarm was activated for Scenarios 1 and 4. Only two consecutive false problem in the bathroom alarms were triggered in Scenario 3. According to this second simulation, the operational location accuracy tends to be higher than the validation set accuracy under normal user's behaviour. The validation samples were taken to cover the whole rooms, including corners and places close to walls. The users are not usually located on some of these places (such as a room corner), and they tend to be located close to the center of the rooms. So, our experiments shows that the fingerprints taken at the center of the rooms tend to be more representative than those located at the room walls and corners, therefore the IPS provide high accuracy under normal situations (in which the user is close a room center) even in those scenarios like Scenario 3.

VI. DISCUSSION
The context of our solution is to provide an in-home monitoring system, and it has been designed to be used in urban flats where there exists an important number of neighbors. Most of them will have a wireless Internet connection, so the number of visible WAPs from the patients house is expected to be high. We consider that out solution is feasible since: 1) almost the 70% of population in Spain live in this dwelling type, 2) almost 75% of Spanish households have an Internet connection by 2014 7 , 3) the main devices used to connect to Internet are mobile phones and laptops, so wireless connections are widespread at Spanish homes.
The proposed methodology uses the existing wireless network topology for providing indoor localization with WiFi fingerprints and some different machine learning techniques. An accurate room-level positioning is obtained with the use of advanced techniques such as Random Forest, Support Vector Machines or Neural Networks. For the purposes of the developed system, it is enough to obtain a room-level positioning instead of a precise longitude/latitude/altitude position. The experiments have demonstrated that the proposed indoor localization system can continuously provide the room where the user is with a high accuracy level.
Alarms are based on detecting abnormal situations, i.e. when the user stays long time in a place not in the expected places for this date/time. As the simulation results have shown, they are properly activated when an anomalous behaviour occurs. There have been only 2 normal alarms that have been improperly activated, and they corresponded to the most difficult scenario. However, it is worth mentioning that in this kind of applications, it is much more important to minimize the false negatives (non-detected abnormal situations) than minimize the false positives (activating an alarm in normal situations). In our experiments, all the abnormal situations have been correctly detected (there were 0 false negatives), and that feature is very important in an AAL application. Although there were only 2 false positives, it can be easily checked whether the alarm was properly or improperly activated by means of a simple phone call.
In our proposed methodology, users should wear the mobile phone with her/him or at least the mobile phone must to be in the same room that the user. It has been previously commented that nowadays elders are increasingly using the mobile phone. In addition, for users it is preferable the use of a well-known device as the mobile phone instead of the need of wear other not so common devices as in other methodologies. Nowadays, the state-of-art gadgets are SmartWatches. However, most of them does not include direct WiFi connectivity and Internet is accessed through a Bluetooth connection to the mobile phone. We consider, that our results shed light on WiFi positioning and our work could be reused in a near future with new SmartWatches with WiFi connectivity.
In addition, an important feature of our system is that it relies on the current wireless network topology, that includes the user's Internet router (if the user had one at home) and the neighbor's WAPs. So, we have not added any extra sensor nor device to perform the experiments. Moreover, the location system had not any prior knowledge of the environment (features of the mobile, structure of the flat, and location of the WAPs, among others). In general, the proposed system is an easy-to-install, inexpensive and unobtrusively system.

VII. CONCLUSIONS
The proposed monitoring system for Ambient Assisted Living is able to unobtrusively detect and analyze the user's behavior by means of the user's smartphone and the already deployed WiFi networks. A service has been developed to periodically send a WiFi-based fingerprint to a centralized server. This server has to estimate the user's position using the fingerprint and a few prior knowledge (only training fingerprints taken at the configuration phase). Using the estimated positions, the monitoring system is able to detect anomalies in user's behavior.
The results of this work indicate that: • Room-level indoor location based on machine learning provides very good results, and it reaches a classification rate of 96.01% in the best scenario and 72.52% in the most challenging real scenario. Even in the worst possible scenario, where the user has not any WiFi router/antenna at home and the neighbor's WiFi coverage is low, the classification rate is good enough for an eightclass classification problem. Moreover, the majority of misclassifications are due to the low distance between the place where the capture was taken and the adjacent room. E.g, the two bathrooms may provide similar fingerprints when they are side by side. • Current user's behavior can be extracted from the location performed. • Anomalies can be detected and the corresponding warnings can be sent using different technologies.
As future work, it is planed to improve the interoperability of the capture behavior system to interact with other health monitoring systems already developed. Gathering information about hearth's rate, blood pressure, diabetes, or presence of apnea may be quite important to improve user's health and quality of life.  Fig. 2. The four main conceptual parts of the proposed system: 1) the received WiFi signals emitted by the user's and neighbor's Internet WAPs, 2) the mobile client that records the information required for positioning, 3) The cloud services that processes all the information for positioning and abnormal behavior detection, and 4) the Alarms describing the problematic situations.        TABLE IV  CONFUSION MATRIX FOR SCENARIOS 1, 3 AND 4. ROWS STAND FOR THE PLACE WHERE THE FINGERPRINT WAS TAKEN AND THE COLUMNS STANDS FOR  THE PREDICTED PLACE USING RF.   Scenario 1  KT  LV  LD  R1  R2  R3  W1  W2  851  62  2  0  0  0  21  1  KT  93  1257  1  0  0  0  139  0  LV  5  0  101  0  0  0  0  0  LD  0  0  0  427  0  0  9