Пример #1
0
from sklearn.svm import SVC
from sklearn.metrics import confusion_matrix

import utils

num_classes = 9
num_kernels = 4

train_path = "/media/linzhank/850EVO_1T/Works/Action_Recognition/Data/train/joint/"
test_path = "/media/linzhank/850EVO_1T/Works/Action_Recognition/Data/test/joint/"
result_path= "/media/linzhank/850EVO_1T/Works/Action_Recognition/Data/result"

# Load data
train_data = spio.loadmat(train_path + "joint_train.mat")["joint_train"]
num_examples_train = train_data.shape[0]
initid_train = utils.detectInit(train_data)
train_data = train_data.reshape(num_examples_train,150,75)
train_classes = spio.loadmat(train_path + "labels_train.mat")["labels_train"]
train_labels = np.argmax(train_classes, axis=1)
                                
test_data = spio.loadmat(test_path + "joint_test.mat")["joint_test"]
num_examples_test = test_data.shape[0]
initid_test = utils.detectInit(test_data)
test_data = test_data.reshape(num_examples_test,150,75)
test_classes = spio.loadmat(test_path + "labels_test.mat")["labels_test"]
test_labels = np.argmax(test_classes, axis=1)

# Use 5, 10, 15,...,40 frames of data to train 8 svm predictor
num_frames = 5*np.arange(1,9)
# Init best kernel storage 
best_kernel = np.array([""]*num_frames.shape[0], dtype="|S8")
Пример #2
0
from datetime import datetime
from sklearn import neighbors
from sklearn.metrics import confusion_matrix

import utils

train_path = "/media/linzhank/850EVO_1T/Works/Action_Recognition/Data/train/joint/"
test_path = "/media/linzhank/850EVO_1T/Works/Action_Recognition/Data/test/joint/"
TODAY = datetime.today().strftime("%Y%m%d")
result_path = "/media/linzhank/850EVO_1T/Works/Action_Recognition/Data/result{}".format(
    TODAY)

# Load train data
train_data = spio.loadmat(train_path + "joint_train.mat")["joint_train"]
num_examples_train = train_data.shape[0]
initid_train = utils.detectInit(train_data, offset=10)
train_data = train_data.reshape(num_examples_train, 150, 75)
train_classes = spio.loadmat(train_path + "labels_train.mat")["labels_train"]
train_labels = np.argmax(train_classes, axis=1)
# Load test data
test_data = spio.loadmat(test_path + "joint_test.mat")["joint_test"]
num_examples_test = test_data.shape[0]
initid_test = utils.detectInit(test_data, offset=10)
test_data = test_data.reshape(num_examples_test, 150, 75)
test_classes = spio.loadmat(test_path + "labels_test.mat")["labels_test"]
test_labels = np.argmax(test_classes, axis=1)

# On your mark
start_t = time.time()
# Use 5, 10, 15,...,40 frames of data to train 8 knn predictor
num_frames = 5 * np.arange(1, 9)