frameSize = math.ceil(np.sqrt(len(subjects)))
fig = plt.figure()
joint = 'rtibia'
plt.xlabel('Time (in frames)')
plt.ylabel(joint + ' angle')
fig_uniform = plt.figure()
data = []
tags = []
for subject in subjects:
    for stride in xrange(1,13):
        file = 'AMCs/subjects/' + str(subject) + '/' + str(stride) + '.amc'
        try:
            input = getAMCperiod(joint, file)
        except:
            continue
        input = alignByMax(input)
        sub =  fig.add_subplot(frameSize*110 + subjects.index(subject))
        sub.plot(range(len(input)), input)
        sub_uniform = fig_uniform.add_subplot(frameSize*110 + subjects.index(subject))
        new_time, uniform_input = inter.getUniformSampled(xrange(len(input)), input, numOfFeatures)
        sub_uniform.plot( xrange(numOfFeatures), uniform_input)
        data.append(uniform_input)
        tags.append(subject)
        plt.xlabel('Time (in frames)')
        plt.ylabel(joint + ' angle')
        plt.title('subject: ' + str(subject))

cl = KNeighborsClassifier()
cl.n_neighbors = 5
cl.weights = 'distance' 
testSize = 35
Beispiel #2
0
from operator import add, sub
import utils.LPF as LPF 
import numpy.random as rnd
import matplotlib.pyplot as plt 
from utils.vicon.amcParser import getAMCperiod
from utils.MovingAverage import movingAverage
def mse(A, B):
    return ((np.array(A) - np.array(B)) ** 2).mean(axis=0)
def me(A, B):
    return np.mean([np.abs(x-y) for x, y in zip(A,B)])

file = 'AMCs/598.amc'
joint = 'rtibia'
list = getAMCperiod(joint, file)
stride = list[112:251] 
list = ut.alignByMax(stride)
amplitude = np.max(list) - np.min(list)
coeffs_num = 16
window_size = 16
maFactor = 1.2
msesMA = []
msesLPF = []
noises = []
noisesFactors = xrange(2,20)
for noiseFactor in noisesFactors:
    sumsLPF = []
    sumsMA = []
    sumsN = []
    for i in xrange(30):
        noise = map(add, np.random.normal(0,(amplitude/noiseFactor)**2,len(list)), list)
        clean = LPF.clean(noise, coeffs_num)