1、导入包
2、导入数据库
3、建立模型,寻找最近邻
model = graphlab.nearest_neighbors.create(wiki, label='name', features=['word_count'], method='brute_force', distance='euclidean')
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进行对比,找出最近邻。