2

I'm using scikit learn for document classification and i would like to know if there is a way to predict more than one classe (with the coresponding probability)

Here is the code i'm using :

vectorizer = CountVectorizer(max_df=4000, min_df=4, strip_accents="unicode", analyzer="word", max_features=4000,stop_words=stopwords, charset="utf-8", token_pattern="\w{4,}") 
x1_vect=vectorizer.fit_transform(x1)

clf = OneVsRestClassifier(LinearSVC())
#or
#clf = MultinomialNB()

clf.fit(x1_vect,y1)
prediction = clf.predict(xpred_vect)

I get only on prediction and would like to have more (with corresponding probability)

4

2 回答 2

0

linearSVC为此.decision_function()。其他一些分类器给出 0 到 1 之间的预测.predict_proba()

于 2013-05-29T10:01:09.610 回答
0

事实上(我回答了我自己的问题),对于一些分类器(我使用的linearSVC),有一种方法叫做

clf.decision_function

它给出了“样本的置信度分数,即该样本到超平面的有符号距离”

于 2013-01-23T16:46:52.420 回答