11 votes
Accepted

Learning with Positive labels only

The topic you are interest in is called "PU learning" or "positive and unlabeled learning". You can start by having a look into survey literature.
Graph4Me Consultant's user avatar
10 votes
Accepted

How to save a knn model?

...
Nayana Madhu's user avatar
8 votes
Accepted

Sklearn: unsupervised knn vs k-means

Unsupervised k-NN Unlike k-means, the unsupervised k-nn does not associate a label to instances. All it can do is tell you what instances in your training data is k-nearest to the point you are ...
JahKnows's user avatar
  • 8,876
8 votes
Accepted

Coordinate System's influence on $L$ distances (Manhattan and Euclidean)

For example, consider the green line. What is its length? In $L_2$, the answer is $1$, in $L_1$, the answer is $1$ as well. Now, for the same line, let's rotate it $45^\circ$ counterclockwise. What ...
Siong Thye Goh's user avatar
7 votes

What is difference between Nearest Neighbor and KNN?

Not really sure about it, but KNN means K-Nearest Neighbors to me, so both are the same. The K just corresponds to the number of nearest neighbours you take into account when classifying. Maybe what ...
Ubikuity's user avatar
  • 626
6 votes
Accepted

Is it sensible to use the ROC curve with an KNN model? And if so why?

ROC curves (and the AUC metric) are used for evaluating model performance on a classification task. If you use KNN for classifying, then you can evaluate your model on it. Probability, in the context ...
Stefan Popov's user avatar
5 votes
Accepted

How Does Weighted KNN Work?

We can view nearest neighbor as a voting process where we consult our $k$ nearest neighbor. We give the $i$-th data point a voting weight $w_i$. In your example, each data point in class $A$ has ...
Siong Thye Goh's user avatar
5 votes

Is Annoy a machine learning algorithm to find nearest neighbor ? and is it similar to K nearest neighbor algorithm?

Don't have enough reputation to comment to a resource, so answering this myself. About Annoy Annoy is a library being used here for finding approximate nearest neighbours, approximate being the key ...
Bhavul's user avatar
  • 151
5 votes

When using KNeighborsClassifier, what is the motivation of using weights="distance"?

weights = 'distance' is in contrast to the default which is weights = 'uniform'. When weights are uniform, a simple majority ...
Brian Spiering's user avatar
4 votes
Accepted

How does sklearn KNeighborsClassifier compute class probabilites?

The class probabilities are the normalized weighted average of indicators for the k-nearest classes, weighted by the inverse distance. For example: Say we have 6 classes, and the 5 nearest examples ...
Imran's user avatar
  • 2,381
4 votes
Accepted

How does KNN work if there are duplicates?

Your reasoning is correct - you should consider duplicate points as separate. You can see that this must be the case in several ways: Introduction of small random noise to the data should not affect ...
KT.'s user avatar
  • 2,121
4 votes
Accepted

Is there any way of ordering/sorting vectors?

If I understand your question correctly, you're looking for something that another (beyond KD-trees) standard space partitioning algorithm does. This one is called BSP-trees (for Binary Space ...
mapto's user avatar
  • 744
4 votes
Accepted

Is K-NN applicable for binary variables?

Yes, you just have to find a suitable distance metric, instead of using the default Euclidean distance. Euclidean distance will work, but it loses a lot of its positive points when used on a non-...
Mephy's user avatar
  • 937
4 votes
Accepted

Evaluation metrics for Decision Tree regressor and KNN regressor

Generally when ever we are trying to compare between models and to choose the best one, we go for other metrics like AIC, BIC, AUC(this is not applicable as it is used for classification algorithm) ...
Toros91's user avatar
  • 2,392
4 votes
Accepted

Why does the overfitting decreases if we choose K to be large in K-nearest neighbors?

Overfitting is "The production of an analysis which corresponds too closely or exactly to a particular set of data, and may therefore fail to fit additional data or predict future observations ...
A Co's user avatar
  • 335
4 votes

What is difference between Nearest Neighbor and KNN?

Scikit wrote in his documantation: sklearn.neighbors provides functionality for unsupervised and supervised neighbors-based learning methods. Unsupervised nearest neighbors is the foundation of many ...
manpreet singh's user avatar
3 votes

How to calculate the silhouette coefficient?

a(i) : the average distance between 'i' and all other data within the same cluster (source) b(i) : the lowest average distance of 'i' to all points in any other cluster, of which 'i' is not a member ...
mausamsion's user avatar
  • 1,282
3 votes
Accepted

Knn and euclidean distance

You can think of examples as vectors in $\mathbb{R}^p$, where $p$ is the number of features. Two examples will be very similar if the distance between them is close to $0$ (in the extreme case, if two ...
David Masip's user avatar
  • 6,051
3 votes
Accepted

sklearn.neighbors.NearestNeighbors - knn for unsupervised learning?

The unsupervised version simply implements different algorithms to find the nearest neighbor(s) for each sample. The kNN algorithm consists of two steps: Compute and store the k nearest neighbors ...
oW_'s user avatar
  • 6,347
3 votes
Accepted

Why do I not get 100% Accuracy with KNN with $K=1$

In your training set (X_2,y), there are some samples with the same input features X_2 but different labels y. For example, the 73rd and 147th samples, which are labelled into class 0 and 1, ...
Nga Dao's user avatar
  • 185
3 votes

K-Nearest Neighbours algorithm explanation needed

K Nearest Neighbors is a Classification Algorithm. Just as with every classification algorithm is important that the algorithm doesn't "remember" the answers and that the answer it gets can be ...
Juan Esteban de la Calle's user avatar
3 votes

How to save a knn model?

Importing the library from sklearn.externals import joblib Saving your model after fitting the parameters ...
Blenz's user avatar
  • 2,074
3 votes

Is the distance in Nearest Neighbors a good measure of similarity?

This is counter-intuitive, because one would expect [0,2,0,0] to be more similar to [0,1,0,0] than [0,1,1,0]. No this is expected, since the two points are exactly at the same distance in the ...
Erwan's user avatar
  • 25.3k
3 votes
Accepted

Calculating distance between data points when there are more than 3 features in KNN algorithm

No, you can definitely search for k-NN with more than 2-dimension data. Here is an example based on sklearn: ...
etiennedm's user avatar
  • 1,395
3 votes
Accepted

Optimal selection of k in K-NN

Your idea isn't wrong, however in k-NN there always might be a case where you have the same number of votes for 2 or more classes (e.g. you have $k=6$ and you have 3 samples of one class vs 3 of ...
Djib2011's user avatar
  • 7,978
3 votes

Optimal selection of k in K-NN

As I was playing with this problem, Djib just wrote an answer which is certainly better than whatever I could have come up with. To illustrate Djib's point, here is a small demonstration that as soon ...
Erwan's user avatar
  • 25.3k
2 votes

Why is cross-validation score so low?

I know this question has been here for two years, however, I was having the same problem when using cross_val_score on my data and I ended up here. The results ...
yzz's user avatar
  • 21
2 votes
Accepted

Why is cross-validation score so low?

In your random forest, this is due to the fact that your final model is overfitting. Sklearn's GridSearchCV has a default argument ...
David Masip's user avatar
  • 6,051
2 votes

sklearn.neighbors.NearestNeighbors - knn for unsupervised learning?

The confusion comes from the way Sklearn designed their code. Short answer The "unsupervised" version you mention is not a K-Nearest Neighbour algorithm (which is implemented here). In its ...
Valentin Calomme's user avatar
2 votes
Accepted

scalable tools to build kNN graph over sparse data

I think what you might be looking for is, L2Knng: Fast Exact K-Nearest Neighbor Graph Construction with L2-Norm Pruning They have multiple runtime options specifically for different kinds of ...
Sujay_K's user avatar
  • 111

Only top scored, non community-wiki answers of a minimum length are eligible