Skip to main content

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
3 votes
2 answers
919 views

Which model is better for incremental learning?

I'm trying to implement face recognition. I'm planning to use some model (like DeepFace) to extract discriminative features and then use a classifier to recognize the faces. I'm confused as to which ...
Nagabhushan S N's user avatar
1 vote
2 answers
148 views

Identify the parameter causing the anomaly in a multivariate dataset

I have a payment transaction dataset with a large number of predictor variables. I am trying to build a model for anomaly detection and I have evaluated various algorithms/approaches for the same like ...
Dhaval Simaria's user avatar
1 vote
1 answer
2k views

Could you help me to resolve this exercise of K-NN?

I am just a young learner in Data Science. Could you help me to resolve this exercise of K-NN? Ex.1 The table below provides a training data set containing six observations, three predictors, and ...
mrbangybang's user avatar
0 votes
2 answers
2k views

Leave - one - out - Cross Validation KNN R

I have a dataset and I divided it into test data and train data. Can anyone suggest how to perform LOOCV for KNN regression? Is there any library? ...
t.wangd's user avatar
  • 11
3 votes
3 answers
104 views

Machine learning on classifying speech

So, I have 9k of 1 second wav files of a person speaking. These are labeled by whether the person speaking is wearing a face mask or not. I am supposed to come up with a machine learning model to ...
Cyber Gh's user avatar
0 votes
1 answer
343 views

Getting a best k in KNN Algorithm

So, i was learning the KNN Algorithm and there i learnt cross Validation to find a optimal value of k.Now i want to apply grid search to get the optimal value.I found an answer on stack overflow where ...
teddcp's user avatar
  • 165
1 vote
0 answers
326 views

Use KNN as a clustering method

I am trying to use KNN as an Unsupervised clustering. Yes, I know KNN is supposed to be a used as a classifier, using I was given a task to use it as a clustering model). I am using this link from ...
justadev's user avatar
  • 111
0 votes
1 answer
97 views

K-Nearest neighbor in transformed space

When googling "weighted KNN", the results appear to be focused on weighting the nearest neighbor values after those neighbors have been determined. I'm looking for something that assigns a level of ...
SuperCodeBrah's user avatar
0 votes
1 answer
3k views

How to consider categorical variables in distance based algorithms like KNN or SVM?

For example lets say I have a dataset with independent features age, gender, name, and income. While my dependent variable is load approval status. If I want to use KNN or SVM, do I need to convert ...
Rohan's user avatar
  • 1
1 vote
0 answers
50 views

Can someone provide me the code of the MiLoF(Memory Efficient Local Outlier Factor) algorithm?

I have to code the MiLoF algorithm for detecting outliers in an unsupervised manner using non-stationary data. I am attaching the paper which explains the algorithm here. However, there are many ...
SAGNIK GHOSAL's user avatar
1 vote
0 answers
148 views

Combine features in Machine Learning KNN

I'm trying to build a simple book recommendation system, where I don't have any kind of ratings (no comments, no likes, no 1-5 stars, ...). The information I can use is the following: Book metadata ...
Sara Kerrigan's user avatar
0 votes
3 answers
3k views

K-Nearest Neighbor Classifier Best K Value

I created a KNeighborsClassifier for my dataset adjusting the k hyper-parameter (the number of neighbors) in a for loop. The k ...
Tahmid's user avatar
  • 61
3 votes
3 answers
246 views

Why does my KNeighborsClassifier graph look like this?

I'm new to data science/ml and working on using the sklearn libraries to classify data. I'm currently using the KNeighborsClassifier with 5 fold cross validation whilst tweaking the k value but its ...
Tahmid's user avatar
  • 61
6 votes
1 answer
360 views

How to add data points to a trained KNN

I have a trained KNN, I created with https://github.com/kevinzakka/blog-code/blob/master/knn/knn.py I want to add more data points to the KNN but I am on a raspberry pi so limited by RAM and ...
ohyesyoucan's user avatar
1 vote
1 answer
81 views

Recommendations based on other products seen

I am trying to develop a basic book recommender system to get in touch with the field and start learning methods and how to prepare the data. The Dataframe I am using is pretty plain, it has the ...
user avatar
1 vote
1 answer
2k views

50% accuracy on multiclass classification

I am trying to do a multiclass classification on a significant amount of output labels (1000). I built a model using KNN. The accuracy given by ...
onelostdude's user avatar
1 vote
1 answer
38 views

Generalised data science approach to astronomical catalogue cross-match

I'm interested in performing a cross-match between two source catalogues in an astronomical context. I'll try and explain the context simply. A truth catalogue of sources (each with some position, ...
ska_james's user avatar
0 votes
1 answer
213 views

When using KNN, how do I know which order of the Minkowski distance to use?

I am learning about KNN and ML in general. I know that KNN usually uses second order Minkowski distance (Eucledian Distance), but I assume it cal also use other orders. But what is the benefit to ...
P_Andre's user avatar
  • 101
4 votes
2 answers
173 views

find most dense neighborhood of points in high dimensional space

I'm working on a project where I have many high-dimensional points and I want to find the most dense neighborhood of them. Ideally, out of my ~500 points that are each a 4x300 matrix (300 ms time ...
markagrios's user avatar
1 vote
1 answer
64 views

How are images (roughly) clustered when using KNN

When classifying data by KNN, the classes are calculated by using the distance between datapoints. For example, the case of real estate, where the x-axis is the price and the y-axis the size of real ...
Jane Mänd's user avatar
1 vote
0 answers
19 views

euclidean distance between true value and estimated value as input for knn [closed]

If we apply knn on euclidean distance between true value and estimated value will the results be better in case of data classification?
Neetu kumari's user avatar
1 vote
1 answer
46 views

How can I compare my regressors?

I am trying to build a regressor for a dataset which gives info about students' school performance and the probability of getting admitted in the University of their choice. The first 5 observations ...
batman's user avatar
  • 149
2 votes
1 answer
161 views

KNN custom transformer shows same accuracy for every k i set

I built custom trasformer for KNN and i can't figure why my k-number, when i set it, always shows same accuracy... ...
pf_man's user avatar
  • 33
2 votes
2 answers
1k views

KNN with mixed data (feature set)

I have a dataset where the feature set consists of hour of the day (between 0 to 23), day of the week (Monday to Sunday), number of shops (a positive integer) and road category (0 to 8 on an ordinal ...
Debjit Bhowmick's user avatar
1 vote
1 answer
44 views

Which kNN model to chose?

I am trying to tune the "n_neighbors" for a kNN model andI have the following problem : Based on the mean cross validation score the optimal kNN model should be the one with 10 neighbors. On the ...
batman's user avatar
  • 149
1 vote
1 answer
3k views

Does this line in Python indicate that KNN is weighted?

Does this line in Python indicate that KNN is weighted? clf = KNeighborsClassifier(n_neighbors=5, metric='euclidean', weights='distance') Are the weights the ...
Mona's user avatar
  • 19
0 votes
0 answers
78 views

Combining several Multi-Output-Models into a single Multi-Output-Model

I'm trying to create a k-Nearest-Neighbor based model of 76-dimensional input data $I$ and 44-dimensional output data $O$. Through domain knowledge I know that only certain input dimensions are ...
twes3's user avatar
  • 1
1 vote
1 answer
60 views

Converting Text Entries into values for machine learning - KNN

Consider the following dataset. ...
Peachman1997's user avatar
1 vote
1 answer
94 views

Maybe wrong values for precision and recall

I'm trying to do some data mining with RapidMiner studio. I've applied the K-nearest neighbor algorithm with different values of K. As I expected, accuracy increase and after K=5, it decrease. But I ...
Lorenzoi's user avatar
0 votes
0 answers
1k views

Operands Could not be Broadcast with Shapes (19,)(0,)

I have googled and read something similar to the problem I have but I do not seem to know how to fix the error I got from this particular code: ...
Mr Prof's user avatar
  • 171
1 vote
1 answer
88 views

Making Sense of this Error Message

I am using a book and a video to learn how to use KNN method to classify movies according to their genres.This is my code: ...
Mr Prof's user avatar
  • 171
1 vote
1 answer
3k views

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

I was researching about Google universal sentence encoding and i saw that it uses simple neighbor/Annoy to find the nearest vector for semantic-similarity search engine. This is the first time i'm ...
star's user avatar
  • 1,481
0 votes
1 answer
292 views

KNN scoring low compared to Logistic regression in MNIST challenge

KNN gives me a score of 0.76100 while it shows 94% accuracy for my training data (splitted with test_size =0.3) in my jupyter notebook while logistic regression gives me a score of 0.91485 with an ...
Isha's user avatar
  • 1
0 votes
2 answers
3k views

kNN vs Logistic Regression

Good day, I had this question set as optional homework and wanted to ask for some input. Suppose an individual was to take a data set, divide it in half into training and test data sets and then try ...
ʎpoqou's user avatar
  • 101
3 votes
2 answers
122 views

Varying the number of neighbors in nearest-neighbors regression

For nearest-neighbors regression, it is plausible to increase the number of neighbors used to predict $f(x)$ when there are many data points near $x$. What is a good algorithm for varying the number ...
Fortranner's user avatar
-1 votes
1 answer
57 views

Has this paper used weighted KNN or not?

Please tell me if you see this paper in the link below has used weighted KNN? because they have used weights as the training and testing samples and no formula written. They don't explain the ...
Mona's user avatar
  • 1
1 vote
1 answer
105 views

Ball Tree and Pseudometrics

The docs for sklearn.neighbors.DistanceMetric state that in order to be used within the BallTree, the distance must be a true metric (i.e. be non-negative, 0 ...
steam_engine's user avatar
6 votes
1 answer
282 views

What does big O mean in KNN optimal weights?

Wiki gives this definition of KNN In pattern recognition, the k-nearest neighbors algorithm (k-NN) is a non-parametric method used for classification and regression. In both cases, the input consists ...
JJJohn's user avatar
  • 623
2 votes
1 answer
660 views

values passed to user-defined distance function by KNeighborsClassifier is wrong

I have a data-set in which all features are binary and the class of each data-point is also binary. I am trying to use KNearestClassifier with a user-defined distance function as follows: ...
Ash's user avatar
  • 51
3 votes
3 answers
2k views

How to predict the value in KNN?

I am trying to build the KNN algorithm for IRIS dataset. First, I've computed the distance and stored it in 1d array. However, I am really struggling to build the prediction function. Therefore two ...
Daria's user avatar
  • 131
3 votes
1 answer
385 views

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

Let's train a Nearest Neighbor model with just one sample in it: In [48]: nn = NearestNeighbors().fit([[0, 1, 0, 0]]) So this one sample has just one significant ...
mac13k's user avatar
  • 133
1 vote
2 answers
126 views

Machine Learning algorithm for detecting anomalies in large sets of events

Let's start with the following hypothetical preconditions: There is traffic: normal and anomaly. Each traffic sample contains a list of events (of variable size) Events happen in order, the possible ...
Denis Rozimovschii's user avatar
2 votes
1 answer
96 views

Item-based recommender using K-NN

I'm trying to build an item-based recommender using k-nn. I have a list of items, all of which have some properties (features) in common. ...
Anto's user avatar
  • 21
1 vote
1 answer
77 views

What is the Value of X in KNN and Why? [duplicate]

I have a dataset of 25 instances these instances are divided into 2 classes Green Circles and Blue Squares data distributed as this graph I want to predict X's class based on "Likelihood Weighted ...
asmgx's user avatar
  • 549
1 vote
1 answer
804 views

logic behind weighted KNN

I am reading about KNN So I made another example to make things clearer In this example (Image attached) You can see there are in total 5 Greed Circles and 20 Blue Squares by standard KNN (k=3) , ...
asmgx's user avatar
  • 549
0 votes
1 answer
110 views

adding a supervising process during knn process

I am trying to improve my KNN regression process (I would like to use sklearn / python, but it doesn't matter).I would like to improve my results and to gain insight. Here is an example: I have data ...
lelorrain7's user avatar
1 vote
2 answers
78 views

Reverse engineering a distance metric from the output of a k-NN

Suppose that someone has trained a nearest-neighbor algorithm based on some unknown metric. I have a large dataset of $N$ observations and $P$ features. For each observation, I am given $K$ indices ...
Lepidopterist's user avatar
1 vote
1 answer
899 views

KNN RandomizedSearchCV typerror

While trying to study a binary classification problem with KNN and trying to tune the parameters of the model I'm getting a typerror that I quite don't understand. Is a parameter missing or something? ...
dungeon's user avatar
  • 175
6 votes
1 answer
289 views

Mapping of categorical features into binary indicator features

I am currently reading an introductory machine learning book by Daumé (ch. 03, p. 30) and when discussing the mapping of categorical features with "n" possible values into "n" binary indicator ...
Nilton Junior's user avatar
0 votes
1 answer
33 views

Does it make sense to use KNN to target ticket buyers for arts events?

I work for a medium-sized non-profit. We have a database with approximately 40,000 profiles of folks (mostly patrons). For each show a patron attends, we add an attribute that indicated that they're ...
jeepers mcface's user avatar