CINXE.COM
Just a moment...
<!DOCTYPE html><html lang="en-US"><head><title>Just a moment...</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=Edge"><meta name="robots" content="noindex,nofollow"><meta name="viewport" content="width=device-width,initial-scale=1"><style>*{box-sizing:border-box;margin:0;padding:0}html{line-height:1.15;-webkit-text-size-adjust:100%;color:#313131;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji}body{display:flex;flex-direction:column;height:100vh;min-height:100vh}.main-content{margin:8rem auto;max-width:60rem;padding-left:1.5rem}@media (width <= 720px){.main-content{margin-top:4rem}}.h2{font-size:1.5rem;font-weight:500;line-height:2.25rem}@media (width <= 720px){.h2{font-size:1.25rem;line-height:1.5rem}}#challenge-error-text{background-image:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iI0IyMEYwMyIgZD0iTTE2IDNhMTMgMTMgMCAxIDAgMTMgMTNBMTMuMDE1IDEzLjAxNSAwIDAgMCAxNiAzbTAgMjRhMTEgMTEgMCAxIDEgMTEtMTEgMTEuMDEgMTEuMDEgMCAwIDEtMTEgMTEiLz48cGF0aCBmaWxsPSIjQjIwRjAzIiBkPSJNMTcuMDM4IDE4LjYxNUgxNC44N0wxNC41NjMgOS41aDIuNzgzem0tMS4wODQgMS40MjdxLjY2IDAgMS4wNTcuMzg4LjQwNy4zODkuNDA3Ljk5NCAwIC41OTYtLjQwNy45ODQtLjM5Ny4zOS0xLjA1Ny4zODktLjY1IDAtMS4wNTYtLjM4OS0uMzk4LS4zODktLjM5OC0uOTg0IDAtLjU5Ny4zOTgtLjk4NS40MDYtLjM5NyAxLjA1Ni0uMzk3Ii8+PC9zdmc+);background-repeat:no-repeat;background-size:contain;padding-left:34px}@media (prefers-color-scheme:dark){body{background-color:#222;color:#d9d9d9}}</style><meta http-equiv="refresh" content="390"></head><body class="no-js"><div class="main-wrapper" role="main"><div class="main-content"><noscript><div class="h2"><span id="challenge-error-text">Enable JavaScript and cookies to continue</span></div></noscript></div></div><script>(function(){window._cf_chl_opt={cvId: '3',cZone: "machinelearningmastery.com",cType: 'managed',cRay: '8e73f975896f8228',cH: 'GGIWrmTNaDU2mjH6qOQL1a_PveFldo.NuUMi5YFPsaY-1732394427-1.2.1.1-FhHumb5An63x1pkpHu9h61u_VYJR4tJ7.BcaoxFUPc3wI_M7K_L2b46l6LJ04nvk',cUPMDTk: "\/tutorial-to-implement-k-nearest-neighbors-in-python-fromscratch\/?__cf_chl_tk=hX7_MSQEOJt9xqfNMmLee4w8XEuKiU47kAfXcfogWWs-1732394427-1.0.1.1-rUivOgDAaWmKXXSevYonUteWPvrv7f.N6gQQgqCgvWQ",cFPWv: 'g',cITimeS: '1732394427',cTTimeMs: '1000',cMTimeMs: '390000',cTplC: 0,cTplV: 5,cTplB: 'cf',cK: "",fa: "\/tutorial-to-implement-k-nearest-neighbors-in-python-fromscratch\/?__cf_chl_f_tk=hX7_MSQEOJt9xqfNMmLee4w8XEuKiU47kAfXcfogWWs-1732394427-1.0.1.1-rUivOgDAaWmKXXSevYonUteWPvrv7f.N6gQQgqCgvWQ",md: "Q3C7Ie7Hk05cWHHVezPazWrq6DsQ4f3382d2n_KGy2g-1732394427-1.2.1.1-cGGioC8uF9QysK7_JBnMkMXCFLL6gdbaK8Os9QcUnITE1yTk4BX_m6Sii.QxFHxywX2BDDenk9n_L9TRLfYa44bHZ83gZAZI3AMil1JlvBaRt3AWrPIT19CAzNlPAJV8FQ.2xAwdoHq4aG8AlZuSJeXqaU4GJ7Iqqr.SjTQEpNLWXgeOX5BDP39ufNbUgfnExbpmu8Q97Zx6qF5JnenUOatZ_FlIhatZFdxbPG6Kq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rs3VIi4Tx.apknRpxWPseaDdf2rk56pU3ecE4mK17gBuYq45ABoZiP2qDL_xKr1GUJ0X2R1GCxcZqIIKRvNxStPzdkf87QgOGAoh44oEIDF9cS8qcGSSX1h3rTQpaCdOCFnV58YEvlwD2ovVRwf6RJLgrJknYoKZFzHczFzzoDpzzghZ6ytNfVrUbSNPZj64hUGx9qzKrl5EZqM0jidXwEgwll6oycYQpO7ehreRbZS0xgfvC923gQWkI7yXtaSbTarawQ7Xz466VG9BgY509FVDQ8nVRcXi_DeL.Xj_Le5gftFt6aXFotH6SALAxmr2k3It7T2TlcuPF3DQs9yi_vguNpJkrbfY4MqgW6dQY5qq9frXjrru7LkayxBiRhqwg4J0l8FcygIH6m.ACin.T7wtmyqQBK.cDck2dRgC8XOTjBsOHCKi3RaVWi5t8FPtIIkArhdljlI3trmf_YH4Vwu0EoHSrxRrtfyZf8R6WCY.IH2PSK9Kpy.iXhjro9M9.gavdbNp_MX2LfQDI4df4anZRxHKhVCXU5utPCKILMQc7C1OVdbq_98npcx4tMeI3y_solt18FOiZYfI39lXheCsD06gPfX1zpeHCI"};var cpo = document.createElement('script');cpo.src = '/cdn-cgi/challenge-platform/h/g/orchestrate/chl_page/v1?ray=8e73f975896f8228';window._cf_chl_opt.cOgUHash = location.hash === '' && location.href.indexOf('#') !== -1 ? '#' : location.hash;window._cf_chl_opt.cOgUQuery = location.search === '' && location.href.slice(0, location.href.length - window._cf_chl_opt.cOgUHash.length).indexOf('?') !== -1 ? '?' : location.search;if (window.history && window.history.replaceState) {var ogU = location.pathname + window._cf_chl_opt.cOgUQuery + window._cf_chl_opt.cOgUHash;history.replaceState(null, null, "\/tutorial-to-implement-k-nearest-neighbors-in-python-fromscratch\/?__cf_chl_rt_tk=hX7_MSQEOJt9xqfNMmLee4w8XEuKiU47kAfXcfogWWs-1732394427-1.0.1.1-rUivOgDAaWmKXXSevYonUteWPvrv7f.N6gQQgqCgvWQ" + window._cf_chl_opt.cOgUHash);cpo.onload = function() {history.replaceState(null, null, ogU);}}document.getElementsByTagName('head')[0].appendChild(cpo);}());</script></body></html>