Task3 基于机器学习的文本分类
本章学习内容
学习内容在此网页中https://tianchi.aliyun.com/notebook-ai/detail?spm=5176.12586969.1002.12.6406111aIKCSLV&postId=118254
本章作业
1.尝试改变TF-IDF的参数,并验证精度。
- 改变参数ngram_range的值,(1,1)时候:f1_score为0.859;(1,3)时候:f1_score为0.871;(1,5)时候:f1_score为0.875。结论:提高ngram_range,能提高f1_score值,但是随后增加不了多少。
- 改变max_features的值,3000时候:f1_score为0.871;5000时候:f1_score为0.885;10000时候:f1_score为0.890。结论:提高max_features的值,能提高f1_score值,但是随后增加不了多少。
2.尝试使用其他机器学习模型,完成训练和验证。
小白这个不怎么理解。
X = train_test
y = np.array(train['label'])
X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.2,random_state=1000)
model = LogisticRegression(C=2.0)
model.fit(X_train,y_train)
y_predict = model.predict(X_test)
print(f1_score(y_predict, y_test, average='macro'))