神经网络方法的标签操作LabelEncoder
发布时间
阅读量:
阅读量
本文介绍一个简单的编码转换方式。对不连续的标签编码成向量表示。
该方法应用于神经网络实现分类任务具有一定的普遍性,在神经网络的输出层中,输出一个向量空间,并将该向量空间中的某个维度标记为1即可表示为该类别。
#导包
from sklearn.preprocessing import LabelEncoder
from keras.utils import np_utils
#例子
a is a sequence containing the integers [1 through 4].
encoder is an instance of LabelEncoder.
The encoder processes the sequence a to produce encoded_Y.
The dummy_y variable holds the categorical representation of encoded_Y.
print(dummy_y, dummy_y.shape)
#运行结果

结果分析:
a列表中有1, 2, 3, 4这几种数字,每个数字结果
全部评论 (0)
还没有任何评论哟~
