CountVectorizer nicht drucken Wortschatz

Habe ich installiert python 2.7, numpy 1.9.0, scipy 0.15.1 und scikit-learn-0.15.2.
Nun, wenn ich den folgenden Code in python:

train_set = ("The sky is blue.", "The sun is bright.")
test_set = ("The sun in the sky is bright.",
"We can see the shining sun, the bright sun.")

from sklearn.feature_extraction.text import CountVectorizer
vectorizer = CountVectorizer()

print vectorizer


    CountVectorizer(analyzer=u'word', binary=False, charset=None,
    charset_error=None, decode_error=u'strict',
    dtype=<type 'numpy.int64'>, encoding=u'utf-8', input=u'content',
    lowercase=True, max_df=1.0, max_features=None, min_df=1,
    ngram_range=(1, 1), preprocessor=None, stop_words=None,
    strip_accents=None, token_pattern=u'(?u)\\b\\w\\w+\\b',
    tokenizer=None, vocabulary=None)

     vectorizer.fit_transform(train_set)
    print vectorizer.vocabulary

    None.

Eigentlich sollte es ausgedruckt habe, die folgenden:

CountVectorizer(analyzer__min_n=1,
analyzer__stop_words=set(['all', 'six', 'less', 'being', 'indeed', 'over',    
 'move', 'anyway', 'four', 'not', 'own', 'through', 'yourselves', (...) --->     
For count vectorizer

{'blue': 0, 'sun': 1, 'bright': 2, 'sky': 3} ---> for vocabulary

Den obigen code aus dem blog:
http://blog.christianperone.com/?p=1589

Könnten Sie mir bitte helfen warum erhalte ich so ein Fehler. Da das Vokabular nicht indiziert ist richtig ich bin nicht in der Lage, um voranzukommen im Verständnis des Konzepts der TF-IDF. Ich bin ein Neuling für python, so dass jede Hilfe wäre sehr geschätzt.

Arc.

InformationsquelleAutor Archana | 2015-03-06

Schreibe einen Kommentar