コード例 #1
0
    def teach(self, butler, target_index, target_label):
        api = VWAPI()

        example = butler.targets.get_target_item(butler.exp_uid, target_index)
        vw_example = api.to_vw_examples([example])

        api.vw.send_example(target_label, features=vw_example)
        api.vw.close()
        del api
コード例 #2
0
ファイル: VowpalWabbit.py プロジェクト: mcomsa/NEXT
    def teach(self, butler, args):
        #print(args)
        args = json.loads(args)
        target_label = args['args']['target_label']
        example = args['args']['example']

        print('\t*** about to teach ...')
        api = VWAPI()

        # products are represented as a bag of words (and maybe syntax too)
        vw_example = api.to_vw_examples([example])

        #print("\t*** vw_example: ", str(vw_example))

        api.vw.add_namespaces(vw_example)

        # important to send namespaces, not features, because
        # to_vw_examples creates namespaces
        api.vw.send_example(response=target_label)
        api.vw.close()
        del api

        print('\t*** ... taught')