【机器学习课程-华盛顿大学】:4 聚类和检索 4.2 实战:wiki文章特征选择和相似文章搜索

1、导入包

2、导入数据库

3、建立模型,寻找最近邻

model = graphlab.nearest_neighbors.create(wiki, label='name', features=['word_count'],
                                          method='brute_force', distance='euclidean')

https://turi.com/products/create/docs/generated/graphlab.nearest_neighbors.create.html#graphlab.nearest_neighbors.create

method:选择brute_force:暴力破解,硬算。依次算法每一个与当前点的距离,选出前k个。

                还有ball_tree, lsh。

distance:euclidean欧氏距离。还有:‘euclidean’, ‘squared_euclidean’, ‘manhattan’, ‘levenshtein’, ‘jaccard’, ‘weighted_jaccard’, ‘cosine’,

                   ‘dot_product’ (deprecated), or ‘transformed_dot_product’.

4、使用tf-idf作为特征,与普通的word_counts进行对比,找出最近邻。

猜你喜欢

转载自blog.csdn.net/weixin_41770169/article/details/80694367