Python LDA模型与joblib并行计算误差
我有一些代码在一堆CSV行上执行LDA模型Python LDA模型与joblib并行计算误差,python,scikit-learn,lda,joblib,Python,Scikit Learn,Lda,Joblib,我有一些代码在一堆CSV行上执行LDA模型 lda_model = LatentDirichletAllocation( n_components=20, # Number of topics max_iter=10, # Max learning iterations learning_method='online', random_state=100, # Random state
lda_model = LatentDirichletAllocation(
n_components=20, # Number of topics
max_iter=10, # Max learning iterations
learning_method='online',
random_state=100, # Random state
batch_size=128, # n docs in each learning iter
evaluate_every = -1, # compute perplexity every n iters, default: Don't
n_jobs = -1, # Use all available CPUs
)
if __name__ == "__main__":
lda_output = lda_model.fit_transform(data_vectorized)
print(lda_model)
我第一次运行它时没有if\u name\u行
,没有任何问题。第二次运行时,出现了错误
ImportError: [joblib] Attempting to do parallel computing without
protecting your import on a system that does not support forking. To
use parallel-computing in a script, you must protect your main loop
using "if __name__ == '__main__'". Please see the joblib documentation
on Parallel for more information.
因此,我尝试添加
if\u name\u
代码以使其工作。我仍然有问题。我试着在我的代码中的不同位置(我在Windows上)插入它,但没有任何效果。是否需要添加其他内容?您是否使用IPython(例如Jupyter)?在使用交互式python的windows上使用joblib
时存在一个已知问题。我使用的是Spyder环境,我相信它使用的是IPython控制台。谢谢你的提示。我看看能不能解决这个问题。看看有没有可能的解决办法。