[英]MemoryError: Unable to allocate 8.27 GiB for an array with shape (323313, 3435) and data type float64
I have extension(example .exe,.py,.xml,.doc etc) table in my dataframe.我的数据框中有扩展名(例如 .exe、.py、.xml、.doc 等)表。 after running on terminal I am getting above error on large data set.在终端上运行后,我在大数据集上遇到了上述错误。
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)
OUTPUT -输出 -
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)
that's funny.那很好笑。
MemoryError: Unable to allocate 8.27 GiB for an array with shape (323313, 3435) and data type float64 MemoryError:无法为形状为 (323313, 3435) 且数据类型为 float64 的数组分配 8.27 GiB
most modern computers don't have more than 8 Gb of RAM.大多数现代计算机的 RAM 不超过 8 Gb。 Looks like you have 8 and python is not able to fit all this data in the memory.看起来您有 8 个,而 python 无法将所有这些数据放入内存中。 Try buying another computer with more ram or upgrade your existing one.尝试购买另一台具有更多内存的计算机或升级您现有的计算机。 This will definitely fix the issue.这肯定会解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.