将tfidf和keras应用于python中的多类文本分类

时间:2018-12-05 18:42:54

标签: python keras text-classification tf-idf tfidfvectorizer

我将skealearn应用到10类文本分类中,我使用

   def featureextraction2(data , clf):
    data.dropna(inplace=True)
    X_train, X_test, y_train, y_test = \
    train_test_split(data['text'], data['class'], random_state = 0)
    vect = CountVectorizer().fit(X_train)
    X_train_vectorized = vect.transform(X_train)
    #clf = LogisticRegression()
    clf.fit(X_train_vectorized, y_train)

我想在tfidf中应用keras 当我使用此代码(在define model之后)不起作用

model.fit([X_train_vectorized], batch_size=64, y=to_categorical(y_train), verbose=1, validation_split=0.3, 
          shuffle=True, epochs=5, callbacks=[checkpointer])

0 个答案:

没有答案