繁体   English   中英

MemoryError:无法为形状为 (323313, 3435) 且数据类型为 float64 的数组分配 8.27 GiB

[英]MemoryError: Unable to allocate 8.27 GiB for an array with shape (323313, 3435) and data type float64

我的数据框中有扩展名(例如 .exe、.py、.xml、.doc 等)表。 在终端上运行后,我在大数据集上遇到了上述错误。

encoder = OneHotEncoder(handle_unknown='ignore')
encoder.fit(features['Extension'].values.reshape(-1, 1))
temp = encoder.transform(features['Extension'].values.reshape(-1, 1)).toarray()  #GETTING ERROR on this
print("Size of array in bytes",getsizeof(temp))
print("Array :-",temp)
print("Shape :- ",features.shape, temp.shape)
features.drop(columns=['Extension'], axis=1, inplace=True)
dump(encoder, os.path.join(os.getcwd(), 'model_dumps', 'encoder.pkl'))
features.drop(columns=['Extension'], axis=1, inplace=True)
features = featureScaling(features)
features = np.concatenate((features, temp), axis=1)

输出 -

1) Size of array in bytes :- 8884558912
2) Array :- 
[[0. 0. 0. ... 0. 0. 0.]
 [0. 0. 0. ... 0. 0. 0.]
 [0. 0. 0. ... 0. 0. 0.]
 ...
 [1. 0. 0. ... 0. 0. 0.]
 [1. 0. 0. ... 0. 0. 0.]
 [1. 0. 0. ... 0. 0. 0.]]
3)Shape :- (323310, 8) (323310, 3435)

那很好笑。

MemoryError:无法为形状为 (323313, 3435) 且数据类型为 float64 的数组分配 8.27 GiB

大多数现代计算机的 RAM 不超过 8 Gb。 看起来您有 8 个,而 python 无法将所有这些数据放入内存中。 尝试购买另一台具有更多内存的计算机或升级您现有的计算机。 这肯定会解决问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM