{"id":51467,"date":"2025-08-10T23:19:03","date_gmt":"2025-08-10T15:19:03","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/51467.html"},"modified":"2025-08-10T23:19:03","modified_gmt":"2025-08-10T15:19:03","slug":"%e6%9c%ba%e5%99%a8%e5%ad%a6%e4%b9%a0%e5%8f%8a%e5%85%b6knn%e7%ae%97%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/51467.html","title":{"rendered":"\u673a\u5668\u5b66\u4e60\u53ca\u5176KNN\u7b97\u6cd5"},"content":{"rendered":"<h2>\u4e00\u3001\u673a\u5668\u5b66\u4e60\u6982\u8ff0<\/h2>\n<p>\u673a\u5668\u5b66\u4e60&#xff08;Machine Learning, ML&#xff09;\u662f\u4eba\u5de5\u667a\u80fd\u7684\u6838\u5fc3\u5206\u652f&#xff0c;\u65e8\u5728\u901a\u8fc7\u7b97\u6cd5\u8ba9\u8ba1\u7b97\u673a\u4ece\u6570\u636e\u4e2d\u81ea\u52a8\u5b66\u4e60\u89c4\u5f8b\u5e76\u4f18\u5316\u6027\u80fd&#xff0c;\u800c\u65e0\u9700\u663e\u5f0f\u7f16\u7a0b\u3002\u8fd9\u4e00\u6280\u672f\u9886\u57df\u8d77\u6e90\u4e8e20\u4e16\u7eaa50\u5e74\u4ee3&#xff0c;\u968f\u7740\u8ba1\u7b97\u80fd\u529b\u7684\u63d0\u5347\u548c\u5927\u6570\u636e\u65f6\u4ee3\u7684\u5230\u6765&#xff0c;\u572821\u4e16\u7eaa\u5f97\u5230\u4e86\u8fc5\u731b\u53d1\u5c55\u3002<\/p>\n<h4>1. \u57fa\u672c\u6982\u5ff5<\/h4>\n<p>\u673a\u5668\u5b66\u4e60\u901a\u8fc7\u6570\u636e\u8bad\u7ec3\u6a21\u578b&#xff0c;\u4f7f\u5176\u80fd\u591f\u8bc6\u522b\u6a21\u5f0f\u3001\u505a\u51fa\u9884\u6d4b\u6216\u51b3\u7b56\u3002\u4e0e\u4f20\u7edf\u7f16\u7a0b\u4e0d\u540c&#xff0c;\u673a\u5668\u5b66\u4e60\u7cfb\u7edf\u4e0d\u662f\u901a\u8fc7\u76f4\u63a5\u7f16\u5199\u89c4\u5219&#xff0c;\u800c\u662f\u901a\u8fc7\u5206\u6790\u5927\u91cf\u6570\u636e\u6765&#034;\u5b66\u4e60&#034;\u5982\u4f55\u5b8c\u6210\u4efb\u52a1\u3002<\/p>\n<h4>2. \u6838\u5fc3\u601d\u60f3<\/h4>\n<p>\u5176\u6838\u5fc3\u662f&#034;\u4ece\u7ecf\u9a8c\u4e2d\u81ea\u52a8\u6539\u8fdb&#034;&#xff0c;\u8fd9\u4e00\u601d\u60f3\u6a21\u4eff\u4e86\u4eba\u7c7b\u7684\u5b66\u4e60\u8fc7\u7a0b\u3002\u673a\u5668\u5b66\u4e60\u7cfb\u7edf\u901a\u8fc7\u4e0d\u65ad\u8c03\u6574\u5185\u90e8\u53c2\u6570&#xff0c;\u9010\u6b65\u63d0\u9ad8\u5728\u7279\u5b9a\u4efb\u52a1\u4e0a\u7684\u8868\u73b0\u3002<\/p>\n<h4>3. \u5173\u952e\u4e09\u8981\u7d20<\/h4>\n<p>\u673a\u5668\u5b66\u4e60\u7684\u5b9e\u73b0\u4f9d\u8d56\u4e8e\u4e09\u5927\u57fa\u672c\u8981\u7d20&#xff1a;<\/p>\n<ul>\n<li>\u6570\u636e&#xff1a;\u8bad\u7ec3\u6750\u6599&#xff0c;\u5305\u62ec\u7ed3\u6784\u5316\u6570\u636e&#xff08;\u5982\u6570\u636e\u5e93\u8868\u683c&#xff09;\u548c\u975e\u7ed3\u6784\u5316\u6570\u636e&#xff08;\u5982\u6587\u672c\u3001\u56fe\u50cf&#xff09;<\/li>\n<li>\u6a21\u578b&#xff1a;\u8f93\u5165\u5230\u8f93\u51fa\u7684\u6620\u5c04\u51fd\u6570&#xff0c;\u5982\u51b3\u7b56\u6811\u3001\u795e\u7ecf\u7f51\u7edc\u7b49<\/li>\n<li>\u7b97\u6cd5&#xff1a;\u4f18\u5316\u65b9\u6cd5\u5982\u68af\u5ea6\u4e0b\u964d\u3001\u968f\u673a\u68af\u5ea6\u4e0b\u964d\u7b49<\/li>\n<\/ul>\n<h3>\u673a\u5668\u5b66\u4e60\u7b97\u6cd5\u5206\u7c7b<\/h3>\n<h4>1. \u76d1\u7763\u5b66\u4e60&#xff08;Supervised Learning&#xff09;<\/h4>\n<p>\u76d1\u7763\u5b66\u4e60\u4f7f\u7528\u6807\u6ce8\u6570\u636e\u8bad\u7ec3\u6a21\u578b&#xff0c;\u9700\u8981\u63d0\u4f9b\u8f93\u5165\u6570\u636e\u548c\u5bf9\u5e94\u7684\u6b63\u786e\u8f93\u51fa&#xff08;\u6807\u7b7e&#xff09;\u3002\u4e3b\u8981\u5e94\u7528\u5305\u62ec&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5206\u7c7b&#xff1a;\u9884\u6d4b\u79bb\u6563\u7c7b\u522b<\/p>\n<ul>\n<li>\u5783\u573e\u90ae\u4ef6\u8bc6\u522b&#xff08;\u4e8c\u5206\u7c7b&#xff09;<\/li>\n<li>\u624b\u5199\u6570\u5b57\u8bc6\u522b&#xff08;\u591a\u5206\u7c7b&#xff09;<\/li>\n<li>\u533b\u7597\u5f71\u50cf\u8bca\u65ad&#xff08;\u5982\u8bc6\u522b\u80bf\u7624\u7c7b\u578b&#xff09;<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u56de\u5f52&#xff1a;\u9884\u6d4b\u8fde\u7eed\u6570\u503c<\/p>\n<ul>\n<li>\u623f\u4ef7\u9884\u6d4b&#xff08;\u57fa\u4e8e\u9762\u79ef\u3001\u4f4d\u7f6e\u7b49\u7279\u5f81&#xff09;<\/li>\n<li>\u80a1\u7968\u4ef7\u683c\u9884\u6d4b<\/li>\n<li>\u9500\u552e\u9884\u6d4b<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>\u5e38\u7528\u7b97\u6cd5&#xff1a;<\/p>\n<ul>\n<li>\u7ebf\u6027\u56de\u5f52<\/li>\n<li>\u903b\u8f91\u56de\u5f52<\/li>\n<li>\u652f\u6301\u5411\u91cf\u673a(SVM)<\/li>\n<li>\u51b3\u7b56\u6811<\/li>\n<li>\u968f\u673a\u68ee\u6797<\/li>\n<\/ul>\n<h4>2. \u65e0\u76d1\u7763\u5b66\u4e60&#xff08;Unsupervised Learning&#xff09;<\/h4>\n<p>\u65e0\u76d1\u7763\u5b66\u4e60\u4ece\u65e0\u6807\u7b7e\u6570\u636e\u4e2d\u53d1\u73b0\u9690\u85cf\u7684\u7ed3\u6784\u548c\u6a21\u5f0f\u3002\u4e3b\u8981\u5e94\u7528\u5305\u62ec&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u805a\u7c7b&#xff1a;<\/p>\n<ul>\n<li>K-Means&#xff1a;\u5ba2\u6237\u7ec6\u5206\u3001\u6587\u6863\u5206\u7c7b<\/li>\n<li>\u5c42\u6b21\u805a\u7c7b&#xff1a;\u751f\u7269\u5b66\u7684\u7269\u79cd\u5206\u7c7b<\/li>\n<li>DBSCAN&#xff1a;\u5f02\u5e38\u68c0\u6d4b<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u964d\u7ef4&#xff1a;<\/p>\n<ul>\n<li>\u4e3b\u6210\u5206\u5206\u6790(PCA)&#xff1a;\u6570\u636e\u53ef\u89c6\u5316\u3001\u7279\u5f81\u63d0\u53d6<\/li>\n<li>t-SNE&#xff1a;\u9ad8\u7ef4\u6570\u636e\u53ef\u89c6\u5316<\/li>\n<li>\u81ea\u7f16\u7801\u5668&#xff1a;\u56fe\u50cf\u538b\u7f29<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u5173\u8054\u89c4\u5219\u5b66\u4e60&#xff1a;<\/p>\n<ul>\n<li>\u8d2d\u7269\u7bee\u5206\u6790&#xff08;\u5564\u9152\u4e0e\u5c3f\u5e03&#xff09;<\/li>\n<li>\u63a8\u8350\u7cfb\u7edf<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>3. \u5f3a\u5316\u5b66\u4e60&#xff08;Reinforcement Learning&#xff09;<\/h4>\n<p>\u5f3a\u5316\u5b66\u4e60\u901a\u8fc7\u73af\u5883\u4ea4\u4e92\u5b66\u4e60\u6700\u4f18\u7b56\u7565&#xff0c;\u5176\u6838\u5fc3\u662f&#034;\u8bd5\u9519\u5b66\u4e60&#034;\u3002\u4e3b\u8981\u7279\u70b9\u5305\u62ec&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5e94\u7528\u573a\u666f&#xff1a;<\/p>\n<ul>\n<li>\u6e38\u620fAI&#xff08;AlphaGo\u3001\u661f\u9645\u4e89\u9738AI&#xff09;<\/li>\n<li>\u673a\u5668\u4eba\u63a7\u5236&#xff08;\u884c\u8d70\u3001\u6293\u53d6&#xff09;<\/li>\n<li>\u81ea\u52a8\u9a7e\u9a76\u51b3\u7b56<\/li>\n<li>\u91d1\u878d\u4ea4\u6613\u7b56\u7565<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u5173\u952e\u6982\u5ff5&#xff1a;<\/p>\n<ul>\n<li>\u667a\u80fd\u4f53(Agent)<\/li>\n<li>\u73af\u5883(Environment)<\/li>\n<li>\u5956\u52b1(Reward)<\/li>\n<li>\u7b56\u7565(Policy)<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u7b97\u6cd5\u5206\u7c7b&#xff1a;<\/p>\n<ul>\n<li>\u57fa\u4e8e\u4ef7\u503c\u7684\u65b9\u6cd5&#xff08;Q-Learning&#xff09;<\/li>\n<li>\u57fa\u4e8e\u7b56\u7565\u7684\u65b9\u6cd5&#xff08;Policy Gradients&#xff09;<\/li>\n<li>Actor-Critic\u65b9\u6cd5<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>\u673a\u5668\u5b66\u4e60\u5e93<\/h3>\n<p>\u5728Python\u4e2d\u8fdb\u884c\u673a\u5668\u5b66\u4e60\u5f00\u53d1\u65f6&#xff0c;Scikit-learn\u662f\u6700\u5e38\u7528\u7684\u673a\u5668\u5b66\u4e60\u5e93\u4e4b\u4e00\u3002\u5b83\u63d0\u4f9b\u4e86\u5404\u79cd\u76d1\u7763\u5b66\u4e60\u548c\u65e0\u76d1\u7763\u5b66\u4e60\u7b97\u6cd5&#xff0c;\u4ee5\u53ca\u6570\u636e\u9884\u5904\u7406\u3001\u6a21\u578b\u8bc4\u4f30\u7b49\u5de5\u5177&#xff0c;\u662f\u673a\u5668\u5b66\u4e60\u5165\u95e8\u548c\u5b9e\u8df5\u7684\u6700\u4f73\u9009\u62e9<\/p>\n<p>pip install scikit-learn &#061;&#061;1.0.2 -i https:\/\/pypi.tuna.tsinghua.edu.cn\/simple<br \/>\n#\u7bc7\u4f7f\u7528\u7248\u672c\u4e3a1.0.2<\/p>\n<p>#\u5bfc\u5165\u65b9\u6cd5\u5982\u4e0b<br \/>\nimport sklearn<\/p>\n<h2>\u4e8c\u3001KNN&#xff08;K-Nearest Neighbors&#xff0c;K\u8fd1\u90bb&#xff09;\u7b97\u6cd5<\/h2>\n<h4>1.\u6838\u5fc3\u601d\u60f3\u200b<\/h4>\n<p>KNN\u662f\u4e00\u79cd\u57fa\u4e8e\u5b9e\u4f8b\u7684\u76d1\u7763\u5b66\u4e60\u7b97\u6cd5&#xff0c;\u5176\u6838\u5fc3\u5047\u8bbe\u662f\u201c\u76f8\u4f3c\u7684\u6570\u636e\u70b9\u5728\u7279\u5f81\u7a7a\u95f4\u4e2d\u5f7c\u6b64\u9760\u8fd1\u201d\u3002\u901a\u8fc7\u8ba1\u7b97\u5f85\u9884\u6d4b\u6837\u672c\u4e0e\u8bad\u7ec3\u96c6\u4e2d\u6240\u6709\u6837\u672c\u7684\u8ddd\u79bb&#xff0c;\u9009\u62e9\u6700\u8fd1\u7684K\u4e2a\u90bb\u5c45&#xff0c;\u6839\u636e\u8fd9\u4e9b\u90bb\u5c45\u7684\u7c7b\u522b&#xff08;\u5206\u7c7b\u4efb\u52a1&#xff09;\u6216\u6570\u503c&#xff08;\u56de\u5f52\u4efb\u52a1&#xff09;\u8fdb\u884c\u9884\u6d4b\u3002\u672c\u7bc7\u4ee5\u5206\u7c7b\u4e3a\u4e3b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"324\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810151901-6898b865dc5d4.png\" width=\"403\" \/><\/p>\n<h4>\u7b97\u6cd5\u6b65\u9aa4\u200b<\/h4>\n<p>\u6570\u636e\u51c6\u5907<\/p>\n<p>\u6807\u51c6\u5316\/\u5f52\u4e00\u5316\u7279\u5f81&#xff1a;\u6d88\u9664\u91cf\u7eb2\u5dee\u5f02\u5bf9\u8ddd\u79bb\u8ba1\u7b97\u7684\u5f71\u54cd&#xff08;\u5982\u4f7f\u7528StandardScaler&#xff09;<\/p>\n<ul>\n<li>\u8be6\u7ec6\u6b65\u9aa4&#xff1a;\n<li>\u8ba1\u7b97\u6bcf\u4e2a\u7279\u5f81\u7684\u5747\u503c&#xff08;\u03bc&#xff09;\u548c\u6807\u51c6\u5dee&#xff08;\u03c3&#xff09;<\/li>\n<li>\u5bf9\u6bcf\u4e2a\u7279\u5f81\u503cx\u8fdb\u884c\u53d8\u6362&#xff1a;(x-\u03bc)\/\u03c3<\/li>\n<li>\u793a\u4f8b&#xff1a;\u82e5\u7279\u5f81A\u7684\u8303\u56f4\u662f0-1000&#xff0c;\u7279\u5f81B\u7684\u8303\u56f4\u662f0-1&#xff0c;\u6807\u51c6\u5316\u540e\u4e24\u4e2a\u7279\u5f81\u90fd\u670d\u4ece\u5747\u503c\u4e3a0\u3001\u6807\u51c6\u5dee\u4e3a1\u7684\u5206\u5e03<\/li>\n<\/li>\n<li>\u5e94\u7528\u573a\u666f&#xff1a;\u5f53\u7279\u5f81\u7684\u5355\u4f4d\u4e0d\u540c&#xff08;\u5982\u8eab\u9ad8cm vs \u4f53\u91cdkg&#xff09;\u6216\u6570\u503c\u8303\u56f4\u5dee\u5f02\u8f83\u5927\u65f6<\/li>\n<\/ul>\n<p>\u8ddd\u79bb\u8ba1\u7b97<\/p>\n<p>\u5e38\u7528\u8ddd\u79bb\u5ea6\u91cf&#xff1a;<\/p>\n<p>\u6b27\u6c0f\u8ddd\u79bb&#xff08;\u9ed8\u8ba4&#xff09;&#xff1a;\u9002\u7528\u4e8e\u8fde\u7eed\u7279\u5f81<\/p>\n<ul>\n<li>\u516c\u5f0f&#xff1a;d(x,y)&#061;\u221a(\u2211(x_i-y_i)^2)<\/li>\n<li>\u51e0\u4f55\u89e3\u91ca&#xff1a;\u4e24\u70b9\u5728n\u7ef4\u7a7a\u95f4\u4e2d\u7684\u76f4\u7ebf\u8ddd\u79bb<\/li>\n<li>\u793a\u4f8b&#xff1a;\u5728\u4e8c\u7ef4\u7a7a\u95f4\u4e2d&#xff0c;\u70b9(1,3)\u548c(4,7)\u7684\u8ddd\u79bb\u4e3a\u221a((1-4)^2 &#043; (3-7)^2)&#061;5<\/li>\n<\/ul>\n<p>\u66fc\u54c8\u987f\u8ddd\u79bb&#xff1a;\u9002\u7528\u4e8e\u7f51\u683c\u8def\u5f84\u6570\u636e<\/p>\n<ul>\n<li>\u516c\u5f0f&#xff1a;d(x,y)&#061;\u2211|x_i-y_i|<\/li>\n<li>\u522b\u79f0&#xff1a;\u57ce\u5e02\u8857\u533a\u8ddd\u79bb<\/li>\n<li>\u9002\u7528\u573a\u666f&#xff1a;\u68cb\u76d8\u683c\u79fb\u52a8\u3001\u57ce\u5e02\u9053\u8def\u89c4\u5212\u7b49\u7f51\u683c\u72b6\u8def\u5f84\u7cfb\u7edf<\/li>\n<li>\u793a\u4f8b&#xff1a;\u5728\u4e8c\u7ef4\u7f51\u683c\u4e2d&#xff0c;(1,3)\u5230(4,7)\u7684\u8ddd\u79bb\u4e3a|1-4| &#043; |3-7|&#061;7<\/li>\n<\/ul>\n<p>\u9009\u62e9K\u4e2a\u6700\u8fd1\u90bb<\/p>\n<p>\u6309\u8ddd\u79bb\u6392\u5e8f&#xff0c;\u9009\u53d6\u524dK\u4e2a\u6837\u672c<\/p>\n<ul>\n<li>\u5173\u952e\u6b65\u9aa4&#xff1a;\n<li>\u8ba1\u7b97\u5f85\u5206\u7c7b\u6837\u672c\u4e0e\u6240\u6709\u8bad\u7ec3\u6837\u672c\u7684\u8ddd\u79bb<\/li>\n<li>\u5c06\u6240\u6709\u8ddd\u79bb\u6309\u4ece\u5c0f\u5230\u5927\u6392\u5e8f<\/li>\n<li>\u9009\u62e9\u8ddd\u79bb\u6700\u5c0f\u7684K\u4e2a\u6837\u672c<\/li>\n<\/li>\n<li>\u6ce8\u610f\u4e8b\u9879&#xff1a;K\u503c\u901a\u5e38\u53d6\u5947\u6570&#xff08;\u59823\/5\/7&#xff09;\u4ee5\u907f\u514d\u5e73\u7968\u60c5\u51b5<\/li>\n<\/ul>\n<p>\u6295\u7968\u51b3\u7b56<\/p>\n<p>\u7edf\u8ba1K\u4e2a\u90bb\u5c45\u7684\u7c7b\u522b\u9891\u7387&#xff0c;\u5c06\u5f85\u5206\u7c7b\u6837\u672c\u5212\u5165\u9891\u7387\u6700\u9ad8\u7684\u7c7b\u522b<\/p>\n<ul>\n<li>\u5177\u4f53\u6d41\u7a0b&#xff1a;\n<li>\u7edf\u8ba1K\u4e2a\u90bb\u5c45\u4e2d\u6bcf\u4e2a\u7c7b\u522b\u51fa\u73b0\u7684\u6b21\u6570<\/li>\n<li>\u9009\u62e9\u51fa\u73b0\u6b21\u6570\u6700\u591a\u7684\u7c7b\u522b\u4f5c\u4e3a\u9884\u6d4b\u7ed3\u679c<\/li>\n<li>\u5e73\u7968\u5904\u7406&#xff1a;\u53ef\u968f\u673a\u9009\u62e9\u6216\u8003\u8651\u66f4\u5c0f\u7684K\u503c<\/li>\n<\/li>\n<li>\u6269\u5c55&#xff1a;\u4e5f\u53ef\u4f7f\u7528\u52a0\u6743\u6295\u7968&#xff0c;\u8ddd\u79bb\u8fd1\u7684\u90bb\u5c45\u6295\u7968\u6743\u91cd\u66f4\u5927<\/li>\n<\/ul>\n<p>\u6570\u636e\u51c6\u5907<\/p>\n<p>\u6807\u51c6\u5316\/\u5f52\u4e00\u5316\u7279\u5f81&#xff1a;\u6d88\u9664\u91cf\u7eb2\u5dee\u5f02\u5bf9\u8ddd\u79bb\u8ba1\u7b97\u7684\u5f71\u54cd&#xff08;\u5982\u4f7f\u7528StandardScaler&#xff09;<\/p>\n<ul>\n<li>\u8be6\u7ec6\u6b65\u9aa4&#xff1a;\n<li>\u8ba1\u7b97\u6bcf\u4e2a\u7279\u5f81\u7684\u5747\u503c&#xff08;\u03bc&#xff09;\u548c\u6807\u51c6\u5dee&#xff08;\u03c3&#xff09;<\/li>\n<li>\u5bf9\u6bcf\u4e2a\u7279\u5f81\u503cx\u8fdb\u884c\u53d8\u6362&#xff1a;(x-\u03bc)\/\u03c3<\/li>\n<li>\u793a\u4f8b&#xff1a;\u82e5\u7279\u5f81A\u7684\u8303\u56f4\u662f0-1000&#xff0c;\u7279\u5f81B\u7684\u8303\u56f4\u662f0-1&#xff0c;\u6807\u51c6\u5316\u540e\u4e24\u4e2a\u7279\u5f81\u90fd\u670d\u4ece\u5747\u503c\u4e3a0\u3001\u6807\u51c6\u5dee\u4e3a1\u7684\u5206\u5e03<\/li>\n<\/li>\n<li>\u5e94\u7528\u573a\u666f&#xff1a;\u5f53\u7279\u5f81\u7684\u5355\u4f4d\u4e0d\u540c&#xff08;\u5982\u8eab\u9ad8cm vs \u4f53\u91cdkg&#xff09;\u6216\u6570\u503c\u8303\u56f4\u5dee\u5f02\u8f83\u5927\u65f6<\/li>\n<\/ul>\n<p>\u8ddd\u79bb\u8ba1\u7b97<\/p>\n<p>\u5e38\u7528\u8ddd\u79bb\u5ea6\u91cf&#xff1a;<\/p>\n<p>\u6b27\u6c0f\u8ddd\u79bb&#xff08;\u9ed8\u8ba4&#xff09;&#xff1a;\u9002\u7528\u4e8e\u8fde\u7eed\u7279\u5f81<\/p>\n<ul>\n<li>\u516c\u5f0f&#xff1a;<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"54\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810151902-6898b8667ecca.png\" width=\"287\" \/><\/li>\n<li>\u51e0\u4f55\u89e3\u91ca&#xff1a;\u4e24\u70b9\u5728n\u7ef4\u7a7a\u95f4\u4e2d\u7684\u76f4\u7ebf\u8ddd\u79bb<\/li>\n<li>\u793a\u4f8b&#xff1a;\u5728\u4e8c\u7ef4\u7a7a\u95f4\u4e2d&#xff0c;\u70b9(1,3)\u548c(4,7)\u7684\u8ddd\u79bb\u4e3a\u221a((1-4)^2 &#043; (3-7)^2)&#061;5<\/li>\n<\/ul>\n<p>\u66fc\u54c8\u987f\u8ddd\u79bb&#xff1a;\u9002\u7528\u4e8e\u7f51\u683c\u8def\u5f84\u6570\u636e<\/p>\n<ul>\n<li>\u516c\u5f0f&#xff1a;<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"45\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810151902-6898b8668642f.png\" width=\"246\" \/><\/li>\n<li>\u522b\u79f0&#xff1a;\u57ce\u5e02\u8857\u533a\u8ddd\u79bb<\/li>\n<li>\u9002\u7528\u573a\u666f&#xff1a;\u68cb\u76d8\u683c\u79fb\u52a8\u3001\u57ce\u5e02\u9053\u8def\u89c4\u5212\u7b49\u7f51\u683c\u72b6\u8def\u5f84\u7cfb\u7edf<\/li>\n<li>\u793a\u4f8b&#xff1a;\u5728\u4e8c\u7ef4\u7f51\u683c\u4e2d&#xff0c;(1,3)\u5230(4,7)\u7684\u8ddd\u79bb\u4e3a|1-4| &#043; |3-7|&#061;7<\/li>\n<\/ul>\n<p>\u9009\u62e9K\u4e2a\u6700\u8fd1\u90bb<\/p>\n<p>\u6309\u8ddd\u79bb\u6392\u5e8f&#xff0c;\u9009\u53d6\u524dK\u4e2a\u6837\u672c<\/p>\n<ul>\n<li>\u5173\u952e\u6b65\u9aa4&#xff1a;\n<li>\u8ba1\u7b97\u5f85\u5206\u7c7b\u6837\u672c\u4e0e\u6240\u6709\u8bad\u7ec3\u6837\u672c\u7684\u8ddd\u79bb<\/li>\n<li>\u5c06\u6240\u6709\u8ddd\u79bb\u6309\u4ece\u5c0f\u5230\u5927\u6392\u5e8f<\/li>\n<li>\u9009\u62e9\u8ddd\u79bb\u6700\u5c0f\u7684K\u4e2a\u6837\u672c<\/li>\n<\/li>\n<li>\u6ce8\u610f\u4e8b\u9879&#xff1a;K\u503c\u901a\u5e38\u53d6\u5947\u6570&#xff08;\u59823\/5\/7&#xff09;\u4ee5\u907f\u514d\u5e73\u7968\u60c5\u51b5<\/li>\n<\/ul>\n<p>\u6295\u7968\u51b3\u7b56<\/p>\n<p>\u7edf\u8ba1K\u4e2a\u90bb\u5c45\u7684\u7c7b\u522b\u9891\u7387&#xff0c;\u5c06\u5f85\u5206\u7c7b\u6837\u672c\u5212\u5165\u9891\u7387\u6700\u9ad8\u7684\u7c7b\u522b<\/p>\n<ul>\n<li>\u5177\u4f53\u6d41\u7a0b&#xff1a;\n<li>\u7edf\u8ba1K\u4e2a\u90bb\u5c45\u4e2d\u6bcf\u4e2a\u7c7b\u522b\u51fa\u73b0\u7684\u6b21\u6570<\/li>\n<li>\u9009\u62e9\u51fa\u73b0\u6b21\u6570\u6700\u591a\u7684\u7c7b\u522b\u4f5c\u4e3a\u9884\u6d4b\u7ed3\u679c<\/li>\n<li>\u5e73\u7968\u5904\u7406&#xff1a;\u53ef\u968f\u673a\u9009\u62e9\u6216\u8003\u8651\u66f4\u5c0f\u7684K\u503c<\/li>\n<\/li>\n<li>\u6269\u5c55&#xff1a;\u4e5f\u53ef\u4f7f\u7528\u52a0\u6743\u6295\u7968&#xff0c;\u8ddd\u79bb\u8fd1\u7684\u90bb\u5c45\u6295\u7968\u6743\u91cd\u66f4\u5927<\/li>\n<\/ul>\n<h4>\u5173\u952e\u53c2\u6570\u4e0e\u4f18\u5316\u200b\u200b<\/h4>\n<ul>\n<li>\n<h4>\u5173\u952e\u53c2\u6570\u4e0e\u4f18\u5316<\/h4>\n<h5>K\u503c\u9009\u62e9<\/h5>\n<p>K\u503c\u7684\u9009\u62e9\u76f4\u63a5\u5f71\u54cdKNN\u6a21\u578b\u7684\u6027\u80fd&#xff1a;<\/p>\n<\/li>\n<li>K\u503c\u8fc7\u5c0f&#xff08;\u5982K&#061;1&#xff09;&#xff1a;\n<ul>\n<li>\u6a21\u578b\u4f1a\u8fc7\u4e8e\u5173\u6ce8\u5c40\u90e8\u566a\u58f0\u70b9&#xff0c;\u5bfc\u81f4\u8fc7\u62df\u5408<\/li>\n<li>\u51b3\u7b56\u8fb9\u754c\u53d8\u5f97\u975e\u5e38\u590d\u6742\u4e14\u4e0d\u89c4\u5219<\/li>\n<li>\u793a\u4f8b&#xff1a;\u5728\u56fe\u50cf\u5206\u7c7b\u4e2d&#xff0c;K&#061;1\u53ef\u80fd\u5bfc\u81f4\u5bf9\u4e2a\u522b\u5f02\u5e38\u50cf\u7d20\u8fc7\u4e8e\u654f\u611f<\/li>\n<\/ul>\n<\/li>\n<li>K\u503c\u8fc7\u5927&#xff1a;\n<ul>\n<li>\u6a21\u578b\u4f1a\u5ffd\u7565\u6570\u636e\u7684\u5c40\u90e8\u7279\u5f81&#xff0c;\u5bfc\u81f4\u6b20\u62df\u5408<\/li>\n<li>\u51b3\u7b56\u8fb9\u754c\u8fc7\u5ea6\u5e73\u6ed1&#xff0c;\u53ef\u80fd\u9519\u8fc7\u91cd\u8981\u6a21\u5f0f<\/li>\n<li>\u793a\u4f8b&#xff1a;\u5728\u623f\u4ef7\u9884\u6d4b\u4e2d&#xff0c;\u8fc7\u5927\u7684K\u503c\u53ef\u80fd\u4f7f\u4e0d\u540c\u793e\u533a\u7684\u623f\u4ef7\u5dee\u5f02\u88ab\u5e73\u5747\u5316<\/li>\n<\/ul>\n<\/li>\n<li>\n<ul>\n<li>\n<p>\u4f18\u5316\u65b9\u6cd5&#xff1a;<\/p>\n<\/li>\n<li>\u4ea4\u53c9\u9a8c\u8bc1&#xff1a;\n<ul>\n<li>\u91c7\u7528k\u6298\u4ea4\u53c9\u9a8c\u8bc1&#xff08;\u59825\u6298\u621610\u6298&#xff09;\u8bc4\u4f30\u4e0d\u540cK\u503c<\/li>\n<li>\u7f51\u683c\u641c\u7d22&#xff1a;\u7cfb\u7edf\u6027\u5730\u6d4b\u8bd5K\u503c\u8303\u56f4&#xff08;\u59821-20&#xff09;<\/li>\n<\/ul>\n<\/li>\n<li>\u7ecf\u9a8c\u6cd5\u5219&#xff1a;\n<ul>\n<li>K\u2248\u221an&#xff08;n\u4e3a\u8bad\u7ec3\u6837\u672c\u6570&#xff09;<\/li>\n<li>\u901a\u5e38\u9009\u62e9\u5947\u6570K\u503c\u4ee5\u907f\u514d\u5e73\u7968\u60c5\u51b5<\/li>\n<li>\u5bf9\u4e8e\u5206\u7c7b\u95ee\u9898&#xff0c;\u521d\u59cb\u53ef\u5c1d\u8bd5K&#061;3,5,7\u7b49\u5c0f\u503c<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>\u4e09\u3001knn\u7b97\u6cd5\u7684\u8fd0\u7528<\/h2>\n<p>class sklearn.neighbors.KNeighborsClassifier( n_neighbors&#061;5, weights&#061;&#039;uniform&#039;, algorithm&#061;&#039;auto&#039;, leaf_size&#061;30, p&#061;2, metric&#061;&#039;minkowski&#039;, metric_params&#061;None, n_jobs&#061;None)<\/p>\n<table>\n<tr>\n<p>\u53c2\u6570\u540d<\/p>\n<p>\u7c7b\u578b\/\u9009\u9879<\/p>\n<p>\u9ed8\u8ba4\u503c<\/p>\n<p>\u4f5c\u7528<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>n_neighbors<\/p>\n<\/td>\n<td>\n<p>int<\/p>\n<\/td>\n<td>\n<p>5<\/p>\n<\/td>\n<td>\n<p>\u8fd1\u90bb\u6570K&#xff0c;\u51b3\u5b9a\u6295\u7968\u7684\u6837\u672c\u6570\u91cf<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>weights<\/p>\n<\/td>\n<td>\n<p>&#039;uniform&#039;,\u00a0&#039;distance&#039;\u6216\u53ef\u8c03\u7528\u5bf9\u8c61<\/p>\n<\/td>\n<td>\n<p>&#039;uniform&#039;<\/p>\n<\/td>\n<td>\n<p>\u6743\u91cd\u5206\u914d\u65b9\u5f0f&#xff1a;<br \/>\n&#8211;\u00a0&#039;uniform&#039;&#xff1a;\u7b49\u6743\u91cd\u6295\u7968<br \/>\n&#8211;\u00a0&#039;distance&#039;&#xff1a;\u6309\u8ddd\u79bb\u53cd\u6bd4\u52a0\u6743<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>algorithm<\/p>\n<\/td>\n<td>\n<p>&#039;auto&#039;,\u00a0&#039;ball_tree&#039;,\u00a0&#039;kd_tree&#039;,\u00a0&#039;brute&#039;<\/p>\n<\/td>\n<td>\n<p>&#039;auto&#039;<\/p>\n<\/td>\n<td>\n<p>\u8fd1\u90bb\u641c\u7d22\u7b97\u6cd5&#xff1a;<br \/>\n&#8211;\u00a0&#039;ball_tree&#039;\/&#039;kd_tree&#039;&#xff1a;\u6811\u7ed3\u6784\u52a0\u901f\u641c\u7d22&#xff08;\u7ef4\u5ea6&lt;20\u65f6\u9ad8\u6548&#xff09;<br \/>\n&#8211;\u00a0&#039;brute&#039;&#xff1a;\u66b4\u529b\u641c\u7d22&#xff08;\u9002\u5408\u5c0f\u6570\u636e\u96c6&#xff09;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>p<\/p>\n<\/td>\n<td>\n<p>int<\/p>\n<\/td>\n<td>\n<p>2<\/p>\n<\/td>\n<td>\n<p>\u95f5\u53ef\u592b\u65af\u57fa\u8ddd\u79bb\u7684\u5e42\u53c2\u6570&#xff1a;<br \/>\n&#8211;\u00a0p&#061;1&#xff1a;\u66fc\u54c8\u987f\u8ddd\u79bb<br \/>\n&#8211;\u00a0p&#061;2&#xff1a;\u6b27\u6c0f\u8ddd\u79bb<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>metric<\/p>\n<\/td>\n<td>\n<p>str\u6216\u53ef\u8c03\u7528\u5bf9\u8c61<\/p>\n<\/td>\n<td>\n<p>&#039;minkowski&#039;<\/p>\n<\/td>\n<td>\n<p>\u8ddd\u79bb\u5ea6\u91cf\u6807\u51c6&#xff08;\u5982&#039;cosine&#039;\u3001&#039;euclidean&#039;&#xff09;<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>n_jobs<\/p>\n<\/td>\n<td>\n<p>int\u6216None<\/p>\n<\/td>\n<td>\n<p>None<\/p>\n<\/td>\n<td>\n<p>\u5e76\u884c\u8ba1\u7b97\u7ebf\u7a0b\u6570&#xff08;-1\u8868\u793a\u4f7f\u7528\u6240\u6709CPU\u6838\u5fc3&#xff09;<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<table>\n<tr>\n<p>\u6cd5\u540d<\/p>\n<p>\u529f\u80fd<\/p>\n<p>\u793a\u4f8b<\/p>\n<\/tr>\n<tbody>\n<tr>\n<td>\n<p>fit(X, y)<\/p>\n<\/td>\n<td>\n<p>\u5b58\u50a8\u8bad\u7ec3\u6570\u636e&#xff08;\u60f0\u6027\u5b66\u4e60&#xff09;<\/p>\n<\/td>\n<td>\n<p>knn.fit(X_train, y_train)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>predict(X)<\/p>\n<\/td>\n<td>\n<p>\u8fd4\u56de\u9884\u6d4b\u7c7b\u522b<\/p>\n<\/td>\n<td>\n<p>y_pred &#061; knn.predict(X_test)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>predict_proba(X)<\/p>\n<\/td>\n<td>\n<p>\u8fd4\u56de\u6837\u672c\u5c5e\u4e8e\u5404\u7c7b\u522b\u7684\u6982\u7387&#xff08;\u57fa\u4e8e\u90bb\u5c45\u7c7b\u522b\u7684\u9891\u7387&#xff09;<\/p>\n<\/td>\n<td>\n<p>prob &#061; knn.predict_proba([[1.5]])\u2192\u00a0[[0.6, 0.4]]<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>score(X, y)<\/p>\n<\/td>\n<td>\n<p>\u8ba1\u7b97\u51c6\u786e\u7387&#xff08;\u5206\u7c7b&#xff09;\u6216R\u00b2\u5206\u6570&#xff08;\u56de\u5f52&#xff09;<\/p>\n<\/td>\n<td>\n<p>accuracy &#061; knn.score(X_test, y_test)<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>kneighbors(X)<\/p>\n<\/td>\n<td>\n<p>\u8fd4\u56deK\u8fd1\u90bb\u7684\u7d22\u5f15\u548c\u8ddd\u79bb<\/p>\n<\/td>\n<td>\n<p>dist, indices &#061; knn.kneighbors([[0.5]])<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u56db\u3001\u7b97\u6cd5\u793a\u4f8b<\/h2>\n<p>from matplotlib import pyplot as plt<br \/>\nimport numpy as np<\/p>\n<p>#knn\u7b97\u6cd5\u9884\u6d4b<br \/>\nfrom sklearn.neighbors import KNeighborsClassifier<br \/>\ndata &#061; np.loadtxt(&#039;datingTestSet2.txt&#039;, delimiter&#061;&#039;\\\\t&#039;)<br \/>\nneigh &#061; KNeighborsClassifier(n_neighbors&#061;5)<br \/>\nx&#061;data[:800,:-1]<br \/>\ny&#061;data[:800,-1]<br \/>\nneigh.fit(x,y)<br \/>\nprint(neigh.score(x,y))#\u51c6\u786e\u7387,\u81ea\u6d4b<br \/>\nc1&#061;data[800:,:-1]<br \/>\nc2&#061;data[800:,-1]<br \/>\nright&#061;neigh.score(c1,c2)<br \/>\nprint(right)<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"48\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810151902-6898b8668cdd9.png\" width=\"77\" \/><\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\uff0c\u70b9\u8d5e41\u6b21\uff0c\u6536\u85cf28\u6b21\u3002\u673a\u5668\u5b66\u4e60\uff08Machine Learning, ML\uff09\u662f\u4eba\u5de5\u667a\u80fd\u7684\u6838\u5fc3\u5206\u652f\uff0c\u65e8\u5728\u901a\u8fc7\u7b97\u6cd5\u8ba9\u8ba1\u7b97\u673a\u4ece\u6570\u636e\u4e2d\u81ea\u52a8\u5b66\u4e60\u89c4\u5f8b\u5e76\u4f18\u5316\u6027\u80fd\uff0c\u800c\u65e0\u9700\u663e\u5f0f\u7f16\u7a0b\u3002\u8fd9\u4e00\u6280\u672f\u9886\u57df\u8d77\u6e90\u4e8e20\u4e16\u7eaa50\u5e74\u4ee3\uff0c\u968f\u7740\u8ba1\u7b97\u80fd\u529b\u7684\u63d0\u5347\u548c\u5927\u6570\u636e\u65f6\u4ee3\u7684\u5230\u6765\uff0c\u572821\u4e16\u7eaa\u5f97\u5230\u4e86\u8fc5\u731b\u53d1\u5c55\u3002<\/p>\n","protected":false},"author":2,"featured_media":51463,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[50,207,427],"topic":[],"class_list":["post-51467","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-50","tag-207","tag-427"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u673a\u5668\u5b66\u4e60\u53ca\u5176KNN\u7b97\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/51467.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u673a\u5668\u5b66\u4e60\u53ca\u5176KNN\u7b97\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\uff0c\u70b9\u8d5e41\u6b21\uff0c\u6536\u85cf28\u6b21\u3002\u673a\u5668\u5b66\u4e60\uff08Machine Learning, ML\uff09\u662f\u4eba\u5de5\u667a\u80fd\u7684\u6838\u5fc3\u5206\u652f\uff0c\u65e8\u5728\u901a\u8fc7\u7b97\u6cd5\u8ba9\u8ba1\u7b97\u673a\u4ece\u6570\u636e\u4e2d\u81ea\u52a8\u5b66\u4e60\u89c4\u5f8b\u5e76\u4f18\u5316\u6027\u80fd\uff0c\u800c\u65e0\u9700\u663e\u5f0f\u7f16\u7a0b\u3002\u8fd9\u4e00\u6280\u672f\u9886\u57df\u8d77\u6e90\u4e8e20\u4e16\u7eaa50\u5e74\u4ee3\uff0c\u968f\u7740\u8ba1\u7b97\u80fd\u529b\u7684\u63d0\u5347\u548c\u5927\u6570\u636e\u65f6\u4ee3\u7684\u5230\u6765\uff0c\u572821\u4e16\u7eaa\u5f97\u5230\u4e86\u8fc5\u731b\u53d1\u5c55\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/51467.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-10T15:19:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810151901-6898b865dc5d4.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/51467.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/51467.html\",\"name\":\"\u673a\u5668\u5b66\u4e60\u53ca\u5176KNN\u7b97\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-10T15:19:03+00:00\",\"dateModified\":\"2025-08-10T15:19:03+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/51467.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/51467.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/51467.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u673a\u5668\u5b66\u4e60\u53ca\u5176KNN\u7b97\u6cd5\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u673a\u5668\u5b66\u4e60\u53ca\u5176KNN\u7b97\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/51467.html","og_locale":"zh_CN","og_type":"article","og_title":"\u673a\u5668\u5b66\u4e60\u53ca\u5176KNN\u7b97\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\uff0c\u70b9\u8d5e41\u6b21\uff0c\u6536\u85cf28\u6b21\u3002\u673a\u5668\u5b66\u4e60\uff08Machine Learning, ML\uff09\u662f\u4eba\u5de5\u667a\u80fd\u7684\u6838\u5fc3\u5206\u652f\uff0c\u65e8\u5728\u901a\u8fc7\u7b97\u6cd5\u8ba9\u8ba1\u7b97\u673a\u4ece\u6570\u636e\u4e2d\u81ea\u52a8\u5b66\u4e60\u89c4\u5f8b\u5e76\u4f18\u5316\u6027\u80fd\uff0c\u800c\u65e0\u9700\u663e\u5f0f\u7f16\u7a0b\u3002\u8fd9\u4e00\u6280\u672f\u9886\u57df\u8d77\u6e90\u4e8e20\u4e16\u7eaa50\u5e74\u4ee3\uff0c\u968f\u7740\u8ba1\u7b97\u80fd\u529b\u7684\u63d0\u5347\u548c\u5927\u6570\u636e\u65f6\u4ee3\u7684\u5230\u6765\uff0c\u572821\u4e16\u7eaa\u5f97\u5230\u4e86\u8fc5\u731b\u53d1\u5c55\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/51467.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-10T15:19:03+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810151901-6898b865dc5d4.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/51467.html","url":"https:\/\/www.wsisp.com\/helps\/51467.html","name":"\u673a\u5668\u5b66\u4e60\u53ca\u5176KNN\u7b97\u6cd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-10T15:19:03+00:00","dateModified":"2025-08-10T15:19:03+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/51467.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/51467.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/51467.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u673a\u5668\u5b66\u4e60\u53ca\u5176KNN\u7b97\u6cd5"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/51467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=51467"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/51467\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/51463"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=51467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=51467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=51467"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=51467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}