<jupyter_start><jupyter_text>Feature Engineering<jupyter_code>from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import math
import sys
sys.path.append('../src/')
import numpy as np
import pandas as pd
import sklearn
import matplotlib.pyplot as plt
%matplotlib inline
from gestureai import load_dataset<jupyter_output>Using TensorFlow backend.<jupyter_text>Load Datasets<jupyter_code>input_dim = 3
timesteps = 40
n_classes = 5
n_files_class = 200
X = load_dataset('../datasets/gesture-3axis-accel.tar.gz')
X.shape
y = np.array([])
for i in range(n_classes):
    y = np.r_[y, [i] * n_files_class]
y.shape<jupyter_output><empty_output><jupyter_text>--- Representative Value<jupyter_code>X_r = X.reshape(1000*40, 3)
X_r.shape
df = pd.DataFrame(X_r, columns=('x', 'y', 'z'))
df.describe()
df.mean()
df.var()
df.std()<jupyter_output><empty_output><jupyter_text>Square Root of Sum of Squares (SRSS)<jupyter_code>squares = X_r[:,0] ** 2 + X_r[:,1] ** 2 + X_r[:,2] ** 2
srss = [math.sqrt(square) for square in squares]
np.mean(srss)
np.var(srss)
np.std(srss)<jupyter_output><empty_output><jupyter_text>--- Plot sequence<jupyter_code>def plot_3axis_seq(seq, title=''):
    plt.title(title)
    plt.grid()
    plt.xlabel('Time[ms]')
    plt.ylabel('Acceleration')
    plt.plot(seq[:,0], label='x')
    plt.plot(seq[:,1], label='y')
    plt.plot(seq[:,2], label='z')
    plt.legend()
def plot_srss_seq(index_class, title=''):
    start = index_class * n_classes * n_files_class
    end = index_class * n_classes * n_files_class + timesteps
    plt.title(title)
    plt.grid()
    plt.xlabel('Time[ms]')
    plt.ylabel('SRSS of Acceleration')
    plt.plot(srss[start:end], label='SRSS')
    plt.legend()<jupyter_output><empty_output><jupyter_text>3-axis Sequence<jupyter_code>plot_3axis_seq(X[0 * n_files_class], title='Circle')
plot_3axis_seq(X[1 * n_files_class], title='Rectangle')
plot_3axis_seq(X[2 * n_files_class], title='Triangle')
plot_3axis_seq(X[3 * n_files_class], title='Cross')
plot_3axis_seq(X[4 * n_files_class], title='Other')<jupyter_output><empty_output><jupyter_text>SRSS of Sequence<jupyter_code>plot_srss_seq(0, title='SRSS of Circle')
plot_srss_seq(1, title='SRSS of Rectangle')
plot_srss_seq(2, title='SRSS of Triangle')
plot_srss_seq(3, title='SRSS of Cross')
plot_srss_seq(3, title='SRSS of Other')<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup