用于多类文本分类的卷积神经网络

时间:2016-11-28 12:43:25

标签: python python-3.x conv-neural-network text-classification

我有一个包含两列的CSV文件,'sentence'是一串句子,emoID是1-7整数,如下所示:

sentence           emoID
During the period of falling in love.       1
When I was involved in a traffic accident.  2
 .....                                      ...

我需要将每个句子分类为相应的emoID。我看到了一个例子,它将两个类分类为:

# Generate labels
positive_labels = [[0, 1] for _ in positive_examples]
negative_labels = [[1, 0] for _ in negative_examples]

现在我有7个课而不是2个,我怎么能为每个课生成7个标签?我是python的初学者,非常感谢你的帮助!

1 个答案:

答案 0 :(得分:0)

你可以使用一个包含7个条目的数组,对于类n,在数组中的位置n处具有条目1,其余为0。第3类:[0,0,1,0,0,0,0] 和

c3_labels = [[0,0,1,0,0,0,0] for _ in c3_examples]