splitIntoSets.py 文件源码

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

项目:rir-database 作者: Marvin182 项目源码 文件源码
def createLists(dbFilename):
    print('Splitting RIRs into sets...')
    sets = [
        RirSet('train', 0.8),
        RirSet('test', 0.1),
        RirSet('dev', 0.1),
    ]

    # open database
    rirDb = json.load(open(dbFilename))
    rirs = sorted(list(rirDb.keys()))

    # to distribute the RIRs to the set we could to a shuffle, but as they are in alphabetical order and just going over them guaranties that we distribute the different conditions (mostly) equally on the different sets
    sets[0].add(rirs[0])
    for i in range(1, len(rirs)):
        si = np.argmin([s.missing(i) for s in sets])
        sets[si].add(rirs[i])

    # safe set files
    util.createDirectory(ListDir)
    for s in sets:
        s.save(ListDir)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号