Case study
Python makes extensive use of iterators and iterable collections. This underlying aspect appears in many places. Each for
statement makes implicit use of this. When we use functional programming techniques, such as generator expressions, and the map()
, filter()
, and reduce()
functions, we're exploiting iterators.
Python has an itertools
module full of additional iterator-based design patterns. This is worthy of study because it provides many examples of common operations that are readily available using built-in constructs.
We can apply these concepts in a number of places in our case study:
- Partitioning all the original samples into testing and training subsets.
- Testing a particular k and distance hyperparameter set by classifying all the test cases.
- The k-nearest neighbors (k-NN) algorithm itself and how it locates the k nearest neighbors from all the training samples. ...