ctgan小结

1.one-hot编码

 1 import numpy as np
 2 from sklearn.preprocessing import OneHotEncoder
 3 
 4 data = np.array([[1],[4]])
 5 ohe = OneHotEncoder(sparse=False,handle_unknown='ignore') # 显示编码
 6 onehot= ohe.fit_transform(data)
 7 categories = ohe.n_values_[0]
 8 
 9 print(onehot) # one-hot编码
10 print(categories) # 取值个数,从0开始计算的

结果:

原文地址:https://www.cnblogs.com/shuangcao/p/12960838.html