featurePonderation.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:OptiCalcRead 作者: MrLeylo 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号