Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [k-nn]

K-Nearest Neighbor (K-NN) is a classification algorithm that determines the label of some data point based on the most common label of the closest k other points.

Filter by
Sorted by
Tagged with
1 vote
0 answers
33 views

Does f1 score evaluate only the model or does it also enable us to observe and evaluate the data?

I have a dataset. This dataset consists of the data that the actual picture that needs to be drawn, that is, the 100-point graded paper, and the similarity between 100 and 0 points graded pictures ...
doqukan's user avatar
  • 11
0 votes
1 answer
21 views

Does performing k-NN on the centroids of clusters obtained from k-means make sense mathematically?

While playing around with some text embeddings, I used k-means clustering to get 4 clusters. I also have the labels for these embeddings, and I may simply use k-NN to classify new embeddings. However, ...
Moltres's user avatar
  • 103
1 vote
0 answers
70 views

Using UMAP on text data (euclidean distance on jaccard distance matrix)

I am checking the capabilities of the UMAP dimensionality reduction algorithm, I am not sure whether the approach I am using is valid and does not violate the rules/limitations of this algorithm. ...
rkabuk's user avatar
  • 21
0 votes
0 answers
14 views

What does a correlation between predictions of training data and predictions of validation data tell me?

In my Machine Learning intro course I made several scatter plots of predictions for the california housing data set. Here is the most complete of them (created by a pipe using a sklearn StandardScaler ...
S3k's user avatar
  • 1
1 vote
1 answer
46 views

Evaluate KNN in recommender system

I'm a newbie in machine learning and I'm currently have a project about building a collaborative filtering (user-based) product recommendation system using KNN. My data has no label, it consists of ...
Arkadian's user avatar
0 votes
0 answers
15 views

Best value of K when using K-Nearest Neighbors with Spectral Clustering

I'm using scikit-learn's SpectralClustering class, which has the option of building its affinity matrix using a K-Nearest Neighbors algorithm. Is there any way to ...
Hippopotoman's user avatar
0 votes
1 answer
11 views

How set binary random projection to features, num_samples for X-train, x_test, y_train to match knn distances L dimension

Binary Random Projection of Features, Samples Creating a binary random projection that will be used in a kNN Hanning function for hamming distances on nearest neighbors that will be processed by ...
Data Science Analytics Manager's user avatar
0 votes
0 answers
8 views

Discuss kNN, test/train, random projection, unit vector, vectored matrix, hamming distance, stft, Y=(aAX1:M)

Suggestion Investigation Looking for suggestions or guide for how to setup a clean approach and discussion on how to apply a python suggested way to solve this challenge Looking for suggestions or ...
Data Science Analytics Manager's user avatar
1 vote
1 answer
69 views

Packages for Density Estimation using K-Nearest Neighbor

I would like to have suggestions for packages that provide K-Nearest Neighbor density estimator, I've already searched the web (to not bother you guys with my question :) ), but most results were ...
Neyo Goldsmith's user avatar
0 votes
0 answers
17 views

Upsell and cross sell opportunity via recommender system

I have a million residential customers across the United States who purchase my service. Some buy a single service, some buy multiple services. I want to identify similar customers who are alike in ...
Sean Ryan's user avatar
0 votes
1 answer
152 views

Python SK-Learn KNN Imputer ( "ValueError: could not convert string to float: )

I have data with missing values. All columns are integer, except for a column that has missing values. These missing values, were set with a "?" which was converted to NaN using the Numpy ...
Palu's user avatar
  • 103
0 votes
0 answers
40 views

Finding Accuracy, Recall, Precision, and F1 from Matlab Confusion Matrix

I'm working on a project to find the highest accuracy between KNN and a Decision Tree for Classification using Matlab. How to calculate the Accuracy, Recall, Precision, and F1 from the output below? ...
willow's user avatar
  • 1
0 votes
0 answers
19 views

Top hundred nearest neighbour

I have a dataframe with a column called pharmacy number and other columns corresponding to each pharmacy number, there many rows and each row corresponds to pharmacy number. I want to create a ...
Sanket Maiti's user avatar
0 votes
0 answers
21 views

Semantic search with pretrained BERT models giving irrelevant results with high similarity

I'm trying to create a Semantic search system and have experimented with multiple pretrained models from the SentenceTransformers library: LaBSE, MS-MARCO etc. The system is working well in returning ...
Aftaab Zia's user avatar
0 votes
0 answers
132 views

K nearest neighbor with varying feature length

I'm trying to build a tool which predicts the elemental composition of some light source using its emission spectrum with the k nearest neighbor algorithm (I'm using the KNeighborsClassifier from ...
oodani's user avatar
  • 1
0 votes
0 answers
23 views

Rejoin Categorical Labels After Running Cluster Analysis

I'm working on creating a kNN & PCA analysis using 6 variables associated with different schools. The first step is to drop the school name label column which the first column, so only numeric ...
katrone's user avatar
1 vote
0 answers
29 views

How to implement Ant Lion Optimization (ALO) feature selection for KNN Classification Problems?

I have been assigned for a project related to text data classification, i have preprocess and vectorized the data with TF-IDF. For feature selection i am using pyMetahueristic library to implement ALO ...
Physics69's user avatar
0 votes
2 answers
853 views

KNN Accuracy training

After I developed my model using KNN I get the following accuracy: Train Accuracy :: 1 Test Accuracy :: 0.24 What is the accuracy of my model?
user150859's user avatar
3 votes
0 answers
74 views

Where can I find implementation of the various improvements of K-nearest neighbors (KNN)?

I have been facing some challenges where traditional KNN algorithm perform well. I'd like to explore more advanced knn solutions. While researching possible solutions, I came across a paper titled <...
Lucas Morin's user avatar
  • 2,234
0 votes
1 answer
75 views

How to add query filter to the Nearest Neighbors algorithm?

I have Nearest Neighbors model, built with sklearn sklearn.neighbors.NearestNeighbors, which I use to make content based recommendations. Sometimes I need to ...
Egor's user avatar
  • 101
0 votes
0 answers
20 views

Evaluation parameter in knn

I am using KNN for a regression task It's like that: 1- I normalized the data 2- I calculated the distance of the new data with the previous data (Euclidean distance) 3 - I choose k nearest neighbors ...
Ho3ein H K's user avatar
0 votes
1 answer
19 views

estimating coordinate correction

I'm working with 3d coordinate data (x,y,z), however I know that the z coordinate is systematically wrong and the error of z is dependant on both x and y. I however do have some data where I know the ...
drulludanni's user avatar
0 votes
1 answer
35 views

Get multiple predictions from a knn model

I want to my code to return multiple(5) predictions from my trained knn model. I've tried using predict_proba() but it just returns the probabilities and not the names Here is my code: ...
Genevieve's user avatar
3 votes
1 answer
2k views

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

I am a beginner doing my first ML project. I am doing a binary supervised classification on an unbalanced dataset and want to use the ROC curve as a performance metric of my models. I am using ...
Ludger's user avatar
  • 33
1 vote
0 answers
8 views

Precision and AUROC for which class values

I am a newbie in reading research paper and implementing it by myself. I went through the paper Breast Cancer Survival Prediction from Imbalanced Dataset with Machine Learning Algorithms. Can anyone ...
Encipher's user avatar
  • 361
1 vote
0 answers
429 views

KNN using Mahalanobis distance gives low score [closed]

I want to get average score of all possible K but the average accuracy I'm getting is much lower than what's given to me. ...
Ali77pour AHmadi's user avatar
0 votes
0 answers
25 views

What does "n∼1/d" mean?

Or rather, what is the "~" notation mean? For reference, I'm trying to understand this section from a sci-kit learn documentation page.
Maxim's user avatar
  • 101
1 vote
0 answers
49 views

Near duplicate detection algorithms for a near real time system

I'm looking for near-duplicate detection algorithms or techniques for a near-real-time system with large document volumes. I know LSH is the most popular industry-standard algorithm for syntactical ...
Murali Mopuru's user avatar
1 vote
1 answer
35 views

Algorithm for optimally removing items for improving a nearest neighbors embedding

Let's say that you embed a collection of items belonging to multiple classes into a multidimensional space for predicting unseen future items by K Nearest Neighbors. And in a particular scenario it is ...
matanox's user avatar
  • 131
0 votes
0 answers
1k views

How solved "ValueError: y should be a 1d array, got an array of shape () instead."?

...
Asma Tolihan's user avatar
0 votes
1 answer
528 views

What does a leaf size of 1 in K-neighbors regression mean?

I am doing hyperparameter tuning + cross validation and I'm constantly getting that the optimal size of the leaf should be 1. Should I worry? Is this a sign of overfitting?
Caterina's user avatar
  • 119
0 votes
1 answer
452 views

parallel work on KNN in python

I have a question, related to parallel work on python How I can use Processers =1,2,3... on k nearest neighbor algorithm when K=1, 2, 3,.. to find the change in time spent, speedup, and efficiency. ...
Salman Al-haddad's user avatar
2 votes
1 answer
213 views

ROC_AUC score is higher before tuning n _neighbors for KNN

This is for multiclass classification. Before tuning the n_neighbors for KNN, these were the results: ...
user2807477's user avatar
6 votes
3 answers
3k views

Best way to vectorise names and addresses for similarity searching?

I have a large dataset of around 9 million people with names and addresses. Given quirks of the process used to get the data it is highly likely that a person is in the dataset more than once, with ...
Sandy Lee's user avatar
  • 247
1 vote
0 answers
19 views

Nearest neighbor face recognition in eigenspace when using dot product of test set with eigenvectors does not match the performance when using sklearn

I am trying to perform Face recognition using PCA (eigenfaces). I have a set of N training images (of dimensions M=wxh), which I have pre-processed into a vertical ...
zr0gravity7's user avatar
1 vote
1 answer
49 views

Recommend different product using NearestNeighbour

I am working on creating a recommendation system which suggests product for the user, based on the other user's data from the same region. My dataset is as below ...
srinath's user avatar
  • 113
0 votes
1 answer
982 views

How does Scikit learn KNN handle categorical input variables?

In some articles, it's said knn uses hamming distance for one-hot encoded categorical variables. Does the scikit learn implementation of knn follow the same way. Also are there any other ways to ...
insomniac's user avatar
1 vote
3 answers
356 views

Need for cross-validation in KNN

I read that we need cross-validation in KNN algorithm as the K value that we have found from the TRAIN-TEST of KNN might not be generalizable on unseen data. The logic given was that, the TEST data ...
Bhartendu Kumar's user avatar
1 vote
1 answer
48 views

Why feature normalization can increase the biometric recognition accuracy?

In a biometric recognition system, I have noticed that normalizing the extracted wavelet features leads to increasing the recognition accuracy. The classifier used is K-nearest neighbor (KNN), and ...
Noha's user avatar
  • 111
2 votes
2 answers
1k views

Massive difference in accuracy of KNN depending on random_state

pardon the noob question but I am baffled by the following behavior. My model has MASSIVELY different results based on the random seed. I want to train a KNN classifier on the famous Kaggle Titanic ...
Esoog's user avatar
  • 123
3 votes
1 answer
32 views

Trim left tail of music in audio file

I have audio files, most of them start with the same music, and then a conversation begins. I want to trim the part of the music (which can be varied in length). I have no labels, I can transcribe the ...
David Harar's user avatar
0 votes
2 answers
54 views

How can I know that this works and is correctly done?

Problem: This seems to be very wrong, cannot pinpoint what I am missing or doing wrong here. Should all rows for each column be Normalized? How? I am working on some small thing, and want to get a ...
John Smith's user avatar
0 votes
1 answer
503 views

Categorical Variables (Y or N) in KNN Classification?

Practicing KNN and I just had a query about pre-processing, as I understand KNN doesn't work with categorical features. I've read into one-hot-encoding (dummy variables) which I suppose if I applied ...
TheDataPanda's user avatar
0 votes
0 answers
47 views

Balanced target variable in KNN classification

In many places, I have seen it only mentioned that predict the label of the query point as the label with more than half of the labels of it's K nearest neighbours. However, I don't see it mentioned ...
Hithesh Kk's user avatar
0 votes
1 answer
759 views

KNN error: could not find function "train" [closed]

this is my KNN code: ...
Inuraghe's user avatar
  • 481
0 votes
0 answers
53 views

KNN model with two classes in the train dataset and three in classes in test

I have a dataset like this: ...
Inuraghe's user avatar
  • 481
2 votes
2 answers
250 views

How can I define the optimal value of k in the KNN model?

This is my script in Rstudio: ...
Inuraghe's user avatar
  • 481
1 vote
1 answer
39 views

How different classifiers would perform on a particular data set

I am reading through and learning how different ML methods work on different types of data, but I have faced a data set that I am not sure how ML methods, such as decision tree, Naive Bayes, and KNN, ...
user9532692's user avatar
-1 votes
3 answers
1k views

How to determine the number of K in KNN

I have a question about how many k values (k=1 or k=5 or k=50) to choose in the following two scenarios. I initially thought choosing k=5 will be the right choice of k for both because it will ...
user9532692's user avatar
3 votes
1 answer
308 views

New classification in Machine Learning KNN model

This is my example of KNN model (I write it using R): ...
Inuraghe's user avatar
  • 481