When you have features in dict and want to make an array format vector like that used in scipy or scikit-learn
from sklearn.feature_extraction import DictVectorizer
features = [{"poko":2, "hoge":1}, {"hoge":2, "pokopoko":10}, {"poko":5, "hogehoge":1}]
vec = DictVectorizer()
array_vectors = vec.fit_transform(features).toarray()
I can go. When you want to see the feature label
vec.get_feature_names()
so
Recommended Posts