# Location Based Indoor and Outdoor Lightweight Activity Recognition System
## 3 Outdoor Activity Recognition System
### POI Identification Mechanism
#### 3.1.2 Second Iteration  
Due to the issues detected in the testing phase, we decided to re-evaluate the process and implement a new clustering algorithm using the lessons learned in the first iteration but trying to correct the problems detected. First, it was decided not to use the initial cleaning step implemented in the first iteration because we detected that it was not able to deal with all the different types of GPS drifts that we have identified during the development of the system. Consequently, using the output route of this process could have led to an error that would have been spread throughout the following steps of the process. The new procedure could be divided into three phases: pre-processing, where the necessary data for clustering is obtained, the multi-clustering algorithm itself, and a final post-processing phase where the route is cleaned. **Pre-processing. ** First, we run the DBSCAN algorithm to identify high quality clusters. In this step, the parameters used in the first iteration are modified. We used a more restrictive eps of just 9 m (instead of 25 m), and a minimum of five samples are required for a cluster to be considered as such. In this way, the detected clusters receive a numerical label and the points that do not belong to any cluster receive the label '\(-1\)'. Next, the quality of the clusters obtained is evaluated. As discussed during the explanation of the POI detection system of the first iteration, DBSCAN is particularly suitable for detecting clusters from a geographical point of view, but in our case, as a user may walk several times through a geographical area at different times of the day, DBSCAN may erroneously identify those points as belonging to the same cluster. Therefore, we analyze each detected cluster and determine if it can be considered as 'good' (indeed, it is going to be a cluster), or 'bad' (either because it is not really a cluster, or because it is composed of several temporal clusters sharing geographic space). The following characteristics are obtained for this evaluation:  
* The standard deviation of the distances from the cluster points to the cluster centroid. In general, a good cluster should not have values that are too high (something that is already taken care of by DBSCAN itself), but not too small either as it would imply a \"static jump\". * The variability representing the average number of different coordinates with respect to the total number of points in the cluster. In a good cluster it is not normal that coordinates are repeated, therefore, it is normal to have values close to 1. If they are closer to 0, it implies a \"static jump\". Figure 5: The cluster circled in red on the left is not a real cluster. In the zoom on the right the zig-zag pattern can be observed. * Number of inputs and outputs. The number of inputs and outputs occurring in that cluster is checked. A good cluster should have 2, if it is in the middle of the route, or 1 if it is the start or the end of the route (home, for example). A larger number may imply that the same cluster is crossed by the user several times throughout the day, although it could also be the result of a GPS drift that goes outside the cluster boundaries. * Time jumps inside the cluster. The time difference between consecutive points in the cluster is calculated and those exceeding 125 s are considered as \"time jumps\" (GPS samples are usually obtained every 60 s, so we give a margin of slightly more than two samples). With the available data, we manually evaluated our approach and based on the results obtained, we established the different thresholds that determine whether a cluster is 'good' or 'bad'. These thresholds are intended to reduce the number of false positives so, when a cluster is considered 'good' we can have a high certainty that it is a real cluster. * First, those clusters that have two or less inputs and outputs are checked.