为了账号安全,请及时绑定邮箱和手机立即绑定

Python:使用scikit-learn进行预测,给出空白预测

Python:使用scikit-learn进行预测,给出空白预测

千万里不及你 2021-03-16 17:12:48
我从事客户支持工作,在给定一组培训票证的情况下,我正在使用scikit-learn来预测我们机票的标签(培训集中约40,000张票证)。我正在使用基于此模型的分类模型。即使训练集中的所有票证都没有标签,它也只是将“()”作为我的许多票证测试组的标签进行预测。我的标签训练数据是一个列表列表,例如:tags_train = [['international_solved'], ['from_build_guidelines my_new_idea eligibility'], ['dropbox other submitted_faq submitted_help'], ['my_new_idea_solved'], ['decline macro_backer_paypal macro_prob_errored_pledge_check_credit_card_us loading_problems'], ['dropbox macro__turnaround_time other plq__turnaround_time submitted_help'], ['dropbox macro_creator__logo_style_guide outreach press submitted_help']]虽然我的票务说明训练数据只是一个字符串列表,例如:descs_train = ['description of ticket one', 'description of ticket two', etc]这是构建模型的代码的相关部分:import numpy as npimport scipyfrom sklearn.pipeline import Pipelinefrom sklearn.feature_extraction.text import CountVectorizerfrom sklearn.feature_extraction.text import TfidfTransformerfrom sklearn.multiclass import OneVsRestClassifierfrom sklearn.svm import LinearSVC# We have lists called tags_train, descs_train, tags_test, descs_test with the test and train dataX_train = np.array(descs_train)y_train = tags_trainX_test = np.array(descs_test)  classifier = Pipeline([    ('vectorizer', CountVectorizer()),    ('tfidf', TfidfTransformer()),    ('clf', OneVsRestClassifier(LinearSVC(class_weight='auto')))])classifier.fit(X_train, y_train)predicted = classifier.predict(X_test)但是,“预测”给出的列表如下:predicted = [(), ('account_solved',), (), ('images_videos_solved',), ('my_new_idea_solved',), (), (), (), (), (), ('images_videos_solved', 'account_solved', 'macro_launched__edit_update other tips'), ('from_guidelines my_new_idea', 'from_guidelines my_new_idea macro__eligibility'), ()]我不明白为什么训练集中没有空白()的原因。它不应该预测最接近的标签吗?谁能推荐我正在使用的模型的任何改进?非常感谢您的提前帮助!
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 314 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号