當前位置: 首頁>>代碼示例>>Python>>正文


Python Bunch.offset方法代碼示例

本文整理匯總了Python中sklearn.datasets.base.Bunch.offset方法的典型用法代碼示例。如果您正苦於以下問題:Python Bunch.offset方法的具體用法?Python Bunch.offset怎麽用?Python Bunch.offset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sklearn.datasets.base.Bunch的用法示例。


在下文中一共展示了Bunch.offset方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: from sklearn.datasets.base import Bunch [as 別名]
# 或者: from sklearn.datasets.base.Bunch import offset [as 別名]

#.........這裏部分代碼省略.........
    print ("Anytime active learning experiment - use objective function to pick data")
    t0 = time.time()
    tac = []
    tau = []
    ### experiment starts
    for t in range(args.trials):

        trial_accu = []

        trial_aucs = []

        print "*" * 60
        print "Trial: %s" % t

        student = get_student(clf, cost_model, sent_clf, sent_detector, vct)
        student.human_mode = args.expert == 'human'
        print "\nStudent: %s " % student

        train_indices = []
        neutral_data = []  # save the xik vectors
        train_x = []
        train_y = []
        neu_x = []  # data to train the classifier
        neu_y = np.array([])

        pool = Bunch()
        pool.data = data.train.bow.tocsr()  # full words, for training
        pool.text = data.train.data
        pool.target = data.train.target
        pool.predicted = []
        pool.remaining = range(pool.data.shape[0]) # indices of the pool
        rand = RandomState(t * 1234)
        rand.shuffle(pool.remaining)
        pool.offset = 0


        bootstrapped = False
        current_cost = 0
        iteration = 0
        query_index = None
        query_size = None
        oracle_answers = 0
        calibrated=args.calibrate
        while 0 < student.budget and len(pool.remaining) > pool.offset and iteration <= args.maxiter:
            util = []

            if not bootstrapped:
                query_index = pool.remaining[:bootstrap_size]
                bootstrapped = True
                query = pool.data[query_index]

                print
            else:
                # if not calibrated:
                #     chosen = student.pick_next(pool=pool, step_size=step_size)
                # else:
                #     chosen = student.pick_next_cal(pool=pool, step_size=step_size)
                chosen = student.pick_next(pool=pool, step_size=step_size)

                query_index = [x for x, y in chosen]  # document id of chosen instances
                query = [y for x, y in chosen]  # sentence of the document

                query_size = [1] * len(query_index)

            ground_truth = pool.target[query_index]
開發者ID:mramire8,項目名稱:active,代碼行數:69,代碼來源:sent_rnd.py


注:本文中的sklearn.datasets.base.Bunch.offset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。