Ejemplo n.º 1
0
import numpy as np
import matplotlib.pyplot as plt
import os, sys

currentdir = os.path.dirname(os.path.realpath(__file__))
parentdir = os.path.dirname(currentdir)
sys.path.append(parentdir)
from s_data_loader import data_path

plt.style.use('bmh')

x_acc_raw_file = open(data_path('train/InertialSignals/body_acc_x_train.txt'),
                      'r')
y_acc_raw_file = open(data_path('train/InertialSignals/body_acc_y_train.txt'),
                      'r')
z_acc_raw_file = open(data_path('train/InertialSignals/body_acc_z_train.txt'),
                      'r')

# Create empty lists
x_acc_raw = []
for x in x_acc_raw_file:
    x_acc_raw.append([float(ts) for ts in x.split()])
y_acc_raw = []
for x in y_acc_raw_file:
    y_acc_raw.append([float(ts) for ts in x.split()])
z_acc_raw = []
for x in z_acc_raw_file:
    z_acc_raw.append([float(ts) for ts in x.split()])

x_acc_raw = np.array(x_acc_raw)
y_acc_raw = np.array(y_acc_raw)
Ejemplo n.º 2
0
import numpy as np
import matplotlib.pyplot as plt
from s_knn_dtw import KnnDtw
from s_data_loader import data_path

plt.style.use('bmh')

print("-------------------------------- section 7")
# Import the HAR dataset
x_train_file = open(data_path('train/X_train.txt'), 'r')
y_train_file = open(data_path('train/y_train.txt'), 'r')

x_test_file = open(data_path('test/X_test.txt'), 'r')
y_test_file = open(data_path('test/y_test.txt'), 'r')

# Create empty lists
x_train = []
y_train = []
x_test = []
y_test = []

# Mapping table for classes
labels = {
    1: 'WALKING',
    2: 'WALKING UPSTAIRS',
    3: 'WALKING DOWNSTAIRS',
    4: 'SITTING',
    5: 'STANDING',
    6: 'LAYING'
}