6
我在客户支持方面工作,并且使用scikit-learn预测我们的票的标签,给定一组训练券(约40,000张训练券组)。Python:使用scikit-learn预测,给出空白预测
我使用基于this one的分类模型。它只是预测“()”作为我的许多测试集的标签,即使训练集中没有任何标签没有标签。
我对标签的训练数据是一个列表的列表,如:
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 np
import scipy
from sklearn.pipeline import Pipeline
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction.text import TfidfTransformer
from sklearn.multiclass import OneVsRestClassifier
from sklearn.svm import LinearSVC
# We have lists called tags_train, descs_train, tags_test, descs_test with the test and train data
X_train = np.array(descs_train)
y_train = tags_train
X_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'),()]
我不明白为什么在训练集中没有任何东西时预测为空()。它不应该预测最接近的标签吗?任何人都可以推荐我使用的模型的任何改进?
非常感谢您的帮助!
[CountVectorizer文档】(http://scikit-learn.org/dev/modules/generated/sklearn.feature_extraction.text.CountVectorizer.html) [ TfidfTransformer documentation](http://scikit-learn.github.io/scikit-learn.org/0.8/modules/generated/scikits.learn.feature_extraction.text.TfidfTransformer.html) [OneVsRestClassifier documentation](http:///scikit-learn.org/dev/modules/generated/sklearn.multiclass.OneVsRestClassifier.html) – jegeragh
你想要多类还是多标签分类?是否允许使用多个标签标记票证? – mbatchkarov
是的,多标签! – jegeragh