2013-10-11 47 views
0

我sklearn版本是0.14.1在Linux上的Debian GNU/Linux的7.1平行随机森林scikit学习抛出一个异常

调用蟒蛇2.7:

clf = RandomForestClassifier(min_samples_split = 10, n_estimators = 50 , n_jobs = 1) is ok 

同时呼吁:

clf = RandomForestClassifier(min_samples_split = 10, n_estimators = 50 , n_jobs = 5) 
clf.fit(train.toarray(), targets) 

抛出以下异常:

Traceback (most recent call last): 
File "/usr/lib/python2.7/threading.py", line 552, in bootstrap_inner 
self.run() 
File "/usr/lib/python2.7/threading.py", line 505, in run 
self.target(self.__args, *self.__kwargs) 
File "/usr/lib/python2.7/multiprocessing/pool.py", line 342, in handletasks 
put(task) 
SystemError: NULL result without error in PyObject_Call 

抛出异常后,随机森林的所有进程都被阻塞

+0

是什么形状和D型数据的? – ogrisel

+0

实际上,输入数据与帖子的格式相同,http://stackoverflow.com/questions/19265097/why-does-cross-validation-for-randomforestregressor-fail-in-scikit-learn。 dtype是浮动的。 – mike

+0

但是由于'load_data'没有在该文章中描述,所以无法知道所产生的形状。请打电话给'print(train.shape)'并在结果中加入你的描述。 – ogrisel

回答

2

根据形状信息,数据集应该是〜4GB(对于单精度浮点数)。这个异常可能是由于多处理序列化数据将其传递给工作进程时内存用尽造成的。

要限制的内存拷贝次数,您可以尝试通过一个符号链接或JOBLIB回购的主分支的joblib子文件夹的副本替换sklearn/externals/joblib文件夹:https://github.com/joblib/joblib

开发版本joblib已被改进为使用大输入数组的内存映射。这可能会解决您的问题。

编辑内存映射支持已登陆JOBLIB 0.8及更高版本,默认情况下在包括scikit学习0.15+

+0

谢谢。我会尝试新的joblib版本。有没有办法在多机器上分割数据并运行scikit-learn的随机森林?任何库支持? – mike

+0

这是可能的(例如与IPython.parallel),但没有现成的库和组合子模型也是模型类特定的。我在https://github.com/ogrisel/parallel_ml_tutorial和http://vimeo.com/63269736中讨论这个问题 – ogrisel