简体   繁体   中英

Convolutional neural network for multi-classes text classification

I have a CSV file with two columns, 'sentence' is string of sentences, emoID is 1-7 integer such as following:

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

I need to classify each sentence to its corresponding emoID. I saw a example that classify two classes likes follow:

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

Now I have 7 classes rather than two, how could I generate 7 labels for each class? I am beginner of python, many thanks for your help!

您可以使用具有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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM