sklearn classifier get ValueError: bad input shape

后端 未结 2 1029
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-17 09:59

I have a csv, struct is CAT1,CAT2,TITLE,URL,CONTENT, CAT1, CAT2, TITLE ,CONTENT are in chinese.

I want train LinearSVC or Multinomial

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-17 10:36

    Thanks to @meelo, I solved this problem. As he said: in my code, data is a feature vector, target is target value. I mixed up two things.

    I learned that TfidfVectorizer processes data to [data, feature], and each data should map to just one target.

    If I want to predict two type targets, I need two distinct targets:

    1. target_C1 with all C1 value
    2. target_C2 with all C2 value.

    Then use the two targets and original data to train two classifier for each target.

提交回复
热议问题