def ponderateByConcentration():
print 'Loading feature concentration..........'
sdFile = open('varStandarDevs.txt','rb')
standevs=pickle.load(sdFile)
sdFile.close()
totDevs={}
for feature in standevs:
totDevs[feature]=sum([abs(standevs[feature][si]) for si in range(len(standevs[feature]))])/len(standevs[feature])
localF=['turningAngle','turningAngleDifference','Coord','LP']
globalF=['accAngle','coG','relStrokeLength','liS','quadraticError']
totalF=['turningAngle','turningAngleDifference','Coord','LP','Style','accAngle','coG','relStrokeLength','liS','quadraticError']
print 'Ponderating features..........'
weights={}
norm=np.nansum([1/float(math.sqrt(totDevs[feature])) for feature in totalF])
for feature in totalF:
weights[feature]=(1/float(math.sqrt(totDevs[feature])))/float(norm)
print 'Features weighted as'
print weights
return weights
评论列表
文章目录