Wikipedia在描述特征哈希时提供了以下示例;但映射似乎与定义的字典不一致
例如,to
应3
根据字典进行转换,但是将其编码为1
。
描述中有错误吗?功能哈希如何工作?
文本:
John likes to watch movies. Mary likes too. John also likes to watch football games.
可以使用字典进行转换
{"John": 1, "likes": 2, "to": 3, "watch": 4, "movies": 5, "also": 6, "football": 7, "games": 8, "Mary": 9, "too": 10}
到矩阵
[[1 2 1 1 1 0 0 0 1 1] [1 1 1 1 0 1 1 1 0 0]]