# user_list 用户文本
# user_lable 用户标签
x_train, x_test, y_train, y_test = train_test_split(user_list, user_label, test_size=0.25, random_state = 0)
count = CountVectorizer(stop_words='english')
train_count = count.fit_transform(x_train)
test_count = count.transform(x_test)
tfidf = TfidfVectorizer(stop_words='english')
train_tfidf = tfidf.fit_transform(x_train)
tes_tfidf = tfidf.transform(x_test)
x_train = scipy.sparse.hstack([train_count, train_tfidf])
x_test = scipy.sparse.hstack([test_count, tes_tfidf])
scipy.sparse.hstack 横向合并系数矩阵
如果训练集和测试集都使用 fit_transform()函数,predict()函数会报错