【发布时间】:2021-03-05 22:35:15
【问题描述】:
我的数据框中有扩展名(例如 .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)
【问题讨论】:
-
@Ehtisham 我看到了那个帖子,但是在生产级别使用内核并不是一个好主意。
标签: python pandas numpy machine-learning one-hot-encoding