I am new in ML and I am a little confused here in the book "Building Machine Learning Systems with Python"
Since you may give different test data, how can you "index these at learning time"?
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It only takes a minute to sign up.Sign up to join this community
I think it refers to Spatial indexing (or Space partitioning) which are methods used to represent spatial data sets (such points clouds) in order to optimize spatial queries (i.e., optimize the time it takes to find the NN of new_example in your case). The use of kd-trees is one of these methods. The kd-tree can be computed during the learning step and the NN search time is reduced in the classification step.
I am not an expert in this but you can read a bit about it on Wikipedia and use the references listed there to go further: