我会有一个关于如何在分类问题中添加更多分类字段的问题。我的数据集最初有 4 个字段:
Date Text Short_Mex Username Label
01/01/2020 I am waiting for the TRAIN A train is coming Ludo 1
01/01/2020 you need to keep distance Social Distance is mandatory wgriws 0
...
02/01/2020 trump declared war against CHINESE technology China’s technology is out of the games Fwu32 1
...
我将此数据集加入到一个带有标签的新数据集,其值为 1 或 0。这将需要分类。
但是,我还从原始数据集中提取了其他字段,例如字符数、大写单词、最常用的术语等。其中一些字段可能对分类有用,因为我可以根据大写而不是小写的单词分配更多的“权重”。
所以我需要使用带有这些字段的新数据集:
Date Text Short_Mex Username Upper Label
01/01/2020 I am waiting for the TRAIN A train is coming Ludo [TRAIN] 1
01/01/2020 you need to keep distance Social Distance is mandatory wgriws [] 0
...
02/01/2020 trump declared war against CHINESE technology China’s technology is out of the games Fwu32 [CHINESE] 1
...
我想问您如何将此信息(大写)添加为我的分类器的新信息。我目前正在做的事情如下:
#Train-test split
x_train,x_test,y_train,y_test = train_test_split(df['Text'], news.target, test_size=0.2, random_state=1)
#Logistic regression classification
pipe1 = Pipeline([('vect', CountVectorizer()), ('tfidf', TfidfTransformer()), ('model', LogisticRegression())])
model_lr = pipe1.fit(x_train, y_train)
lr_pred = model_lr.predict(x_test)
print("Accuracy of Logistic Regression Classifier: {}%".format(round(accuracy_score(y_test, lr_pred)*100,2)))
print("\nConfusion Matrix of Logistic Regression Classifier:\n")
print(confusion_matrix(y_test, lr_pred))
print("\nCLassification Report of Logistic Regression Classifier:\n")
print(classification_report(y_test, lr_pred))