507a5ef9b0285e118fcbc3f8d9995b8ed37a69e9,mla/knn.py,KNN,_predict_x,#KNN#Any#,35
Before Change
// Get labels of the k-nn and compute the most common one.
neighbors_labels = [label for (_, label) in neighbors[:self.k]]
most_common_label = Counter(neighbors_labels).most_common(1)[0][0]
return most_common_label
After Change
Predict the label of a single instance x.
// compute distances between x and all examples in the training set.
distances = (self.distance_func(x, example) for example in self.X)
// Sort all examples by their distance to x and keep their target value.
neighbors = sorted(((dist, target)
for (dist, target) in zip(distances, self.y)),
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 3
Instances Project Name: rushter/MLAlgorithms
Commit Name: 507a5ef9b0285e118fcbc3f8d9995b8ed37a69e9
Time: 2016-11-18
Author: nh.nicolas.hug@gmail.com
File Name: mla/knn.py
Class Name: KNN
Method Name: _predict_x
Project Name: facebookresearch/pytext
Commit Name: 1207689fa1e6ff2d321ccc182be13825b4e2575e
Time: 2019-07-12
Author: mikaell@fb.com
File Name: pytext/models/embeddings/word_embedding.py
Class Name: WordEmbedding
Method Name: from_config
Project Name: stanfordnlp/stanza
Commit Name: b89d94957773d49908829272f8c1ac98c6031243
Time: 2018-10-22
Author: zyh@stanford.edu
File Name: models/lemma/data.py
Class Name: DataLoader
Method Name: init_vocab