コード例 #1
0
def feature_extractor_one_dim(data):

    feature_vector = []
    c = 0
    for j in range(0,len(data)):
        feature_vector.append([])
        
        
        for w in range(len(ref_samples)):
            for d in ref_indexes[w]:
                   
                feature_vector[c].append(arc.my_kernel(arc, data[j][d], ref_samples[w][d], learning_rate=0.01))
        c = c + 1
    
    return feature_vector
コード例 #2
0
from myfunctions import Action_recognition_class as arc
from sklearn.svm import SVC
import random
import numpy as np

#reading sata
all_actions, labels = arc.read_UTkinect_aligned()

#preparing data
all_action_prepared = arc.zero_padding(arc, all_actions)
all_action_prepared = [x[3:] for x in all_action_prepared]

num_of_classes = len(set(labels))
#=============================================================================================

ref_samples = []
for i in range(0, num_of_classes):
    while (len(ref_samples) < (i + 1)):
        j = random.randint(0, len(all_action_prepared) - 1)
        if (labels[j] == i):
            ref_samples.append(all_action_prepared[j])

#=============================================================================================
ref_indexes = [x for x in range(len(ref_samples[0]))]
ref_indexes = [ref_indexes for i in range(num_of_classes)]
'''
two functions that extract feature
            first one is based on multi dimentional kernel
            second one is based on one dimentional kernel
'''
'''
コード例 #3
0
from myfunctions import Action_recognition_class as arc
from sklearn.svm import SVC
import random
import numpy as np

#reading TST fall detection data
all_actions, labels = arc.read_tst()

#=============================================================================================
#Preparing data
all_action_prepared = arc.prepare_data_tst(arc, all_actions)
all_action_prepared = arc.zero_padding(arc, all_actions)

#some samples should be deleted because of different series length of features
del all_action_prepared[78]
del all_action_prepared[219]
del all_action_prepared[234]

del labels[78]
del labels[219]
del labels[234]

num_of_classes = len(set(labels))
#=============================================================================================

#choosing reference samples randomly
ref_samples = []
for i in range(0,num_of_classes):
    while(len(ref_samples) < (i + 1)):
        j = random.randint(0, len(all_action_prepared) - 1)