python - 使用 Python tpot 配置 njobs

标签 python python-3.x scikit-learn tpot

是否可以在代码中使用 tpot 配置 njobs 参数而不是作为命令行参数传递?

阅读 https://rhiever.github.io/tpot/using/状态:

-njobs  NUM_JOBS    Any positive integer or -1  Number of CPUs for evaluating pipelines in parallel during the TPOT optimization process. 

Assigning this to -1 will use as many cores as available on the computer.

但是如何在代码中配置这个参数呢?

尝试:

TPOTClassifier(generations=5, verbosity=3,  config_dict='TPOT light' , NUM_JOBS = 4)  

返回错误:

TPOTClassifier(generations=5, verbosity=3,  config_dict='TPOT light' , NUM_JOBS = 4)
TypeError: __init__() got an unexpected keyword argument 'NUM_JOBS'

最佳答案

使用n_jobs参数实现:

TPOTClassifier(
    generations=5,
    verbosity=3,
    config_dict='TPOT light',
    n_jobs=4
)

关于python - 使用 Python tpot 配置 njobs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46977794/

相关文章:

python - 使用pybing时出错

python - QCoreApplication 没有正常终止

python - 如何在python中粘贴从键盘复制的文本

python - sklearn log_loss 不同数量的类

python矩阵搜索

python - TCP 服务器/客户端 : [Errno 32] Broken pipe

python-3.x - 正则表达式从文本文件中捕获包含制表符/空格和子字符串的字符串部分

python - 使用 .score() 方法时出错 : shapes (10719, 1) 和 (16,1) 未对齐 : 1 (dim 1) ! = 16 (dim 0)

scikit-learn - scikit-learn(sklearn) : TypeError: 'KFold' object is not iterable 中的 GridSearchCV

python - 从列表中获取子字符串