(tokens, label)
| 92 | |
| 93 | # now let's create our input matrices |
| 94 | def tokens_to_vector(tokens, label): |
| 95 | x = np.zeros(len(word_index_map) + 1) # last element is for the label |
| 96 | for t in tokens: |
| 97 | i = word_index_map[t] |
| 98 | x[i] += 1 |
| 99 | x = x / x.sum() # normalize it before setting label |
| 100 | x[-1] = label |
| 101 | return x |
| 102 | |
| 103 | N = len(positive_tokenized) + len(negative_tokenized) |
| 104 | # (N x D+1 matrix - keeping them together for now so we can shuffle more easily later |