.. _book_fig_chapter9_fig_rrlyrae_knn: K-neighbors Classification of photometry ---------------------------------------- Figure 9.7 K-nearest-neighbor classification for RR Lyrae stars (see caption of figure 9.3 for details). Here the left panel shows the decision boundary for the model based on K = 10 neighbors, and the right panel shows the completeness and contamination for both K = 1 and K = 10. With all four colors and K = 10, K-neighbors classification achieves a completeness of 0.533 and a contamination of 0.240. .. image:: ../images/chapter9/fig_rrlyrae_knn_1.png :scale: 100 :align: center .. raw:: html
**Code output:** .. raw:: html
.. literalinclude:: fig_rrlyrae_knn.txt .. raw:: html
**Python source code:** .. raw:: html
.. literalinclude:: fig_rrlyrae_knn.py :lines: 13- .. raw:: html
:download:`[download source: fig_rrlyrae_knn.py] ` .. raw:: html