LDA模型和Joblib并行计算错误

时间:2018-08-28 02:42:48

标签: python scikit-learn lda joblib

我有一些代码可以在一堆CSV行上进行LDA模型。

SELECT *
FROM source
WHERE 234 IN(
    SELECT user_id
    FROM usergroup  
    )
    OR 
    SOURCE.source_id IN(
        SELECT sl.source_id
        FROM sourcelevel SL
    );

我第一次没有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_name_ line

因此,我尝试添加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. 代码以使其正常工作。我仍然有问题。我尝试将其插入到代码的各个位置(我在Windows上),但没有任何效果。我需要添加其他内容吗?

0 个答案:

没有答案