active_learning.py 文件源码

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

项目:Steal-ML 作者: ftramer 项目源码 文件源码
def run(dataset_name, n_features, n_repeat=5, n_learning_round=5):
    base_dir = os.path.join(os.getcwd(), '../targets/%s/' % dataset_name)
    model_file = os.path.join(base_dir, 'train.scale.model')

    result = Result(dataset_name + '-'+ 'active')
    for repeat in range(0, n_repeat):
        print 'Round %d of %d'% (repeat, n_repeat - 1)

        ex = LibSVMOnline(dataset_name, model_file, (1, -1), n_features, 'uniform', 1e-1)
        X_test, y_test = load_svmlight_file(os.path.join(base_dir, 'test.scale'), n_features)
        X_test = X_test.todense()

        for i in result.index:
            q_by_u = result.Q_by_U[i]

            main = ActiveLearning(ex, (None, None), (X_test, y_test), n_features,
                                  q_by_u * (n_features + 1), n_learning_round)

            L_unif, L_test = main.do()

            result.L_unif[i].append(L_unif)
            result.L_test[i].append(L_test)
            result.nquery[i].append(ex.get_n_query())

    print result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号