|
| 1 | +##################################################################### |
| 2 | + |
| 3 | +# Example : load HAPT data set only |
| 4 | +# basic illustrative python script |
| 5 | + |
| 6 | +# For use with test / training datasets : HAPT-data-set-DU |
| 7 | + |
| 8 | +# Author : Toby Breckon, [email protected] |
| 9 | + |
| 10 | +# Copyright (c) 2014 School of Engineering & Computing Science, |
| 11 | +# Durham University, UK |
| 12 | +# License : LGPL - http://www.gnu.org/licenses/lgpl.html |
| 13 | + |
| 14 | +##################################################################### |
| 15 | + |
| 16 | +import csv |
| 17 | +import cv2 |
| 18 | +import os |
| 19 | +import numpy as np |
| 20 | + |
| 21 | +########### Define classes |
| 22 | + |
| 23 | +classes = {} # define mapping of cla |
| 24 | +inv_classes = {v: k for k, v in classes.items()} |
| 25 | + |
| 26 | +########### Load Data Set |
| 27 | + |
| 28 | +path_to_data = "../../assignment/2016-17/HAPT-data-set-DU" # edit this |
| 29 | + |
| 30 | +# Training data - as currenrtly split |
| 31 | + |
| 32 | +attribute_list = [] |
| 33 | +label_list = [] |
| 34 | + |
| 35 | +reader=csv.reader(open(os.path.join(path_to_data, "Train/x_train.txt"),"rt", encoding='ascii'),delimiter=' ') |
| 36 | +for row in reader: |
| 37 | + # attributes in columns 0-561 |
| 38 | + attribute_list.append(list(row[i] for i in (range(0,561)))) |
| 39 | + |
| 40 | +reader=csv.reader(open(os.path.join(path_to_data, "Train/y_train.txt"),"rt", encoding='ascii'),delimiter=' ') |
| 41 | +for row in reader: |
| 42 | + # attributes in column 1 |
| 43 | + label_list.append(row[0]) |
| 44 | + |
| 45 | +training_attributes=np.array(attribute_list).astype(np.float32) |
| 46 | +training_labels=np.array(label_list).astype(np.float32) |
| 47 | + |
| 48 | +# Testing data - as currently split |
| 49 | + |
| 50 | +attribute_list = [] |
| 51 | +label_list = [] |
| 52 | + |
| 53 | +reader=csv.reader(open(os.path.join(path_to_data, "Test/x_test.txt"),"rt", encoding='ascii'),delimiter=' ') |
| 54 | +for row in reader: |
| 55 | + # attributes in columns 0-561 |
| 56 | + attribute_list.append(list(row[i] for i in (range(0,561)))) |
| 57 | + |
| 58 | +reader=csv.reader(open(os.path.join(path_to_data, "Test/y_test.txt"),"rt", encoding='ascii'),delimiter=' ') |
| 59 | +for row in reader: |
| 60 | + # attributes in column 1 |
| 61 | + label_list.append(row[0]) |
| 62 | + |
| 63 | +testing_attributes=np.array(attribute_list).astype(np.float32) |
| 64 | +testing_labels=np.array(label_list).astype(np.float32) |
| 65 | + |
| 66 | +########### test output for sanity |
| 67 | + |
| 68 | +print(training_attributes) |
| 69 | +print(len(training_attributes)) |
| 70 | +print(training_labels) |
| 71 | +print(len(training_labels)) |
| 72 | + |
| 73 | +print(testing_attributes) |
| 74 | +print(len(testing_attributes)) |
| 75 | +print(testing_labels) |
| 76 | +print(len(testing_labels)) |
| 77 | + |
| 78 | +##################################################################### |
0 commit comments