随机森林分类器预测的内存错误

时间:2016-04-05 10:15:59

标签: python classification

我在我的数据集上安装了一个随机森林分类器,其中包含7个功能和大约100万行或记录。

以下是我的代码。

randForestClassifier=RandomForestClassifier(n_estimators=10,max_depth=3)
randForestClassifier.fit(X_train,y)
pred=randForestClassifier.predict(featues_test)

当我使用分类器的预测方法时,我收到内存错误。如何解决?

以下是我的完整日志

randForestClassifier.predict(featues_test)
Traceback (most recent call last):

  File "<ipython-input-15-0b7612d6e958>", line 1, in <module>
    randForestClassifier.predict(featues_test)

  File "C:\Python27\lib\site-packages\sklearn\ensemble\forest.py", line 462, in predict
    proba = self.predict_proba(X)

  File "C:\Python27\lib\site-packages\sklearn\ensemble\forest.py", line 513, in predict_proba
    for e in self.estimators_)

  File "C:\Python27\lib\site-packages\sklearn\externals\joblib\parallel.py", line 659, in __call__
    self.dispatch(function, args, kwargs)

  File "C:\Python27\lib\site-packages\sklearn\externals\joblib\parallel.py", line 406, in dispatch
    job = ImmediateApply(func, args, kwargs)

  File "C:\Python27\lib\site-packages\sklearn\externals\joblib\parallel.py", line 140, in __init__
    self.results = func(*args, **kwargs)

  File "C:\Python27\lib\site-packages\sklearn\ensemble\forest.py", line 106, in _parallel_helper
    return getattr(obj, methodname)(*args, **kwargs)

  File "C:\Python27\lib\site-packages\sklearn\tree\tree.py", line 592, in predict_proba
    proba = self.tree_.predict(X)

  File "sklearn/tree/_tree.pyx", line 3207, in sklearn.tree._tree.Tree.predict (sklearn\tree\_tree.c:24468)

  File "sklearn/tree/_tree.pyx", line 3209, in sklearn.tree._tree.Tree.predict (sklearn\tree\_tree.c:24340)

MemoryError

1 个答案:

答案 0 :(得分:0)

是的,您正在col-md-4获取MemoryError,如堆栈跟踪所示:

randForestClassifier.predict(featues_test)

堆栈跟踪的其余行显示问题来自File "<ipython-input-15-0b7612d6e958>", line 1, in <module> randForestClassifier.predict(featues_test) ,在C代码中:sklearn