{'fraction_non_alphanumeric': 0.019943019943019943, 'fraction_numerical': 0.0014245014245014246, 'mean_word_length': 5.030042918454936, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
An approach to enhance KNN based on data clustering using K-medoid

K-nearest-neighbor (KNN) is one of the state-of-the-art machine learning algorithms used for classification and regression tasks. In addition to being simple to understand, KNN is also versatile, spanning various applications. Despite its simplicity, it is considered a lazy classifier that does not generate a trained model but stores or memorizes training examples instead. Consequently, the prediction process using KNN becomes costly in resources and time, especially when the dataset becomes large. Also, there is no general way to choose the best distance metric during the prediction. This paper proposes a new algorithm called K-nearest Medoid KNN (KMKNN) which improves the performance of KNN in terms of prediction performance and time efficiency without a major effect on its result accuracy. The core idea of the proposed KMKNN is to cluster the dataset before the prediction to limit the distance measures to those data instances that belong to the nearest cluster of the new data. KMKNN when compared to the traditional KNN and other similar extended versions of KNN, achieves a noticeable improvement on 15 benchmark datasets. The importance of this work is primarily in large datasets or when the distance measure used is computationally expensive, which is common in the computer vision and pattern recognition domains.