Introduction
The $k$-Nearest Neighbors (kNN) algorithm is a foundational technique in machine learning, valued for its simplicity and lack of a formal training phase. However, its performance is often hampered by a significant limitation: the assumption that all features or attributes are equally relevant to the classification task. In high-dimensional datasets containing redundant or noisy features, the accuracy of standard kNN can degrade rapidly.
Finding an optimal set of weights to balance these features is a daunting search problem. For a dataset with 17 attributes, even a restricted search space of five possible values per weight results in over 760 billion combinations ($5^{17}$). This paper introduces GA-WKNN, a hybrid system that leverages a Genetic Algorithm (GA) to navigate this search space and optimize weights for both attributes and neighbors.
Methodology: GA-WKNN
The proposed GA-WKNN system enhances the standard kNN framework by introducing two distinct types of weights:
- Attribute Weights ($w_a$): These weights scale the distance calculation between data points. By "stretching" or "shrinking" specific dimensions, the algorithm can effectively filter out noise or emphasize features with high predictive power.
- Neighbor Weights ($W_j$): These weights adjust the influence of individual neighbors during the voting process, typically giving closer neighbors more "voting power" than those further away.
The Genetic Algorithm Component
To optimize these weights, the authors utilize a Genetic Algorithm with several specific design choices:
- Real-Valued Encoding: Moving away from traditional binary strings, the system uses real-valued chromosomes (vectors of decimals between 0 and 1). This is more efficient for continuous optimization problems like weight tuning.
- Evolutionary Operators: The GA employs "crossover" to combine parent solutions and "creep"—a mutation operator that makes small, incremental adjustments to weights—to explore the search space locally.
- Fitness Functions: The researchers explored two methods for ranking solutions. While a simple count of misclassifications provides a baseline, it often results in a "flat" fitness landscape where many solutions appear identical. To solve this, they introduced Multiple Value Ranking.
Multiple Value Ranking
Multiple Value Ranking provides a smoother gradient for the GA to follow by using a cascaded tie-breaking method. If two weight sets produce the same number of misclassifications, the algorithm evaluates them based on the density and proximity of neighbors belonging to the same versus different classes.
Experimental Results
The GA-WKNN algorithm was evaluated against three datasets of varying complexity: the classic IRIS dataset, the forensic GLASS dataset, and a highly noisy BIOCRITERIA dataset from the Ohio EPA. In all cases, the hybrid approach outperformed the standard kNN benchmark.
| Dataset | Standard kNN Error | GA-WKNN (Best Ranking) |
|---|---|---|
| IRIS | 0.1000 | 0.0600 |
| GLASS | 0.4154 | 0.3785 |
| BIOCRITERIA | 0.6371 | 0.6198 |
The most significant insight from these results is the importance of the fitness gradient. By providing the GA with "hints" via Multiple Value Ranking, the system could continue to improve its internal model even when the total error count remained static, eventually leading to better generalization.
Conclusion
GA-WKNN demonstrates that a Genetic Algorithm can effectively solve the feature-weighting problem that plagues standard kNN. By evolving real-valued weights and utilizing sophisticated ranking functions, the system consistently improves classification accuracy across diverse datasets. Future work may involve evolving the value of $k$ itself or developing class-specific weight vectors to further refine the model's sensitivity.
Summary updated