python 模型运行时评估

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 模型运行时评估相关的知识,希望对你有一定的参考价值。

def evaluate_cores(model, data, n_samples, stride=1000, printer=False):
    """
    evaluate multicore model training time
    
    """
    N = [n for n in range(stride, (n_samples+stride), stride)]  # the number of samples we're using, stride of 1000

    cores = os.cpu_count()  # get the number of cores

    model_dict = {f"model_{n}": model(n_jobs=n) for n in range(1, cores+1)}  # contruct model:instance pairs
    data_dict = {model: [] for model in model_dict.keys()}  # prep data for storage

    if printer: print("Starting evaluation...")
    for n in N:
        print(f"\n  n={n}")
        sample = bootstrap(data.copy(), n=n, to_df=True)  # get bootstrap sample data

        for k in data_dict.keys():
            if printer: print(f"\tTraining model {k}")
            start = time.time()
            data_dict[k].append(test_model(model_dict[k], sample))  # add times to dict
            if printer: print(f"\t  - mean fit time: {(time.time() - start):.2f} s")

    data_dict['N'] = N

    df = pd.DataFrame.from_dict(data_dict)

    return df

以上是关于python 模型运行时评估的主要内容,如果未能解决你的问题,请参考以下文章

sizeof 是在编译时还是运行时评估?

jquery click函数声明在运行时评估变量

nameof() 是在编译时评估的吗?

如何判断表达式是在编译时还是运行时评估的?

将变量转换为Scala“运行时评估”中的方法

在 Django 1.11 admin 中创建新对象时评估只读字段