MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / tokens_to_vector

Function tokens_to_vector

unsupervised_class/books.py:68–73  ·  view source on GitHub ↗
(tokens)

Source from the content-addressed store, hash-verified

66
67# now let's create our input matrices - just indicator variables for this example - works better than proportions
68def tokens_to_vector(tokens):
69 x = np.zeros(len(word_index_map))
70 for t in tokens:
71 i = word_index_map[t]
72 x[i] += 1
73 return x
74
75N = len(all_tokens)
76D = len(word_index_map)

Callers 1

books.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected