Hi Sicco.
This is desired behavior.
If you want to always get a label, you could have a look at the 
decision_function
and just predict the label with the highest score if no label was predicted.

Cheers,
Andy

----- Ursprüngliche Mail -----
> Von: "Sicco van Sas" <[email protected]>
> An: [email protected]
> Gesendet: Freitag, 20. Juli 2012 16:08:06
> Betreff: [Scikit-learn-general] LinearSVC somtimes returns no label
> 
> Hi all,
> 
> I use LinearSVC for multi-class multi-label text classification, but
> the
> learned classifier doesn't always output a label when I try to
> classify
> a test sample.
> 
> Here is the code:
> 
> classifier = Pipeline([
>         ('vectorizer', CountVectorizer()),
>          ('tfidf', TfidfTransformer()),
>          ('clf', OneVsRestClassifier(LinearSVC()))])
> classifier.fit(train_txt, train_labels)
> print str(classifier.predict(example_txt))
> 
> Sometimes I get a fine results, e.g. [(u'dogs',)] , while it
> sometimes
> also returns nothing: [()]
> It seems that the more samples I train the classifier on, the less it
> will output nothing, but even training on 20k samples still sometimes
> results in no labels as output. E.g., training on 10k sampels,
> results
> in approx 80. classifiers. I tested on 5k samples and approx 30% of
> the
> samples were given no label, while the ones that did get one of more
> labels performed quite good.
> 
> Is there a way to force the classifier to always predict at least 1
> label?
> 
> Cheers,
> Sicco
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond.
> Discussions
> will include endpoint security, mobile security and the latest in
> malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
> 

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to