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


Python Evaluator.results["timings"][key]方法代码示例

本文整理汇总了Python中evaluator.Evaluator.results["timings"][key]方法的典型用法代码示例。如果您正苦于以下问题:Python Evaluator.results["timings"][key]方法的具体用法?Python Evaluator.results["timings"][key]怎么用?Python Evaluator.results["timings"][key]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在evaluator.Evaluator的用法示例。


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

示例1: window_overlap_test

# 需要导入模块: from evaluator import Evaluator [as 别名]
# 或者: from evaluator.Evaluator import results["timings"][key] [as 别名]
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,代码行数:57,代码来源:feature_engineering_tuning.py

示例2: training_size_test

# 需要导入模块: from evaluator import Evaluator [as 别名]
# 或者: from evaluator.Evaluator import results["timings"][key] [as 别名]
def training_size_test(split=0.5):
    """
    see what effect the training size has on the performance, initially take off 50%
    """
    print "test_2"

    train_labels, train_images, test_labels, test_images = get_training_and_test_data()

    train_labels, train_images = get_subset_of_training_data(train_labels, train_images, split=split)

    selected_labels = list(set(train_labels))

    params = build_params(num_classes=len(selected_labels),
                          training_size=len(train_images),
                          test_size=len(test_images))

    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"] = "After many iterations, this is a baseline for which tuning will benchmark from"

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

示例3: sanity_check

# 需要导入模块: from evaluator import Evaluator [as 别名]
# 或者: from evaluator.Evaluator import results["timings"][key] [as 别名]
def sanity_check():
    """ baseline test, all all parameters from experimentation """

    train_labels, train_images, test_labels, test_images = get_training_and_test_data()

    train_labels, train_images = get_subset_of_training_data(train_labels, train_images, split=0.05)

    selected_labels = list(set(train_labels))

    params = build_params(
        num_classes=len(selected_labels),
        training_size=len(train_images),
        test_size=len(test_images),
        fn_prefix="sanitycheck"
    )

    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"] = "After many iterations, this is a baseline for which tuning will benchmark from"

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

示例4: cluster_size_test

# 需要导入模块: from evaluator import Evaluator [as 别名]
# 或者: from evaluator.Evaluator import results["timings"][key] [as 别名]
def cluster_size_test(num_clusters=200):
    """  """

    train_labels, train_images, test_labels, test_images = get_training_and_test_data()

    selected_labels = list(set(train_labels))

    params = build_params(num_classes=len(selected_labels),
                          training_size=len(train_images),
                          test_size=len(test_images),
                          num_clusters=num_clusters)

    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"] = "testing influence of num_clusters, set to {}".format(num_clusters)

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

示例5: clustering_algorithm_test

# 需要导入模块: from evaluator import Evaluator [as 别名]
# 或者: from evaluator.Evaluator import results["timings"][key] [as 别名]
def clustering_algorithm_test(clustering='kmeans'):
    """  """

    from sklearn.cluster import KMeans
    from sklearn.cluster import MiniBatchKMeans
    import multiprocessing

    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 different clustering algorithms, using {} for a training size of {}".format(
        clustering,
        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),
                          fn_prefix="clustering-{}".format(clustering))

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

    if clustering == "kmeans":
        trainer.clustering = KMeans(
            init='k-means++',
            n_clusters=params[ParamKeys.NUM_CLUSTERS],
            n_init=10,
            max_iter=10,
            tol=1.0,
            n_jobs=multiprocessing.cpu_count() if trainer.run_parallel_processors else 1
        )
    elif clustering == "minibatchkmeans":
        trainer.clustering = MiniBatchKMeans(
            init='k-means++',
            n_clusters=params[ParamKeys.NUM_CLUSTERS],
            batch_size=100,
            n_init=10,
            max_no_improvement=10,
            verbose=0
        )
    elif clustering == "meanshift":
        trainer = MeanShiftSketchRecognitionTrainer(
            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,代码行数:86,代码来源:feature_engineering_tuning.py


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