5ImplementationImplementation PlatformHardwareProcessor: Intel Core i5RAM: 8 GBGPU: NVIDIA GEFORCEThe above requirements were satisfied, where in the training could be done on an instance that matches the necessary requirements as mentioned above.SoftwareOperating System: Windows 8 or Windows 10 (64bit)Programming Languages: Python (version 3.6.5)Tools: Numpy, Matplotlib, PandasDeep Learning Framework: Keras (version 2.1.6)Implementation Details5.2.1 Conceptual OverviewThe dataset used is a collection of accelerometer data taken from the smartphone the various people carried with them while conducting six different activities (Downstairs, Jogging, Sitting, Standing, Upstairs, Walking).
Timestamp was captured for each exercise and the acceleration for the x, y and z-axis was measured.With this available data, a neural network is trained in order to understand if a person carrying a smartphone is performing any of the six activities. After the neural network is trained on the existing data, it should be able to correctly predict the type of activity a person is conducting when given unseen data.5.2.2 Import LibrariesInitial step is to import all the necessary python libraries.
It is required to install these libraries before importing using the pip installer.After importing the libraries, some standard parameters should be set and Keras version should be printed out, which was installed.5.2.3 Load, Inspect and Transform the accelerometer dataStandard dataset should be downloaded and stored locally. The accelerometer data should be loaded from the WISDM dataset. Now it is required to convert and reformat accelerometer data into a time-sliced representation. Later, the data should be visualized and reshaped so that it is accepted by the Keras. The dataset is split into training, validation, and test data.9048756953255.2.3.1 Training datasetThe choice of dataset heavily depends on the application. The activities we are interested to recognize are sitting, standing, walking, jogging, climb upstairs, and downstairs. The dataset chosen for training is WISDM dataset, which contains readings from two sensors (Accelerometer and Gyroscope). Readings were recorded when users executed activities in no specific order, while carrying smartphones. The data can be loaded to data frame successfully and displayed.94297550666655.2.4 Create Neural Network Models in KerasNow, that the data is ready in such a format that Keras will be able to process it, a model combining CNN (Convolutional Neural Network) and RNN (Recurrent Neural Network) is proposed here. The sensor measurements given as input are split into series of data intervals along time. The representation of each data interval is fed into CNN and then to RNN. 220.127.116.11 Convolutional Neural NetworkThe CNN is capable of automatically extracting local features within the each sensor modality and merges the local features of different sensor modalities into global features hierarchically. CNNs are able to extract features from input sequences, such as accelerometer data. CNNs would be better fit for predicting the activity given a sequence of observed accelerometer data.One-dimensional CNNs have been widely used for this type of problem, with one channel for each axis of the accelerometer data. A good simple starting point would be to fit a CNN model on windows of sequence data directly.8470903971925005.2.4.2 Recurrent Neural NetworkThe RNN is capable of extracting temporal dependencies. To understand how this might be useful, existing implementations are tested by performing an activity in various positions. The LSTM (Long Short Term Memory) network model is developed for the human activity recognition dataset.The LSTM network models are a type of RNN that are able to learn and remember over long sequences of input data. They are intended for use with the data that is comprised of long sequences of data. They may be good fit for this problem. The benefit of using LSTMs for sequence classification is that they can learn from the raw time series data directly.7810502790825005.2.5 Fit the ModelPost creating the model, model is trained with the training data that was prepared earlier. Early stopping callback monitor on training accuracy is defined. The hyper parameter used for the training are quite simple: the used batch size of 400 records and will train the model for 10 epochs. For model training, we will use a 80:20 split separate training data and validation data. It is that simple.5.2.6 Model EvaluationThe data are exposed to the model while maintaining the temporal ordering of the observations. The segmentation of the dataset by subject avoids any issues related to the temporal ordering.center260032500 Accelerometer contains capacitive plates internally. Some of them are fixed, while others are attached to minuscule springs that move internally as acceleration forces act upon the sensor. As these plates move in relation to each other, the capacitance between them changes. From these changes, the acceleration can be determined.The following graphs clearly depicts the x, y and z-axis representations for each of the activities. The rate of change of velocity of an object varies for every activity. This slightly varies with the elevation. 6TestingThe movement data recorded was the x, y and z accelerometer data and the gyroscopic data from the smartphone. The pre-processed data was made available. The 80% of the data was used first for training and the 20% of the data was used as testing data. For training the batch size and the epochs were varied. Normalization was done on the x, y and z co-ordinates of the data.The expectations prove to be right, as there is a higher acceleration for activities such as jogging and walking compared to sitting.Activity-1: Climbing stairsright3181350Activity-2: Walkingleft4953000057150508635000Activity-3: JoggingActivity-4: Sittingright5429250Activity-5: Lying downrightbottom06.1 Testing InputThe testing input is given in the form 3-axis data, derived from the testing data samples. The model is checked by looking at the performance against the movements of various users.6.2 Testing outputIn the final step, the chosen model is evaluated against the hold out set/ test data set. After training the model, it is saved and made ready for testing. The output is the prediction of the activity, based on the readings from the testing input. The testing accuracy is nearly same as the training accuracy, which depicts that the model is working at its greater accuracy. The model can be stored for the future use/improvements.It was possible to obtain 98.49% accuracy from the LSTM model and 94.30% accuracy from the CNN model.