I am trying to extract some functions from this document, given a given set of functions.
from sklearn.feature_extraction.text import CountVectorizer
features = ['a', 'b', 'c']
doc = ['a', 'c']
vectoriser = CountVectorizer()
vectoriser.vocabulary = features
vectoriser.fit_transform(doc)
However, the output is a 2x3 array filled with zeros, not:
desired_output = [[1, 0, 0]
[0, 0, 1]]
Any help would be greatly appreciated
source
share