python for循环中的多处理

时间:2019-08-27 10:00:40

标签: python-3.x for-loop multiprocessing python-multiprocessing

我正在尝试通过遍历参数以选择最佳模型来优化for循环,该循环是通过多处理池方法进行的。

for k in range(0, len(algo['mthod'])):          
                    start_time = time.time()
                    mv = mv(c.deepcopy(newob))
                    method = getattr(mv, algorithm['method'][k])
                    # results contains the predicted values for all the validation
                    # sets, the values returned is in the form of a dictionary
                    # numbered same as the validation dataframes
                    pool = mp.Pool(mp.cpu_count())
                    results = pool.starmap(method(algorithm['parameters'][k]))
                    #<<output>> format {'1':[results],'2':[results]}
                    Algo_time = time.time()-start_time

我收到错误消息: TypeError:starmap()缺少1个必需的位置参数:'iterable'

如何解决这个问题?

0 个答案:

没有答案