Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Create tf–idf matrix
- from sklearn.feature_extraction.text import TfidfVectorizer
- vectorizer = TfidfVectorizer(stop_words = 'english')
- X = vectorizer.fit_transform(corpus)
- X.todense()
- Out[37]:
- matrix([[ 0.89469821, 0. , 0. , 0. , 0. ,
- 0.23513012, 0. , 0. , 0. , 0.29823274,
- 0. , 0.23513012],
- [ 0. , 0. , 0. , 0.70710678, 0. ,
- 0. , 0.70710678, 0. , 0. , 0. ,
- 0. , 0. ],
- [ 0. , 0.35415727, 0.35415727, 0. , 0. ,
- 0.55844332, 0. , 0. , 0. , 0. ,
- 0.35415727, 0.55844332],
- [ 0. , 0. , 0. , 0.38274272, 0.48546061,
- 0. , 0.38274272, 0.48546061, 0.48546061, 0. ,
- 0. , 0. ]])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement