Dealing with near duplicates of the same person in K Nearest Neighbor algorithm For context, I am a beginner and this is my first time attempting to implement a machine-learning algorithm. This is for school. I am attempting to predict whether a 100-meter dash athlete wins a medal or not from inputs: weight, height, and age. There are athletes who appear more than once. For example, Usain Bolt appears 3 times with the same height and weight, and at ages: 21, 25, and 29. Only age changes with athletes appearing more than once. I have two concerns.

*

*This creates line segments that can heavily influence data near them, but the
points correspond to the same person. Essentially, multiple-time winners
attributes would be given additional weight. I am worried that this would veer the
algorithm to predict a medal based on whether a data point is someone who is already
Olympic champion or is most similar to them, as opposed to predicting based on
if there exists some inherent combination of attributes that would give an athlete
advantage.


*When splitting the data into training and testing components, there is a possibility
of getting many duplicate persons, especially if I were to apply this to other
sports. This could artificially boost precision and recall metrics.
How do I address these issues? I considered removing the duplicate athletes but they have varying ages, and some have not won a medal at every age, so I am not sure what the proper course of action would be.
 A: Your intuition is correct, this "duplicated items" phenomenon is indeed problematic. I would strongly advice against removing this data though.
To start with the easy part - the test-train split/performance assessment: In this case we will stratify based on athlete ID, i.e. we cannot have the same athlete appear in both the training and the test set. Standard stratified sampling principles apply. That way, our learner cannot "memorise" that a particular athlete is successful (or unsuccessful).
Continuing to the more complicated part - clustering these data: In this case is reasonable to assume we have an underlying cluster hierarchy based on athlete ID. In general, constrained clustering is reasonably niche domain but the basic idea being that we have a series of must-have and cannot-have link between our pairs. In this case, instances from the same athlete ID would have some must-have links. There is some even more specialised work for cases with partially known hierarchies (e.g. see Creating a Cluster Hierarchy under Constraints of a Partially Known Hierarchy (2008) by Bade & Nürnberger) if one wants to go down that rabbit-hole.
Final comment: $k$-NN regression/classification does not really account of data hierarchies. Using a model that explicitly accounts for them (e.g. a generalised linear mixed-effects model where athlete ID and age are used to define the random-effects strucure) might be more appropriate. In any case, the stratified train-test split should be done as it is easy to implement and safe-guard us from data leakage.
