3.2.2. Recognition Phase

Once we train the model, the trained application will be installed on all participants' smartphones. Our application is capable of running in the background so that users can use their smartphone for other tasks. Our model is a two-step process, where we process the accelerometer data stream and know the contexts either "still" or "active". If the classifier labels the context as "still", we process the environmental sound to recognize the micro-context: working on a PC, watching television, "sedentary-unknown context". We consider every context as sedentary-unknown if the user is "still" and it does not lie in the defined micro-contexts. Unknown context includes for example sleeping, reading books and attending classes or seminars. In order to preserve privacy, we do not store the environmental sound. We extract the features in real time from the sensory data and fed to the classifier to recognize the micro-contexts. The time scale for inference is set to one-minute epochs, which is sufficient to distinguish among the micro-contexts. If a user is found to be sedentary, then we activate the audio sensor for 8 s to analyse the environmental sound and recognize the micro-context. Furthermore, if we found the micro-context and the user is still in the sedentary state, we check the environment after fifteen minutes to distinguish between the different micro-contexts while staying sedentary. In this way, we save the battery consumption of the smartphone by only checking the environment when the user is in a sedentary state. The training models were used to classify the contexts in real time, as is shown in Figure 4. Signal Segmentation Set of Frames Feature Extraction Classifier Training Train Models

**Figure 4.** Real-time mining of users' contexts.

We processed all these data inside our smartphone application, and furthermore, it requires a ubiquitous service to transfer this contextual information to our private cloud. We deployed the software as a service model, which will automatically scale the services with dynamic provisioning of resources. This approach will reduce the chances of denial of service to the users even at peak usage. It will also enable the user's phone to be independent in case of any issue with the smartphone. We also present the flowchart of the proposed model in Figure 5.

**Figure 5.** Flowchart of the context miner model.
