# Location Based Indoor and Outdoor Lightweight Activity Recognition System
## 3 Outdoor Activity Recognition System
### POI Identification Mechanism
#### 3.1.1 First Iteration  
First, the GPS data is cleaned to fix some of the issues found when it comes to smartphone's GPS accuracy. The first issue is the GPS drifts, when suddenly the smartphone reports for an unspecified period (usually a few minutes) a location that is far away from the real one and then returns to the real location. During the development of the data cleaning process we found that there can be different types of GPS drifts which sometimes can be mistaken for actual coordinates. To fix this, for each consecutive three points we check if the following three conditions are true. These conditions were defined after analyzing the pattern of several GPS drifts found in the data gathered from different volunteers. Therefore, if the three conditions are fulfilled, a GPS drift is found (see in Figure 1 the three points that form the marked triangle):  
* The angle formed by connecting the three points is less than 40 degrees. * The ratio between the two sides of the angle (longest side/shortest side) is less than 2. * The angles formed by the first point and its previous point, or the angle formed by the third point and its next point, are greater than 145 degrees and less than 215 degrees. The second issue detected is that there are some cases where the phone stops updating the coordinates and therefore, the coordinates are the same for a few minutes. When this happens, all the points will be unified in a single one with a larger duration. After the raw data has been properly cleaned, DBSCAN clustering algorithm has been used to identify the most relevant clusters and analyze if those clusters can be selected as a POI. The parameters used in this case are eps (the maximum distance between two samples to be considered as neighbors) of 25 m, minimum samples (the minimum number of points each cluster should have) to one, ball tree as algorithm and haversine as metric. DBSCAN returns a label per each of the points fed into it. Therefore, those points belonging to the same cluster would have the same label, whereas those points that do not belong to any cluster would have a unique label. Until this point, only the geographical data have  
Figure 1: Example of how a GPS drift would be removed. On the left the original drift, on the right the drift already removed. been taken into account. However, there is also temporal data that should be used too. To do so, the GPS data is analysed in temporal order checking if the next point's label is the same as the previous one, unifying all consecutive points with the same cluster label until a point with a different label is found. Therefore, those consecutive points, which belong to the same cluster, are grouped together being the duration of the cluster the addition of all points' durations. Finally, a cluster is considered a POI if the user has been there more than 5 min. **Testing and validation. ** Using the algorithm described above, a first prototype is implemented and tested with data from real mobile devices from some volunteers. These tests were created after manually annotating specific days of the gathered data that we considered could help in the evaluation of the proposed system due to their characteristics: high mobility days or large number of GPS inaccuracies that were found after a manual analysis of the data. In general terms, the obtained results were acceptable, but there were occasions in which the mobile devices, especially when they were indoors, captured erroneous GPS points that showed erratic results and the implemented data cleaning algorithm was not able to correct them. Including the errors identified before, the GPS errors detected are summarized into three types:  
1. Static jumps: already identified during the data cleaning phase of the first iteration. They are points that have exactly the same coordinates. It is not common for the points to have the same coordinates; therefore, they may indicate that there are errors in the GPS data (See Figure 2). 2. GPS drifts: also addressed during the first iteration.