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


Python File.write_json方法代码示例

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


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

示例1: enumerate

# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import write_json [as 别名]
    for j, candidate in enumerate(training_with_label):
        dist = DTW.dist(data, candidate['data'])

        if dist < min_dist:
            min_dist = dist
            min_pos = j

    predicted = training_with_label[min_pos]['label']

    if predicted == label:
        correctness += 1

    print('min_dist:', min_dist)
    print('min_pos:', min_pos)
    print('predicted label:', predicted)
    print('actual label:', label)

print('correctness:', correctness)
print('accuracy:', correctness / len(testing) * 100)

result['dtw'] = {
    "correctness": correctness,
    "total": len(testing),
    'accuracy': correctness / len(testing) * 100
}

# write to file
File.write_json('Coffee.json', result)

开发者ID:phizaz,项目名称:time-series-dtw,代码行数:30,代码来源:main.py

示例2: enumerate

# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import write_json [as 别名]
        "train": File.open_with_label("Beef_TRAIN"),
        "test": File.open_with_label("Beef_TEST"),
        "fn": two_sym_fn,
    },
    {
        "title": "Beef.P=2.asym",
        "train": File.open_with_label("Beef_TRAIN"),
        "test": File.open_with_label("Beef_TEST"),
        "fn": two_asym_fn,
    },
]

for i, job in enumerate(jobs):
    print("job:", i, "of", len(jobs))
    print("job:", job["title"])

    result = {"title": job["title"]}

    start_time = time.process_time()

    accuracy, correctness = DTW.predict_list(job["train"], job["test"], job["fn"])

    end_time = time.process_time()

    result["accuracy"] = accuracy
    result["correctness"] = correctness
    result["total"] = len(job["test"])
    result["time_elapsed"] = end_time - start_time

    File.write_json(job["title"] + ".json", result)
开发者ID:phizaz,项目名称:time-series-dtw,代码行数:32,代码来源:advance.py

示例3: print

# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import write_json [as 别名]
                print('c:', c)

                start_time = time.process_time()

                accuracy, correctness = DTW.predict_list(job['train'], job['test'], [a, b, c], [ [-1, 0], [0, -1], [-1, -1] ])

                print('[', a, b, c, ']', 'accuracy:', accuracy, 'correctness:', correctness)

                end_time = time.process_time()
                time_elasped = end_time - start_time
                print('time_elapsed:', time_elasped)

                result = {
                    'a': a,
                    'b': b,
                    'c': c,
                    'accuracy': accuracy,
                    'correctness': correctness,
                    'total': len(job['test']),
                    'time_elapsed': time_elasped
                }

                results['results'].append(result)

    end_time = time.process_time()

    results['time_elapsed'] = end_time - start_time

    File.write_json(job['title'] + '.json', results)

开发者ID:phizaz,项目名称:time-series-dtw,代码行数:31,代码来源:normal_3x3.py


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