【问题标题】:Memory failure while trying to train a logistic regression model尝试训练逻辑回归模型时出现内存故障
【发布时间】:2019-11-30 11:50:33
【问题描述】:

我遇到了这个失败:

文件“C:\Users\ophirbh\AppData\Roaming\Python\Python38\site-packages\scipy\special_logsumexp.py”,第 112 行,在 logsumexp tmp = np.exp(a - a_max) MemoryError: Unable to allocate array with shape (950028, 45) and data type float64

对于该代码:

from sklearn import datasets
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import cross_val_score

X, y = datasets.load_svmlight_file('converted_features')
clf = LogisticRegression(random_state = 0, solver = 'lbfgs', multi_class = 
'multinomial',max_iter=2).fit(X,y)
print(cross_val_score(clf, X, y, scoring='recall_macro', cv = 5))

有什么办法吗?

【问题讨论】:

    标签: python-3.x machine-learning nlp


    【解决方案1】:

    在这种情况下,您似乎内存不足,您可以使用google colab 进行快速实验,而不会遇到任何内存问题。

    【讨论】:

      猜你喜欢
      • 2020-10-26
      • 2018-05-01
      • 2015-11-18
      • 2020-02-25
      • 2019-07-11
      • 2017-07-08
      • 2022-01-21
      • 2022-01-12
      • 2015-01-07
      相关资源
      最近更新 更多