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
0
votes
0answers
43 views

Estimate eps value in DBSCAN using KNN algorithm

I would like to estimate the best eps value for the DBSCAN algorithm on this dataset by following this set of rules: Set a minPts: 10 Compute the reachability distance of the 10-th nearest neighbour ...
0
votes
2answers
20 views

Impossible to increase model accuracy [closed]

I'm building binary classification models on my company's dataset. The problem I'm having is that I haven't been able to increase the accuracy of my models. I have trained, tuned, cross validated ...
0
votes
1answer
18 views

Combine K-nearest neighbor with categorical embedding

I've tried a few ways to do my multi-class classification. For categorical data, I used the embedding technique with Tensorflow, which moves the entity closer with its similarity. This technique ...
10
votes
1answer
564 views

Learning with Positive labels only

I have ~7 million rows of customer data (~500 sparse attributes) A million out of them have opted in to a new service. How do I use this signal to predict which of the remaining customers are likely ...
2
votes
2answers
23 views

Missing value Imputation in dataset

I have two separate files for Testing and Training. In the training data, I am dropping rows that contain too many missing values . But , In the test data , I cannot afford to drop the rows so I have ...
1
vote
1answer
26 views

Standardization on training and split data

I am confused on which of the following should be used for standardization: method 1: fit transforming training data and only transforming test data ...
0
votes
1answer
30 views

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

I am studying machine learning and I am focusing on K-nearest neighbors . I have understood the algorithm, but I have still a doubt, which is on how to choose the K for the number of neighbors. I ...
3
votes
0answers
42 views

Could my AI classifier be extended to categorical data? [closed]

I created a new AI classifier. Physics Based Classifier
1
vote
0answers
14 views

Redo preprocess on unknown row

I'm trying to write a script to get the most similar rows in a certain dataframe, based on a single row. Using scikit-learn The method I need is ...
2
votes
0answers
40 views

Classification and clustering of Time series data of temperature

I have a time series recorded data of temperature. This is what my data looks like: The change in data represents specific event or a class which I would like to detect when new incoming data. ...
0
votes
2answers
30 views

sklearn KNN fit throws out error : value too large for dtype('float64')

I have cleaned the data from nan values and infinite values, the only feature which has a large float is the column 8 (it's a sum) I have no Idea how to fix this last error, I tried all previous ...
4
votes
1answer
53 views

KNN Regression: Distance function and/or vector representation for datetime features

Context: Trying to forecast some sort of consumption value (e.g. water) using datetime features and exogenous variables (like temperature). Take some datetime features like week days (...
0
votes
1answer
86 views

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

I've been reading about K-nearest neighbors algorithm and want to clarify few things. If we have 2 features we could simply plot it on 2-d plane and calculate distance by using euclidean distance or ...
0
votes
1answer
31 views

Logic behind the Statement on Non-Parametric models

I am currently reading 'Mastering Machine Learning with scikit-learn', 2E, by Packt. In Lazy Learning and Non-Parametric models topic in Chapter 3- Classification and Regression with k-Nearest ...
2
votes
2answers
40 views

Using KNN to categorise inventory (physical stock items) - is it the best way?

I'm working on a machine learning problem involving inventory (i.e. physical retail stock), however through the cleaning (outlier removal) process some of the items (via their corresponding ...
2
votes
1answer
85 views

KNN Imputation utilize mean or mode?

In my current project, I am doing KNN imputation with K = 5 and I am using sklearn.impute.KNNImputer. I have a mix of continuous and nominal variables(encoded as 0/1 or ordinal ones that have been ...
0
votes
0answers
15 views

What is complexity of Nearest Neigbor graph calculation and why kd/ball_tree works slower than brute?

Consider sklearn NearestNeighbors: nbrs = NearestNeighbors(n_neighbors=2, algorithm=method ).fit(X) # 'ball_tree' distances, indices = nbrs.kneighbors(X) There ...
0
votes
1answer
35 views

Question about reshaping array size for KNN Classifiers

I keep trying to run a new set of data through my KNN Classifier but would recieve the message: ValueError: query data dimension must match training data dimension ...
0
votes
2answers
60 views

Need help understanding data leakage

I am a newbie to this stuff so I am sorry if my question is stupid~ I need help understanding what data leakage between X_train and X_test is and when exactly it happens. I am currently working on a ...
3
votes
2answers
41 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 ...
1
vote
2answers
36 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 ...
1
vote
1answer
85 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 ...
0
votes
2answers
196 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? ...
0
votes
0answers
99 views

KNN() and SVD() for recommender system

I come here cause I have some troubles (or is it normal ?) with the rating predicted by SVD() and KNNWithMeans(), I'm using the Sckit-Surprise library . Here is context : I have 637 069 rating I ...
2
votes
3answers
77 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 ...
0
votes
1answer
64 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 ...
1
vote
0answers
22 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 ...
0
votes
1answer
46 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 ...
0
votes
1answer
181 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 ...
0
votes
0answers
19 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 ...
0
votes
0answers
47 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 ...
0
votes
2answers
52 views

K-Nearest Neighbour Classifier Best K Value

I created a KNeighborsClassifier for my dataset adjusting the k hyper-parameter (the number of neighbours) in a for loop. The k value was between 1 and 20. The ...
3
votes
3answers
67 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 ...
6
votes
1answer
67 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 ...
1
vote
1answer
48 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 ...
0
votes
1answer
146 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 ...
0
votes
1answer
26 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, ...
0
votes
0answers
15 views

How to find top N neighbors of a datapoint in a cluster sorted in increasing order of distance from that point?

I am doing a clustering exercise and I am doing it using K-Means. After doing the clustering part, I have a dataframe that looks something like this : ...
0
votes
1answer
34 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 ...
3
votes
2answers
39 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 ...
1
vote
1answer
44 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 ...
1
vote
0answers
16 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?
1
vote
1answer
32 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 ...
2
votes
1answer
80 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... ...
2
votes
2answers
167 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 ...
1
vote
1answer
30 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 ...
0
votes
1answer
607 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 ...
0
votes
0answers
20 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 ...
1
vote
1answer
24 views

Converting Text Entries into values for machine learning - KNN

Consider the following dataset. ...
1
vote
1answer
45 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 ...