当前位置: 首页>>代码示例>>Python>>正文


Python evaluator.Evaluator类代码示例

本文整理汇总了Python中evaluator.Evaluator的典型用法代码示例。如果您正苦于以下问题:Python Evaluator类的具体用法?Python Evaluator怎么用?Python Evaluator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Evaluator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: evaluate_classifier

def evaluate_classifier(clf_wrapper,
                        params,
                        train_images_codelabels, train_labels,
                        test_images_codelabels, test_labels):

    print "==\nevaluate_classifier (test size: {})\n{}".format(len(test_labels), clf_wrapper)

    print "training classifier {}".format(clf_wrapper.clf)
    start_time = time.time()
    clf_wrapper.fit(X=train_images_codelabels, labels=train_labels)
    et = (time.time() - start_time) * 1000.0
    print "finished training classifier - took {}ms".format(et)

    # evaluate
    print "proceeding to evaluate classifier on test set {}".format(len(test_labels))
    encoded_test_labels = clf_wrapper.label_encoder.transform(test_labels)

    evaluator = Evaluator(
        clf=clf_wrapper.clf,
        label_encoder=clf_wrapper.label_encoder,
        params=params,
        output_filepath="../results/evaluation_results_{}.json".format(clf_wrapper)
    )

    evaluator.results["classifier"] = "{}".format(clf_wrapper.clf)
    evaluator.results["classifier_training_time"] = "{}".format(et)

    evaluation_results = evaluator.evaluate(X=test_images_codelabels, y=encoded_test_labels)
    print evaluation_results
开发者ID:joshnewnham,项目名称:udacity_machine_learning_engineer_nanodegree_capstone,代码行数:29,代码来源:model_tuning.py

示例2: detect

	def detect(self, img_path=None, output_file_prefix='', num_ft=100, offset=0, scaling_factor = 1.2, scaling_iters=3, nms=0.5, clf=None, templates=None, linear_scaling=False):
		
		#=====[ Load our classifier and templates ]=====
		clf = pickle.load(open(clf)) if clf else pickle.load(open('classifiers/top_ft_classifier_100_200', 'r'))
		templates = pickle.load(open(templates)) if templates else pickle.load(open('processed_data/top_templates_1000.p','r'))
	
		#=====[ Get top templates ]=====
		templates = templates[:num_ft]

		#=====[ Instantiate our feature generator ]=====
		fg = FeatureGenerator(templates)

		#=====[ Instantiate our detector ]=====
		if linear_scaling:
			self.detector = LinearScaleDetector(clf.clf, fg,scaling_factor=scaling_factor,scaling_iters=scaling_iters, nms=nms)
		else:
			self.detector = Detector(clf.clf, fg,scaling_factor=scaling_factor,scaling_iters=scaling_iters, nms=nms)

		#=====[ If a specific image path is given, then we do not evaluate, just detect the pedestrian and draw bounding boxes ]=====
		if img_path:
			_, bbs = self.detector.detect_pedestrians(img_path)
			self._draw_bbs(img_path, bbs)
		
		else:
			#=====[ Instantiate our evaluator and evaluate ]=====
			evaluator = Evaluator('INRIAPerson/Test', self.detector)
			FPPI, miss_rate = evaluator.evaluate(output_file_prefix,offset)

			print '\nFPPI: {}\nMiss rate: {}\n'.format(FPPI, miss_rate)
开发者ID:sigberto,项目名称:informed-haar,代码行数:29,代码来源:pipeline.py

示例3: NERValidator

class NERValidator(object):
    def __init__(self, recbysns, classifiers):
        self.recbysns = recbysns
        self.db = self.recbysns.db
        self.classifiers = classifiers
        self.evaluator = Evaluator()
        self.confusion_matrixes = {str(classifier):
                                   [] for classifier in self.classifiers}

    def validate(self):
        entities = [NEREntity(self.recbysns, entity)
                    for entity in self.db.select_table('recbysns_entity', '1')]
        for classifier in self.classifiers:
            self.test(classifier, entities)
        self.evaluator.evaluate(self.confusion_matrixes)

    def test(self, classifier, entities):
        confusion_matrix = {
                NER_BOOK:   {NER_BOOK: float(0), NER_MOVIE: float(0),
                             NER_VIDEO: float(0), NER_OTHERS: float(0)},
                NER_MOVIE:  {NER_BOOK: float(0), NER_MOVIE: float(0),
                             NER_VIDEO: float(0), NER_OTHERS: float(0)},
                NER_VIDEO:  {NER_BOOK: float(0), NER_MOVIE: float(0),
                             NER_VIDEO: float(0), NER_OTHERS: float(0)},
                NER_OTHERS: {NER_BOOK: float(0), NER_MOVIE: float(0),
                             NER_VIDEO: float(0), NER_OTHERS: float(0)},
        }
        for entity in entities:
            # predicted ner class
            p_ner_class = classifier.predict(entity)
            ner_class = entity.ner_class()
            confusion_matrix[ner_class][p_ner_class] += 1
        print confusion_matrix
        self.confusion_matrixes[str(classifier)].append(confusion_matrix)
开发者ID:jjyao,项目名称:recbysns,代码行数:34,代码来源:ner.py

示例4: __main__

def __main__(argv):
    #%%
    logger = logging.getLogger(__name__)
    logger.info("VECTOR MODEL INFORMATION RETRIEVAL SYSTEM START")    
    
    gli = InvertedIndexGenerator(GLI_CONFIG_FILE)
    gli.run()
    gli.write_output()
    
    index = Indexer(INDEX_CONFIG_FILE, TfidfVectorizer)
    index.run()
    index.write_output()
    
    pc = QueryProcessor(PC_CONFIG_FILE)
    pc.run()
    pc.write_output()
    
    buscador = SearchEngine(BUSCA_CONFIG_FILE, TfidfVectorizer)
    buscador.run()
    buscador.write_output()
    #%%
    avaliador = Evaluator(AVAL_CONFIG_FILE)
    avaliador.run()
    avaliador.write_output()
    
    logger.info("VECTOR MODEL INFORMATION RETRIEVAL SYSTEM DONE")     
开发者ID:ygorcanalli,项目名称:bri-2015-01,代码行数:26,代码来源:__main__.py

示例5: p_interpreter_other

 def p_interpreter_other(self, p):
     '''interpreter : comparision
                    | select
                    | array_selection
                    | func_call_stmt
                    | expression'''
     print Evaluator.visit(p[1])
开发者ID:k0ner,项目名称:sil,代码行数:7,代码来源:parser.py

示例6: SAValidator

class SAValidator(object):
    def __init__(self, recbysns, classifiers):
        self.recbysns = recbysns
        self.db = self.recbysns.db
        self.classifiers = classifiers
        self.evaluator = Evaluator()
        self.confusion_matrixes = {str(classifier): []
                                   for classifier in self.classifiers}

    def validate(self):
        entities = [SAEntity(self.recbysns, entity)
                    for entity in self.db.select_table('recbysns_entity',
                    "type in (%d,%d,%d)" % (NER_BOOK, NER_MOVIE, NER_VIDEO))]
        for classifier in self.classifiers:
            self.test(classifier, entities)
        self.evaluator.evaluate(self.confusion_matrixes)

    def test(self, classifier, entities):
        confusion_matrix = {
                SA_POSITIVE: {SA_POSITIVE: float(0), SA_NETURAL: float(0),
                              SA_NEGATIVE: float(0)},
                SA_NETURAL:  {SA_POSITIVE: float(0), SA_NETURAL: float(0),
                              SA_NEGATIVE: float(0)},
                SA_NEGATIVE: {SA_POSITIVE: float(0), SA_NETURAL: float(0),
                              SA_NEGATIVE: float(0)},
        }
        for entity in entities:
            # predicted sa_class
            p_sa_class = classifier.predict(entity)
            # actual sa_class
            sa_class = entity.sa_class()
            confusion_matrix[sa_class][p_sa_class] += 1
        print confusion_matrix
        self.confusion_matrixes[str(classifier)].append(confusion_matrix)
开发者ID:jjyao,项目名称:recbysns,代码行数:34,代码来源:sa.py

示例7: run

 def run(self):
     while 1:
         try:
             s = raw_input('calc> ')
         except EOFError:
             break
         if not s: continue
         Evaluator.visit(yacc.parse(s))
开发者ID:k0ner,项目名称:sil,代码行数:8,代码来源:interpreter.py

示例8: window_overlap_test

def window_overlap_test(window_overlap=2.):
    """  """

    train_labels, train_images, test_labels, test_images = get_training_and_test_data()

    # split to make experimentation quicker
    train_labels, train_images = get_subset_of_training_data(train_labels, train_images, split=0.5)

    training_size = len(train_labels)

    desc = "testing influence of window_overlap, set to {}. NB training size = {}".format(
        window_overlap,
        training_size
    )

    print desc

    selected_labels = list(set(train_labels))

    params = build_params(num_classes=len(selected_labels),
                          training_size=len(train_images),
                          test_size=len(test_images),
                          window_overlap=window_overlap,
                          fn_prefix="winoverlap-{}".format(window_overlap))

    trainer = SketchRecognitionTrainer(
        file_path=SketchRecognitionTrainer.get_cookbook_filename_for_params(params=params),
        run_parallel_processors=True,
        params=params
    )

    classifier = trainer.train_and_build_classifier(train_labels, train_images)
    encoded_test_labels = classifier.le.transform(test_labels)

    test_images_codelabels = trainer.code_labels_for_image_descriptors(
        trainer.extract_image_descriptors(test_images)
    )

    evaluator = Evaluator(
        clf=classifier.clf,
        label_encoder=classifier.le,
        params=params,
        output_filepath=SketchRecognitionTrainer.get_evaluation_filename_for_params(params=params)
    )

    # add timings to output
    evaluator.results["timings"] = {}
    for key, value in trainer.timings.iteritems():
        evaluator.results["timings"][key] = value

    # add comment
    evaluator.results["desc"] = desc

    evaluation_results = evaluator.evaluate(X=test_images_codelabels, y=encoded_test_labels)
    print evaluation_results
开发者ID:joshnewnham,项目名称:udacity_machine_learning_engineer_nanodegree_capstone,代码行数:55,代码来源:feature_engineering_tuning.py

示例9: Test

class Test(unittest.TestCase):


    def setUp(self):
        gold_directory = os.path.join(DATA_DIRECTORY, 'segment_data_test')
        result_directory = os.path.join(DATA_DIRECTORY, 'data_test_result')
        self.evaluator = Evaluator(gold_directory, result_directory)


    def test_calculate_precision(self):
        self.evaluator.calculate_precision()
开发者ID:dtkirsch,项目名称:vietnamese-text-recovery,代码行数:11,代码来源:module_test.py

示例10: main

def main():
	if len(sys.argv) != 6:
		assert False, "INSUFFICIENT ARGUMENTS!"

	filenames = [line.strip() for line in open(sys.argv[4])]
	ann_filepaths = [sys.argv[5] + '/' + filename[:len(filename)-4]+".ann" for filename in filenames]
	# print(ann_filepaths)
	
	data_param = {"dataset_name": sys.argv[1], "ann_filepaths": ann_filepaths,"n_label": int(sys.argv[2]), "gt_img_dir": sys.argv[3], "test_img_list_filepath": sys.argv[4], "result_dir": sys.argv[5], "mapping_label": color_class_map, "dir_output": sys.argv[5]}

	eval = Evaluator(data_param)
	eval.evaluate_all()
开发者ID:grafikaj,项目名称:lab1231-sun-prj,代码行数:12,代码来源:run_evaluator.py

示例11: main

def main():
    mode = argv[1]
    e = Evaluator()
    if mode == 'wikt':
        e.read_all_wiktionary()
        e.compare_with_triangles_stdin()
    elif mode == 'feat':
        e.write_labels(argv[2])
        e.featurize_and_uniq_triangles_stdin()
开发者ID:juditacs,项目名称:wikt2dict,代码行数:9,代码来源:compare_dicts.py

示例12: _process

 def _process(self):
     self.msg = self._receive(True)
     if self.msg:
         request = json.loads(self.msg.content)
         if request['request_type'] == 'games':
             self.games = request['data']
             self.show_dialog()
         if request['request_type'] == 'game_evaluation':
             PrintFormatter.results(request['data'])
             Evaluator.make_bet(self.mood, request['data'])
             print "\n********Results********\n"
             Evaluator.find_result(request['data'])
             self.show_dialog()
开发者ID:lpredova,项目名称:pybookie,代码行数:13,代码来源:client.py

示例13: main

def main():
    """Requests infix expressions, translates them to postfix,
    and evaluates them, until the user enters nothing."""
    while True:
        sourceStr = input("Enter an infix expression: ")
        if sourceStr == "": break
        try:
            scanner = Scanner(sourceStr)
            translator = Translator(scanner)
            postfix = translator.translate()
            evaluator = Evaluator(postfix)
            print("Value:", evaluator.evaluate())
        except Exception as e:
            print("Error:", e, translator.translationStatus())
开发者ID:Billy-The-Squid,项目名称:Cayley,代码行数:14,代码来源:evaluatorapp.py

示例14: test_end_to_end

    def test_end_to_end(self):
        with open("unit_tests/fixtures/tests_games.json") as file:
            data = json.loads(file.read())

        # Update player's source placeholder with actual code
        with open("unit_tests/fixtures/Snakes/Snakes.cpp") as source:
            data["source"] = source.read()

        # Update opponent's source placeholder with actual code
        with open("unit_tests/fixtures/Snakes/Opponent.cpp") as source:
            data["matches"][0]["source"] = source.read()

        evaluator = Evaluator(data)
        evaluator.evaluate()
开发者ID:espr1t,项目名称:action,代码行数:14,代码来源:test_games.py

示例15: solve

    def solve(self, instance, startpoint=None):
        if startpoint is None:
            startpoint = Random().solve(instance)

        e = Evaluator(instance)
        current = (startpoint, e.evaluate(startpoint))

        while True:
            next_step = self.select_step(e, current)
            if not next_step:
                break
            else:
                current = next_step

        return current[0]
开发者ID:powerllamas,项目名称:MiOIB,代码行数:15,代码来源:local_search.py


注:本文中的evaluator.Evaluator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。