def evalParams(m1=MEAN_COEFF, m2=STD_COEFF, epsilon=EPSILON_FACTOR,gap=GAP_FACTOR, overlap=OVERLAP_FACTOR): sum = 0 for stitch in xrange(stitchesNum): data = [] tags = [] for subject in subjects: for index in xrange(8): try: input = getAMCInput(joint, subject, index) except: continue parts = st.createParts(input, partsAmount) stitched = st.stitch(parts, m1, m2, epsilon,gap, overlap) #plt.figure() #plt.plot(stitched) periods = pr.breakToPeriods(stitched) periods = ut.alignByMaxMany(periods) periods = inter.getUniformSampledVecs(periods, 100) data = data + periods tags = tags + [subject]*len(periods) #st.plotParts(periods) cl = KNeighborsClassifier() cl.n_neighbors = 5 cl.weights = 'distance' testSize = 1 score = crossValidate(cl, data, tags, testSize, testAmount) #print str(m2)+' '+ str(score) sum+=score score = float(sum)/stitchesNum scores[m1, m2] = score return score
def getSwingsAndStances(input): periods = par.breakToPeriods(input) periods = ut.alignByMaxMany(periods) stances = [] swings = [] for period in periods: a = np.array(period) localMax = argrelextrema(a, np.greater, 0, MAXIMA_ORDER) #localMax is a tuple for m in localMax: if(len(m) != 1): continue max = m[0] swings.append(max) stances.append(int(len(period)-max)) break return swings, stances