{"id":1187477,"date":"2025-01-15T20:06:03","date_gmt":"2025-01-15T12:06:03","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1187477.html"},"modified":"2025-01-15T20:06:06","modified_gmt":"2025-01-15T12:06:06","slug":"python%e5%a6%82%e4%bd%95%e8%bf%9b%e8%a1%8c%e5%88%86%e7%b1%bb%e5%88%a4%e5%88%ab","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1187477.html","title":{"rendered":"python\u5982\u4f55\u8fdb\u884c\u5206\u7c7b\u5224\u522b"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25140036\/28fd7a78-9a62-41c7-a007-dd4e1e7c3b43.webp\" alt=\"python\u5982\u4f55\u8fdb\u884c\u5206\u7c7b\u5224\u522b\" \/><\/p>\n<p><p> <strong>Python\u8fdb\u884c\u5206\u7c7b\u5224\u522b\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5982\uff1aK\u8fd1\u90bb\u7b97\u6cd5\uff08KNN\uff09\u3001\u51b3\u7b56\u6811\u3001\u968f\u673a\u68ee\u6797\u3001\u652f\u6301\u5411\u91cf\u673a\uff08SVM\uff09\u3001\u903b\u8f91\u56de\u5f52\u3001\u6734\u7d20\u8d1d\u53f6\u65af\u3001\u795e\u7ecf\u7f51\u7edc\u7b49\u3002<\/strong>\u5728\u8fd9\u4e9b\u65b9\u6cd5\u4e2d\uff0c<strong>\u968f\u673a\u68ee\u6797<\/strong>\u662f\u4e00\u79cd\u975e\u5e38\u5f3a\u5927\u4e14\u5e38\u7528\u7684\u5206\u7c7b\u65b9\u6cd5\u3002\u968f\u673a\u68ee\u6797\u662f\u4e00\u79cd\u96c6\u6210\u5b66\u4e60\u65b9\u6cd5\uff0c\u5b83\u901a\u8fc7\u6784\u5efa\u591a\u4e2a\u51b3\u7b56\u6811\uff0c\u5e76\u7ed3\u5408\u5b83\u4eec\u7684\u9884\u6d4b\u7ed3\u679c\u6765\u63d0\u9ad8\u5206\u7c7b\u7684\u51c6\u786e\u6027\u548c\u9c81\u68d2\u6027\u3002\u968f\u673a\u68ee\u6797\u7684\u4f18\u52bf\u5728\u4e8e\u5b83\u80fd\u591f\u5904\u7406\u9ad8\u7ef4\u6570\u636e\uff0c\u5e76\u4e14\u5bf9\u6570\u636e\u4e2d\u7684\u566a\u58f0\u548c\u5f02\u5e38\u503c\u4e0d\u654f\u611f\u3002\u4e0b\u9762\u8be6\u7ec6\u63cf\u8ff0\u968f\u673a\u68ee\u6797\u7684\u5206\u7c7b\u8fc7\u7a0b\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001K\u8fd1\u90bb\u7b97\u6cd5\uff08KNN\uff09<\/h3>\n<\/p>\n<p><p>K\u8fd1\u90bb\u7b97\u6cd5\u662f\u6700\u7b80\u5355\u7684\u5206\u7c7b\u7b97\u6cd5\u4e4b\u4e00\u3002\u5b83\u7684\u57fa\u672c\u601d\u60f3\u662f\uff1a\u7ed9\u5b9a\u4e00\u4e2a\u6837\u672c\u70b9\uff0c\u627e\u5230\u8bad\u7ec3\u96c6\u4e2d\u4e0e\u8be5\u6837\u672c\u70b9\u6700\u63a5\u8fd1\u7684K\u4e2a\u70b9\uff0c\u7136\u540e\u6839\u636e\u8fd9K\u4e2a\u70b9\u7684\u7c7b\u522b\u6765\u51b3\u5b9a\u8be5\u6837\u672c\u70b9\u7684\u7c7b\u522b\u3002K\u8fd1\u90bb\u7b97\u6cd5\u7684\u4f18\u70b9\u662f\u7b80\u5355\u6613\u61c2\uff0c\u4e0d\u9700\u8981\u8bad\u7ec3\u8fc7\u7a0b\uff1b\u7f3a\u70b9\u662f\u8ba1\u7b97\u91cf\u5927\uff0c\u5bf9\u5185\u5b58\u8981\u6c42\u9ad8\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u57fa\u672c\u539f\u7406<\/h4>\n<\/p>\n<p><p>K\u8fd1\u90bb\u7b97\u6cd5\u7684\u6838\u5fc3\u662f\u8ddd\u79bb\u5ea6\u91cf\u3002\u5e38\u7528\u7684\u8ddd\u79bb\u5ea6\u91cf\u6709\u6b27\u6c0f\u8ddd\u79bb\u3001\u66fc\u54c8\u987f\u8ddd\u79bb\u548c\u95f5\u53ef\u592b\u65af\u57fa\u8ddd\u79bb\u7b49\u3002\u5047\u8bbe\u6837\u672c\u70b9\u4e3ax\uff0c\u8bad\u7ec3\u96c6\u4e2d\u7684\u70b9\u4e3ay1, y2, &#8230;, yN\uff0c\u8ddd\u79bb\u5ea6\u91cf\u4e3ad\uff0c\u5219x\u4e0eyi\u7684\u8ddd\u79bb\u4e3ad(x, yi)\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u7b97\u6cd5\u6b65\u9aa4<\/h4>\n<\/p>\n<ol>\n<li>\u9009\u62e9\u8ddd\u79bb\u5ea6\u91cf\u65b9\u5f0f\u3002<\/li>\n<li>\u8ba1\u7b97\u6837\u672c\u70b9x\u5230\u8bad\u7ec3\u96c6\u4e2d\u6240\u6709\u70b9\u7684\u8ddd\u79bb\u3002<\/li>\n<li>\u9009\u62e9\u8ddd\u79bb\u6700\u8fd1\u7684K\u4e2a\u70b9\u3002<\/li>\n<li>\u6839\u636e\u8fd9K\u4e2a\u70b9\u7684\u7c7b\u522b\uff0c\u91c7\u7528\u591a\u6570\u8868\u51b3\u7684\u65b9\u5f0f\u51b3\u5b9a\u6837\u672c\u70b9x\u7684\u7c7b\u522b\u3002<\/li>\n<\/ol>\n<p><h4>3\u3001\u4ee3\u7801\u793a\u4f8b<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.neighbors import KNeighborsClassifier<\/p>\n<h2><strong>\u52a0\u8f7d\u6570\u636e\u96c6<\/strong><\/h2>\n<p>from sklearn.datasets import load_iris<\/p>\n<p>data = load_iris()<\/p>\n<p>X, y = data.data, data.target<\/p>\n<h2><strong>\u5212\u5206\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6<\/strong><\/h2>\n<p>from sklearn.model_selection import tr<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>n_test_split<\/p>\n<p>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)<\/p>\n<h2><strong>\u521b\u5efaKNN\u5206\u7c7b\u5668<\/strong><\/h2>\n<p>knn = KNeighborsClassifier(n_neighbors=3)<\/p>\n<h2><strong>\u8bad\u7ec3\u6a21\u578b<\/strong><\/h2>\n<p>knn.fit(X_train, y_train)<\/p>\n<h2><strong>\u8fdb\u884c\u9884\u6d4b<\/strong><\/h2>\n<p>y_pred = knn.predict(X_test)<\/p>\n<h2><strong>\u8bc4\u4f30\u6a21\u578b<\/strong><\/h2>\n<p>from sklearn.metrics import accuracy_score<\/p>\n<p>print(&quot;Accuracy:&quot;, accuracy_score(y_test, y_pred))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u51b3\u7b56\u6811<\/h3>\n<\/p>\n<p><p>\u51b3\u7b56\u6811\u662f\u4e00\u79cd\u6811\u5f62\u7ed3\u6784\u7684\u5206\u7c7b\u7b97\u6cd5\u3002\u5b83\u901a\u8fc7\u9012\u5f52\u5730\u5c06\u6570\u636e\u96c6\u5212\u5206\u6210\u4e0d\u540c\u7684\u5b50\u96c6\uff0c\u6700\u7ec8\u5f62\u6210\u4e00\u4e2a\u6811\u5f62\u7ed3\u6784\uff0c\u7528\u4e8e\u5206\u7c7b\u3002\u51b3\u7b56\u6811\u7684\u4f18\u70b9\u662f\u76f4\u89c2\u6613\u61c2\uff0c\u80fd\u591f\u5904\u7406\u591a\u79cd\u7c7b\u578b\u7684\u6570\u636e\uff1b\u7f3a\u70b9\u662f\u5bb9\u6613\u8fc7\u62df\u5408\uff0c\u5bf9\u566a\u58f0\u654f\u611f\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u57fa\u672c\u539f\u7406<\/h4>\n<\/p>\n<p><p>\u51b3\u7b56\u6811\u7684\u6838\u5fc3\u662f\u9009\u62e9\u6700\u4f73\u7684\u5212\u5206\u5c5e\u6027\u3002\u5e38\u7528\u7684\u5212\u5206\u6807\u51c6\u6709\u4fe1\u606f\u589e\u76ca\u3001\u4fe1\u606f\u589e\u76ca\u6bd4\u548c\u57fa\u5c3c\u6307\u6570\u7b49\u3002\u5047\u8bbe\u6570\u636e\u96c6\u4e3aD\uff0c\u5c5e\u6027\u4e3aA\uff0c\u5212\u5206\u6807\u51c6\u4e3aS\uff0c\u5219A\u662f\u6700\u4f73\u5212\u5206\u5c5e\u6027\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u7b97\u6cd5\u6b65\u9aa4<\/h4>\n<\/p>\n<ol>\n<li>\u9009\u62e9\u6700\u4f73\u5212\u5206\u5c5e\u6027\u3002<\/li>\n<li>\u6839\u636e\u6700\u4f73\u5212\u5206\u5c5e\u6027\uff0c\u5c06\u6570\u636e\u96c6\u5212\u5206\u6210\u4e0d\u540c\u7684\u5b50\u96c6\u3002<\/li>\n<li>\u5bf9\u6bcf\u4e2a\u5b50\u96c6\u9012\u5f52\u5730\u6784\u5efa\u51b3\u7b56\u6811\uff0c\u76f4\u5230\u6ee1\u8db3\u505c\u6b62\u6761\u4ef6\u3002<\/li>\n<\/ol>\n<p><h4>3\u3001\u4ee3\u7801\u793a\u4f8b<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.tree import DecisionTreeClassifier<\/p>\n<h2><strong>\u52a0\u8f7d\u6570\u636e\u96c6<\/strong><\/h2>\n<p>from sklearn.datasets import load_iris<\/p>\n<p>data = load_iris()<\/p>\n<p>X, y = data.data, data.target<\/p>\n<h2><strong>\u5212\u5206\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6<\/strong><\/h2>\n<p>from sklearn.model_selection import train_test_split<\/p>\n<p>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)<\/p>\n<h2><strong>\u521b\u5efa\u51b3\u7b56\u6811\u5206\u7c7b\u5668<\/strong><\/h2>\n<p>dt = DecisionTreeClassifier()<\/p>\n<h2><strong>\u8bad\u7ec3\u6a21\u578b<\/strong><\/h2>\n<p>dt.fit(X_train, y_train)<\/p>\n<h2><strong>\u8fdb\u884c\u9884\u6d4b<\/strong><\/h2>\n<p>y_pred = dt.predict(X_test)<\/p>\n<h2><strong>\u8bc4\u4f30\u6a21\u578b<\/strong><\/h2>\n<p>from sklearn.metrics import accuracy_score<\/p>\n<p>print(&quot;Accuracy:&quot;, accuracy_score(y_test, y_pred))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u968f\u673a\u68ee\u6797<\/h3>\n<\/p>\n<p><p>\u968f\u673a\u68ee\u6797\u662f\u4e00\u79cd\u96c6\u6210\u5b66\u4e60\u65b9\u6cd5\uff0c\u901a\u8fc7\u6784\u5efa\u591a\u4e2a\u51b3\u7b56\u6811\uff0c\u5e76\u7ed3\u5408\u5b83\u4eec\u7684\u9884\u6d4b\u7ed3\u679c\u6765\u63d0\u9ad8\u5206\u7c7b\u7684\u51c6\u786e\u6027\u548c\u9c81\u68d2\u6027\u3002\u968f\u673a\u68ee\u6797\u7684\u4f18\u70b9\u662f\u80fd\u591f\u5904\u7406\u9ad8\u7ef4\u6570\u636e\uff0c\u5bf9\u6570\u636e\u4e2d\u7684\u566a\u58f0\u548c\u5f02\u5e38\u503c\u4e0d\u654f\u611f\uff1b\u7f3a\u70b9\u662f\u8ba1\u7b97\u91cf\u5927\uff0c\u8bad\u7ec3\u65f6\u95f4\u8f83\u957f\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u57fa\u672c\u539f\u7406<\/h4>\n<\/p>\n<p><p>\u968f\u673a\u68ee\u6797\u7684\u6838\u5fc3\u662f\u901a\u8fc7\u5f15\u5165\u968f\u673a\u6027\u6765\u6784\u5efa\u591a\u4e2a\u51b3\u7b56\u6811\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u5728\u6784\u5efa\u6bcf\u68f5\u51b3\u7b56\u6811\u65f6\uff0c\u968f\u673a\u9009\u62e9\u6837\u672c\u548c\u5c5e\u6027\u3002\u7136\u540e\uff0c\u901a\u8fc7\u591a\u6570\u8868\u51b3\u7684\u65b9\u5f0f\uff0c\u5c06\u591a\u4e2a\u51b3\u7b56\u6811\u7684\u9884\u6d4b\u7ed3\u679c\u7ed3\u5408\u8d77\u6765\uff0c\u5f97\u5230\u6700\u7ec8\u7684\u5206\u7c7b\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u7b97\u6cd5\u6b65\u9aa4<\/h4>\n<\/p>\n<ol>\n<li>\u968f\u673a\u9009\u62e9\u6837\u672c\u548c\u5c5e\u6027\uff0c\u6784\u5efa\u591a\u68f5\u51b3\u7b56\u6811\u3002<\/li>\n<li>\u5bf9\u6bcf\u68f5\u51b3\u7b56\u6811\u8fdb\u884c\u8bad\u7ec3\uff0c\u5f97\u5230\u5206\u7c7b\u7ed3\u679c\u3002<\/li>\n<li>\u901a\u8fc7\u591a\u6570\u8868\u51b3\u7684\u65b9\u5f0f\uff0c\u5c06\u591a\u4e2a\u51b3\u7b56\u6811\u7684\u9884\u6d4b\u7ed3\u679c\u7ed3\u5408\u8d77\u6765\uff0c\u5f97\u5230\u6700\u7ec8\u7684\u5206\u7c7b\u7ed3\u679c\u3002<\/li>\n<\/ol>\n<p><h4>3\u3001\u4ee3\u7801\u793a\u4f8b<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.ensemble import RandomForestClassifier<\/p>\n<h2><strong>\u52a0\u8f7d\u6570\u636e\u96c6<\/strong><\/h2>\n<p>from sklearn.datasets import load_iris<\/p>\n<p>data = load_iris()<\/p>\n<p>X, y = data.data, data.target<\/p>\n<h2><strong>\u5212\u5206\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6<\/strong><\/h2>\n<p>from sklearn.model_selection import train_test_split<\/p>\n<p>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)<\/p>\n<h2><strong>\u521b\u5efa\u968f\u673a\u68ee\u6797\u5206\u7c7b\u5668<\/strong><\/h2>\n<p>rf = RandomForestClassifier(n_estimators=100, random_state=42)<\/p>\n<h2><strong>\u8bad\u7ec3\u6a21\u578b<\/strong><\/h2>\n<p>rf.fit(X_train, y_train)<\/p>\n<h2><strong>\u8fdb\u884c\u9884\u6d4b<\/strong><\/h2>\n<p>y_pred = rf.predict(X_test)<\/p>\n<h2><strong>\u8bc4\u4f30\u6a21\u578b<\/strong><\/h2>\n<p>from sklearn.metrics import accuracy_score<\/p>\n<p>print(&quot;Accuracy:&quot;, accuracy_score(y_test, y_pred))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u652f\u6301\u5411\u91cf\u673a\uff08SVM\uff09<\/h3>\n<\/p>\n<p><p>\u652f\u6301\u5411\u91cf\u673a\u662f\u4e00\u79cd\u5f3a\u5927\u7684\u5206\u7c7b\u7b97\u6cd5\uff0c\u5c24\u5176\u9002\u7528\u4e8e\u9ad8\u7ef4\u6570\u636e\u3002\u5b83\u901a\u8fc7\u5bfb\u627e\u4e00\u4e2a\u6700\u4f18\u7684\u8d85\u5e73\u9762\uff0c\u5c06\u6570\u636e\u96c6\u5212\u5206\u6210\u4e0d\u540c\u7684\u7c7b\u522b\u3002\u652f\u6301\u5411\u91cf\u673a\u7684\u4f18\u70b9\u662f\u5206\u7c7b\u6548\u679c\u597d\uff0c\u80fd\u591f\u5904\u7406\u9ad8\u7ef4\u6570\u636e\uff1b\u7f3a\u70b9\u662f\u5bf9\u53c2\u6570\u654f\u611f\uff0c\u8ba1\u7b97\u91cf\u5927\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u57fa\u672c\u539f\u7406<\/h4>\n<\/p>\n<p><p>\u652f\u6301\u5411\u91cf\u673a\u7684\u6838\u5fc3\u662f\u5bfb\u627e\u4e00\u4e2a\u6700\u4f18\u7684\u8d85\u5e73\u9762\uff0c\u4f7f\u5f97\u4e0d\u540c\u7c7b\u522b\u7684\u6837\u672c\u70b9\u5c3d\u53ef\u80fd\u8fdc\u79bb\u8d85\u5e73\u9762\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u652f\u6301\u5411\u91cf\u673a\u901a\u8fc7\u4f18\u5316\u76ee\u6807\u51fd\u6570\uff0c\u627e\u5230\u4e00\u7ec4\u652f\u6301\u5411\u91cf\uff0c\u4f7f\u5f97\u5206\u7c7b\u95f4\u9694\u6700\u5927\u5316\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u7b97\u6cd5\u6b65\u9aa4<\/h4>\n<\/p>\n<ol>\n<li>\u9009\u62e9\u5408\u9002\u7684\u6838\u51fd\u6570\u3002<\/li>\n<li>\u6784\u5efa\u76ee\u6807\u51fd\u6570\uff0c\u5e76\u4f18\u5316\u76ee\u6807\u51fd\u6570\uff0c\u627e\u5230\u6700\u4f18\u7684\u8d85\u5e73\u9762\u3002<\/li>\n<li>\u6839\u636e\u6700\u4f18\u7684\u8d85\u5e73\u9762\uff0c\u5bf9\u6837\u672c\u8fdb\u884c\u5206\u7c7b\u3002<\/li>\n<\/ol>\n<p><h4>3\u3001\u4ee3\u7801\u793a\u4f8b<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.svm import SVC<\/p>\n<h2><strong>\u52a0\u8f7d\u6570\u636e\u96c6<\/strong><\/h2>\n<p>from sklearn.datasets import load_iris<\/p>\n<p>data = load_iris()<\/p>\n<p>X, y = data.data, data.target<\/p>\n<h2><strong>\u5212\u5206\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6<\/strong><\/h2>\n<p>from sklearn.model_selection import train_test_split<\/p>\n<p>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)<\/p>\n<h2><strong>\u521b\u5efa\u652f\u6301\u5411\u91cf\u673a\u5206\u7c7b\u5668<\/strong><\/h2>\n<p>svm = SVC(kernel=&#39;linear&#39;)<\/p>\n<h2><strong>\u8bad\u7ec3\u6a21\u578b<\/strong><\/h2>\n<p>svm.fit(X_train, y_train)<\/p>\n<h2><strong>\u8fdb\u884c\u9884\u6d4b<\/strong><\/h2>\n<p>y_pred = svm.predict(X_test)<\/p>\n<h2><strong>\u8bc4\u4f30\u6a21\u578b<\/strong><\/h2>\n<p>from sklearn.metrics import accuracy_score<\/p>\n<p>print(&quot;Accuracy:&quot;, accuracy_score(y_test, y_pred))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u903b\u8f91\u56de\u5f52<\/h3>\n<\/p>\n<p><p>\u903b\u8f91\u56de\u5f52\u662f\u4e00\u79cd\u5e7f\u6cdb\u4f7f\u7528\u7684\u5206\u7c7b\u7b97\u6cd5\uff0c\u5c24\u5176\u9002\u7528\u4e8e\u4e8c\u5206\u7c7b\u95ee\u9898\u3002\u5b83\u901a\u8fc7\u6784\u5efa\u4e00\u4e2a\u7ebf\u6027\u6a21\u578b\uff0c\u5e76\u4f7f\u7528\u903b\u8f91\u51fd\u6570\u5bf9\u7ebf\u6027\u6a21\u578b\u7684\u8f93\u51fa\u8fdb\u884c\u8f6c\u6362\uff0c\u5f97\u5230\u5206\u7c7b\u7ed3\u679c\u3002\u903b\u8f91\u56de\u5f52\u7684\u4f18\u70b9\u662f\u7b80\u5355\u6613\u61c2\uff0c\u8ba1\u7b97\u91cf\u5c0f\uff1b\u7f3a\u70b9\u662f\u5bf9\u7ebf\u6027\u5173\u7cfb\u7684\u6570\u636e\u6548\u679c\u8f83\u597d\uff0c\u5bf9\u975e\u7ebf\u6027\u5173\u7cfb\u7684\u6570\u636e\u6548\u679c\u8f83\u5dee\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u57fa\u672c\u539f\u7406<\/h4>\n<\/p>\n<p><p>\u903b\u8f91\u56de\u5f52\u7684\u6838\u5fc3\u662f\u6784\u5efa\u4e00\u4e2a\u7ebf\u6027\u6a21\u578b\uff0c\u5e76\u4f7f\u7528\u903b\u8f91\u51fd\u6570\u5bf9\u7ebf\u6027\u6a21\u578b\u7684\u8f93\u51fa\u8fdb\u884c\u8f6c\u6362\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u903b\u8f91\u56de\u5f52\u901a\u8fc7\u4f18\u5316\u76ee\u6807\u51fd\u6570\uff0c\u627e\u5230\u6700\u4f18\u7684\u53c2\u6570\uff0c\u4f7f\u5f97\u6a21\u578b\u7684\u9884\u6d4b\u7ed3\u679c\u5c3d\u53ef\u80fd\u63a5\u8fd1\u771f\u5b9e\u503c\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u7b97\u6cd5\u6b65\u9aa4<\/h4>\n<\/p>\n<ol>\n<li>\u6784\u5efa\u7ebf\u6027\u6a21\u578b\u3002<\/li>\n<li>\u4f7f\u7528\u903b\u8f91\u51fd\u6570\u5bf9\u7ebf\u6027\u6a21\u578b\u7684\u8f93\u51fa\u8fdb\u884c\u8f6c\u6362\u3002<\/li>\n<li>\u6784\u5efa\u76ee\u6807\u51fd\u6570\uff0c\u5e76\u4f18\u5316\u76ee\u6807\u51fd\u6570\uff0c\u627e\u5230\u6700\u4f18\u7684\u53c2\u6570\u3002<\/li>\n<li>\u6839\u636e\u6700\u4f18\u7684\u53c2\u6570\uff0c\u5bf9\u6837\u672c\u8fdb\u884c\u5206\u7c7b\u3002<\/li>\n<\/ol>\n<p><h4>3\u3001\u4ee3\u7801\u793a\u4f8b<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.linear_model import LogisticRegression<\/p>\n<h2><strong>\u52a0\u8f7d\u6570\u636e\u96c6<\/strong><\/h2>\n<p>from sklearn.datasets import load_iris<\/p>\n<p>data = load_iris()<\/p>\n<p>X, y = data.data, data.target<\/p>\n<h2><strong>\u5212\u5206\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6<\/strong><\/h2>\n<p>from sklearn.model_selection import train_test_split<\/p>\n<p>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)<\/p>\n<h2><strong>\u521b\u5efa\u903b\u8f91\u56de\u5f52\u5206\u7c7b\u5668<\/strong><\/h2>\n<p>lr = LogisticRegression()<\/p>\n<h2><strong>\u8bad\u7ec3\u6a21\u578b<\/strong><\/h2>\n<p>lr.fit(X_train, y_train)<\/p>\n<h2><strong>\u8fdb\u884c\u9884\u6d4b<\/strong><\/h2>\n<p>y_pred = lr.predict(X_test)<\/p>\n<h2><strong>\u8bc4\u4f30\u6a21\u578b<\/strong><\/h2>\n<p>from sklearn.metrics import accuracy_score<\/p>\n<p>print(&quot;Accuracy:&quot;, accuracy_score(y_test, y_pred))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u6734\u7d20\u8d1d\u53f6\u65af<\/h3>\n<\/p>\n<p><p>\u6734\u7d20\u8d1d\u53f6\u65af\u662f\u4e00\u79cd\u57fa\u4e8e\u8d1d\u53f6\u65af\u5b9a\u7406\u7684\u5206\u7c7b\u7b97\u6cd5\u3002\u5b83\u901a\u8fc7\u8ba1\u7b97\u6bcf\u4e2a\u7c7b\u522b\u7684\u540e\u9a8c\u6982\u7387\uff0c\u5e76\u9009\u62e9\u540e\u9a8c\u6982\u7387\u6700\u5927\u7684\u7c7b\u522b\uff0c\u4f5c\u4e3a\u6837\u672c\u7684\u7c7b\u522b\u3002\u6734\u7d20\u8d1d\u53f6\u65af\u7684\u4f18\u70b9\u662f\u7b80\u5355\u6613\u61c2\uff0c\u8ba1\u7b97\u91cf\u5c0f\uff1b\u7f3a\u70b9\u662f\u5047\u8bbe\u5c5e\u6027\u4e4b\u95f4\u76f8\u4e92\u72ec\u7acb\uff0c\u4e0d\u9002\u7528\u4e8e\u5c5e\u6027\u4e4b\u95f4\u6709\u8f83\u5f3a\u76f8\u5173\u6027\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u57fa\u672c\u539f\u7406<\/h4>\n<\/p>\n<p><p>\u6734\u7d20\u8d1d\u53f6\u65af\u7684\u6838\u5fc3\u662f\u8ba1\u7b97\u6bcf\u4e2a\u7c7b\u522b\u7684\u540e\u9a8c\u6982\u7387\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u6734\u7d20\u8d1d\u53f6\u65af\u901a\u8fc7\u8d1d\u53f6\u65af\u5b9a\u7406\uff0c\u8ba1\u7b97\u6837\u672c\u5c5e\u4e8e\u6bcf\u4e2a\u7c7b\u522b\u7684\u540e\u9a8c\u6982\u7387\uff0c\u5e76\u9009\u62e9\u540e\u9a8c\u6982\u7387\u6700\u5927\u7684\u7c7b\u522b\uff0c\u4f5c\u4e3a\u6837\u672c\u7684\u7c7b\u522b\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u7b97\u6cd5\u6b65\u9aa4<\/h4>\n<\/p>\n<ol>\n<li>\u8ba1\u7b97\u6bcf\u4e2a\u7c7b\u522b\u7684\u5148\u9a8c\u6982\u7387\u3002<\/li>\n<li>\u8ba1\u7b97\u6bcf\u4e2a\u5c5e\u6027\u5728\u6bcf\u4e2a\u7c7b\u522b\u4e0b\u7684\u6761\u4ef6\u6982\u7387\u3002<\/li>\n<li>\u6839\u636e\u8d1d\u53f6\u65af\u5b9a\u7406\uff0c\u8ba1\u7b97\u6bcf\u4e2a\u7c7b\u522b\u7684\u540e\u9a8c\u6982\u7387\u3002<\/li>\n<li>\u9009\u62e9\u540e\u9a8c\u6982\u7387\u6700\u5927\u7684\u7c7b\u522b\uff0c\u4f5c\u4e3a\u6837\u672c\u7684\u7c7b\u522b\u3002<\/li>\n<\/ol>\n<p><h4>3\u3001\u4ee3\u7801\u793a\u4f8b<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.naive_bayes import GaussianNB<\/p>\n<h2><strong>\u52a0\u8f7d\u6570\u636e\u96c6<\/strong><\/h2>\n<p>from sklearn.datasets import load_iris<\/p>\n<p>data = load_iris()<\/p>\n<p>X, y = data.data, data.target<\/p>\n<h2><strong>\u5212\u5206\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6<\/strong><\/h2>\n<p>from sklearn.model_selection import train_test_split<\/p>\n<p>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)<\/p>\n<h2><strong>\u521b\u5efa\u6734\u7d20\u8d1d\u53f6\u65af\u5206\u7c7b\u5668<\/strong><\/h2>\n<p>nb = GaussianNB()<\/p>\n<h2><strong>\u8bad\u7ec3\u6a21\u578b<\/strong><\/h2>\n<p>nb.fit(X_train, y_train)<\/p>\n<h2><strong>\u8fdb\u884c\u9884\u6d4b<\/strong><\/h2>\n<p>y_pred = nb.predict(X_test)<\/p>\n<h2><strong>\u8bc4\u4f30\u6a21\u578b<\/strong><\/h2>\n<p>from sklearn.metrics import accuracy_score<\/p>\n<p>print(&quot;Accuracy:&quot;, accuracy_score(y_test, y_pred))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e03\u3001\u795e\u7ecf\u7f51\u7edc<\/h3>\n<\/p>\n<p><p>\u795e\u7ecf\u7f51\u7edc\u662f\u4e00\u79cd\u590d\u6742\u7684\u5206\u7c7b\u7b97\u6cd5\uff0c\u5c24\u5176\u9002\u7528\u4e8e\u5904\u7406\u975e\u7ebf\u6027\u5173\u7cfb\u7684\u6570\u636e\u3002\u5b83\u901a\u8fc7\u6784\u5efa\u591a\u5c42\u795e\u7ecf\u5143\uff0c\u5e76\u4f7f\u7528\u6fc0\u6d3b\u51fd\u6570\u5bf9\u6bcf\u5c42\u795e\u7ecf\u5143\u7684\u8f93\u51fa\u8fdb\u884c\u8f6c\u6362\uff0c\u5f97\u5230\u5206\u7c7b\u7ed3\u679c\u3002\u795e\u7ecf\u7f51\u7edc\u7684\u4f18\u70b9\u662f\u80fd\u591f\u5904\u7406\u590d\u6742\u7684\u975e\u7ebf\u6027\u5173\u7cfb\uff1b\u7f3a\u70b9\u662f\u8ba1\u7b97\u91cf\u5927\uff0c\u8bad\u7ec3\u65f6\u95f4\u8f83\u957f\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u57fa\u672c\u539f\u7406<\/h4>\n<\/p>\n<p><p>\u795e\u7ecf\u7f51\u7edc\u7684\u6838\u5fc3\u662f\u6784\u5efa\u591a\u5c42\u795e\u7ecf\u5143\uff0c\u5e76\u4f7f\u7528\u6fc0\u6d3b\u51fd\u6570\u5bf9\u6bcf\u5c42\u795e\u7ecf\u5143\u7684\u8f93\u51fa\u8fdb\u884c\u8f6c\u6362\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u795e\u7ecf\u7f51\u7edc\u901a\u8fc7\u4f18\u5316\u76ee\u6807\u51fd\u6570\uff0c\u627e\u5230\u6700\u4f18\u7684\u53c2\u6570\uff0c\u4f7f\u5f97\u6a21\u578b\u7684\u9884\u6d4b\u7ed3\u679c\u5c3d\u53ef\u80fd\u63a5\u8fd1\u771f\u5b9e\u503c\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u7b97\u6cd5\u6b65\u9aa4<\/h4>\n<\/p>\n<ol>\n<li>\u6784\u5efa\u795e\u7ecf\u7f51\u7edc\u7ed3\u6784\u3002<\/li>\n<li>\u4f7f\u7528\u6fc0\u6d3b\u51fd\u6570\u5bf9\u6bcf\u5c42\u795e\u7ecf\u5143\u7684\u8f93\u51fa\u8fdb\u884c\u8f6c\u6362\u3002<\/li>\n<li>\u6784\u5efa\u76ee\u6807\u51fd\u6570\uff0c\u5e76\u4f7f\u7528\u53cd\u5411\u4f20\u64ad\u7b97\u6cd5\u4f18\u5316\u76ee\u6807\u51fd\u6570\uff0c\u627e\u5230\u6700\u4f18\u7684\u53c2\u6570\u3002<\/li>\n<li>\u6839\u636e\u6700\u4f18\u7684\u53c2\u6570\uff0c\u5bf9\u6837\u672c\u8fdb\u884c\u5206\u7c7b\u3002<\/li>\n<\/ol>\n<p><h4>3\u3001\u4ee3\u7801\u793a\u4f8b<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.neural_network import MLPClassifier<\/p>\n<h2><strong>\u52a0\u8f7d\u6570\u636e\u96c6<\/strong><\/h2>\n<p>from sklearn.datasets import load_iris<\/p>\n<p>data = load_iris()<\/p>\n<p>X, y = data.data, data.target<\/p>\n<h2><strong>\u5212\u5206\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6<\/strong><\/h2>\n<p>from sklearn.model_selection import train_test_split<\/p>\n<p>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)<\/p>\n<h2><strong>\u521b\u5efa\u795e\u7ecf\u7f51\u7edc\u5206\u7c7b\u5668<\/strong><\/h2>\n<p>mlp = MLPClassifier(hidden_layer_sizes=(100,), max_iter=300, random_state=42)<\/p>\n<h2><strong>\u8bad\u7ec3\u6a21\u578b<\/strong><\/h2>\n<p>mlp.fit(X_train, y_train)<\/p>\n<h2><strong>\u8fdb\u884c\u9884\u6d4b<\/strong><\/h2>\n<p>y_pred = mlp.predict(X_test)<\/p>\n<h2><strong>\u8bc4\u4f30\u6a21\u578b<\/strong><\/h2>\n<p>from sklearn.metrics import accuracy_score<\/p>\n<p>print(&quot;Accuracy:&quot;, accuracy_score(y_test, y_pred))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516b\u3001\u6a21\u578b\u8bc4\u4f30<\/h3>\n<\/p>\n<p><p>\u5728\u5206\u7c7b\u95ee\u9898\u4e2d\uff0c\u6a21\u578b\u8bc4\u4f30\u662f\u975e\u5e38\u91cd\u8981\u7684\u4e00\u6b65\u3002\u5e38\u7528\u7684\u8bc4\u4f30\u6307\u6807\u6709\u51c6\u786e\u7387\u3001\u7cbe\u786e\u7387\u3001\u53ec\u56de\u7387\u548cF1\u5f97\u5206\u7b49\u3002\u901a\u8fc7\u8fd9\u4e9b\u8bc4\u4f30\u6307\u6807\uff0c\u53ef\u4ee5\u8861\u91cf\u6a21\u578b\u7684\u5206\u7c7b\u6548\u679c\uff0c\u9009\u62e9\u6700\u4f18\u7684\u6a21\u578b\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u51c6\u786e\u7387<\/h4>\n<\/p>\n<p><p>\u51c6\u786e\u7387\u662f\u6307\u5206\u7c7b\u6b63\u786e\u7684\u6837\u672c\u6570\u5360\u603b\u6837\u672c\u6570\u7684\u6bd4\u4f8b\u3002\u51c6\u786e\u7387\u7684\u8ba1\u7b97\u516c\u5f0f\u4e3a\uff1a<\/p>\n<\/p>\n<p><p>$$<\/p>\n<p>Accuracy = \\frac{TP + TN}{TP + TN + FP + FN}<\/p>\n<p>$$<\/p>\n<\/p>\n<p><p>\u5176\u4e2d\uff0cTP\u8868\u793a\u771f\u6b63\u7c7b\uff0cTN\u8868\u793a\u771f\u8d1f\u7c7b\uff0cFP\u8868\u793a\u5047\u6b63\u7c7b\uff0cFN\u8868\u793a\u5047\u8d1f\u7c7b\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u7cbe\u786e\u7387<\/h4>\n<\/p>\n<p><p>\u7cbe\u786e\u7387\u662f\u6307\u5206\u7c7b\u6b63\u786e\u7684\u6b63\u7c7b\u6837\u672c\u6570\u5360\u6240\u6709\u88ab\u5206\u7c7b\u4e3a\u6b63\u7c7b\u7684\u6837\u672c\u6570\u7684\u6bd4\u4f8b\u3002\u7cbe\u786e\u7387\u7684\u8ba1\u7b97\u516c\u5f0f\u4e3a\uff1a<\/p>\n<\/p>\n<p><p>$$<\/p>\n<p>Precision = \\frac{TP}{TP + FP}<\/p>\n<p>$$<\/p>\n<\/p>\n<p><h4>3\u3001\u53ec\u56de\u7387<\/h4>\n<\/p>\n<p><p>\u53ec\u56de\u7387\u662f\u6307\u5206\u7c7b\u6b63\u786e\u7684\u6b63\u7c7b\u6837\u672c\u6570\u5360\u6240\u6709\u5b9e\u9645\u4e3a\u6b63\u7c7b\u7684\u6837\u672c\u6570\u7684\u6bd4\u4f8b\u3002\u53ec\u56de\u7387\u7684\u8ba1\u7b97\u516c\u5f0f\u4e3a\uff1a<\/p>\n<\/p>\n<p><p>$$<\/p>\n<p>Recall = \\frac{TP}{TP + FN}<\/p>\n<p>$$<\/p>\n<\/p>\n<p><h4>4\u3001F1\u5f97\u5206<\/h4>\n<\/p>\n<p><p>F1\u5f97\u5206\u662f\u7cbe\u786e\u7387\u548c\u53ec\u56de\u7387\u7684\u8c03\u548c\u5e73\u5747\u6570\u3002F1\u5f97\u5206\u7684\u8ba1\u7b97\u516c\u5f0f\u4e3a\uff1a<\/p>\n<\/p>\n<p><p>$$<\/p>\n<p>F1 = 2 \\times \\frac{Precision \\times Recall}{Precision + Recall}<\/p>\n<p>$$<\/p>\n<\/p>\n<p><h4>5\u3001\u4ee3\u7801\u793a\u4f8b<\/h4>\n<\/p>\n<p><pre><code class=\"language-python\">from sklearn.metrics import classification_report<\/p>\n<h2><strong>\u52a0\u8f7d\u6570\u636e\u96c6<\/strong><\/h2>\n<p>from sklearn.datasets import load_iris<\/p>\n<p>data = load_iris()<\/p>\n<p>X, y = data.data, data.target<\/p>\n<h2><strong>\u5212\u5206\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6<\/strong><\/h2>\n<p>from sklearn.model_selection import train_test_split<\/p>\n<p>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)<\/p>\n<h2><strong>\u521b\u5efa\u5206\u7c7b\u5668\uff08\u4ee5\u968f\u673a\u68ee\u6797\u4e3a\u4f8b\uff09<\/strong><\/h2>\n<p>clf = RandomForestClassifier(n_estimators=100, random_state=42)<\/p>\n<h2><strong>\u8bad\u7ec3\u6a21\u578b<\/strong><\/h2>\n<p>clf.fit(X_train, y_train)<\/p>\n<h2><strong>\u8fdb\u884c\u9884\u6d4b<\/strong><\/h2>\n<p>y_pred = clf.predict(X_test)<\/p>\n<h2><strong>\u8bc4\u4f30\u6a21\u578b<\/strong><\/h2>\n<p>print(classification_report(y_test, y_pred))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\u548c\u4ee3\u7801\u793a\u4f8b\uff0c\u53ef\u4ee5\u770b\u5230Python\u8fdb\u884c\u5206\u7c7b\u5224\u522b\u7684\u65b9\u6cd5\u53ca\u5176\u5b9e\u73b0\u8fc7\u7a0b\u3002\u4e0d\u540c\u7684\u5206\u7c7b\u7b97\u6cd5\u6709\u4e0d\u540c\u7684\u7279\u70b9\u548c\u9002\u7528\u573a\u666f\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u95ee\u9898\u9009\u62e9\u5408\u9002\u7684\u7b97\u6cd5\uff0c\u5e76\u901a\u8fc7\u6a21\u578b\u8bc4\u4f30\u9009\u62e9\u6700\u4f18\u7684\u6a21\u578b\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684\u5206\u7c7b\u7b97\u6cd5\u8fdb\u884c\u5224\u522b\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u6709\u591a\u79cd\u5206\u7c7b\u7b97\u6cd5\u53ef\u4f9b\u9009\u62e9\uff0c\u5982\u51b3\u7b56\u6811\u3001\u968f\u673a\u68ee\u6797\u3001\u652f\u6301\u5411\u91cf\u673a\uff08SVM\uff09\u3001K\u8fd1\u90bb\uff08KNN\uff09\u7b49\u3002\u9009\u62e9\u5408\u9002\u7684\u7b97\u6cd5\u901a\u5e38\u53d6\u51b3\u4e8e\u6570\u636e\u7684\u7279\u6027\u548c\u5177\u4f53\u7684\u5e94\u7528\u573a\u666f\u3002\u4f8b\u5982\uff0c\u51b3\u7b56\u6811\u6613\u4e8e\u7406\u89e3\u548c\u53ef\u89c6\u5316\uff0c\u4f46\u5728\u5904\u7406\u9ad8\u7ef4\u6570\u636e\u65f6\u53ef\u80fd\u8868\u73b0\u4e0d\u4f73\uff1b\u800c\u968f\u673a\u68ee\u6797\u5219\u66f4\u5177\u9c81\u68d2\u6027\uff0c\u9002\u5408\u5904\u7406\u566a\u58f0\u8f83\u5927\u7684\u6570\u636e\u3002\u8bc4\u4f30\u6a21\u578b\u6027\u80fd\u7684\u6307\u6807\u4e5f\u975e\u5e38\u91cd\u8981\uff0c\u4f8b\u5982\u51c6\u786e\u7387\u3001\u53ec\u56de\u7387\u548cF1\u5206\u6570\u7b49\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u9009\u62e9\u6700\u4f73\u7b97\u6cd5\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u9884\u5904\u7406\u6570\u636e\u4ee5\u63d0\u9ad8\u5206\u7c7b\u6027\u80fd\uff1f<\/strong><br \/>\u6570\u636e\u9884\u5904\u7406\u5728\u5206\u7c7b\u4efb\u52a1\u4e2d\u81f3\u5173\u91cd\u8981\u3002\u5e38\u89c1\u7684\u6b65\u9aa4\u5305\u62ec\u6570\u636e\u6e05\u6d17\u3001\u7f3a\u5931\u503c\u5904\u7406\u3001\u7279\u5f81\u7f29\u653e\uff08\u5982\u6807\u51c6\u5316\u6216\u5f52\u4e00\u5316\uff09\u3001\u7c7b\u522b\u7f16\u7801\uff08\u5982\u72ec\u70ed\u7f16\u7801\uff09\u7b49\u3002\u4f7f\u7528<code>pandas<\/code>\u5e93\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u6570\u636e\u6e05\u7406\uff0c\u800c<code>scikit-learn<\/code>\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u9884\u5904\u7406\u5de5\u5177\uff0c\u4f8b\u5982<code>StandardScaler<\/code>\u548c<code>OneHotEncoder<\/code>\u3002\u901a\u8fc7\u6709\u6548\u7684\u9884\u5904\u7406\uff0c\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u5206\u7c7b\u7b97\u6cd5\u7684\u6027\u80fd\u548c\u51c6\u786e\u6027\u3002<\/p>\n<p><strong>\u5982\u4f55\u8bc4\u4f30\u5206\u7c7b\u6a21\u578b\u7684\u6548\u679c\uff1f<\/strong><br \/>\u8bc4\u4f30\u5206\u7c7b\u6a21\u578b\u7684\u6548\u679c\u901a\u5e38\u9700\u8981\u4f7f\u7528\u4ea4\u53c9\u9a8c\u8bc1\u3001\u6df7\u6dc6\u77e9\u9635\u3001ROC\u66f2\u7ebf\u53ca\u5176AUC\u503c\u7b49\u65b9\u6cd5\u3002\u4ea4\u53c9\u9a8c\u8bc1\u53ef\u4ee5\u5e2e\u52a9\u4f60\u4e86\u89e3\u6a21\u578b\u5728\u4e0d\u540c\u6570\u636e\u96c6\u4e0a\u7684\u8868\u73b0\uff0c\u4ece\u800c\u907f\u514d\u8fc7\u62df\u5408\u3002\u6df7\u6dc6\u77e9\u9635\u5219\u63d0\u4f9b\u4e86\u771f\u5b9e\u6807\u7b7e\u4e0e\u9884\u6d4b\u6807\u7b7e\u7684\u5bf9\u6bd4\uff0c\u4fbf\u4e8e\u89c2\u5bdf\u6a21\u578b\u7684\u5206\u7c7b\u6548\u679c\u3002ROC\u66f2\u7ebf\u80fd\u591f\u76f4\u89c2\u5730\u663e\u793a\u5206\u7c7b\u5668\u7684\u6027\u80fd\uff0cAUC\u503c\u8d8a\u63a5\u8fd11\uff0c\u6a21\u578b\u7684\u6027\u80fd\u8d8a\u597d\u3002\u4f7f\u7528<code>scikit-learn<\/code>\u5e93\u4e2d\u7684\u76f8\u5173\u51fd\u6570\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u8fd9\u4e9b\u8bc4\u4f30\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u8fdb\u884c\u5206\u7c7b\u5224\u522b\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5982\uff1aK\u8fd1\u90bb\u7b97\u6cd5\uff08KNN\uff09\u3001\u51b3\u7b56\u6811\u3001\u968f\u673a\u68ee\u6797\u3001\u652f\u6301\u5411\u91cf\u673a\uff08SVM\uff09\u3001\u903b\u8f91\u56de [&hellip;]","protected":false},"author":3,"featured_media":1187486,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1187477"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1187477"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1187477\/revisions"}],"predecessor-version":[{"id":1187490,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1187477\/revisions\/1187490"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1187486"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1187477"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1187477"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1187477"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}