Keras LabelEncoder fit_transform()函数中的问题

时间:2019-07-15 16:31:05

标签: keras deep-learning nlp

我要在python餐馆评论数据集上实现ABSA任务。而且我想使用Sklearn和Keras对Aspect_category进行编码以虚拟(二进制)变量:

  • labeled_df ['aspect_category']的结构如下(dtype:对象)

0 [RESTAURANT#GENERAL]

1 [SERVICE#GENERAL]

2 [SERVICE#GENERAL]

3 [FOOD#QUALITY,FOOD#STYLE_OPTIONS]

4 [SERVICE#GENERAL]

5 [RESTAURANT#GENERAL]

6 [FOOD#QUALITY]

7 [RESTAURANT#GENERAL]

   from keras.utils import to_categorical
   label_encoder = LabelEncoder()
   integer_category= label_encoder.fit_transform(labeled_df['aspect_category'])
   dummy_category = to_categorical(integer_category)

行出现错误(参数必须是字符串或数字)
   integer_category= label_encoder.fit_transform(labeled_df['aspect_category'])

我会很高兴听到您的解决方案。谢谢!

0 个答案:

没有答案