{"id":1152501,"date":"2025-01-13T17:26:20","date_gmt":"2025-01-13T09:26:20","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1152501.html"},"modified":"2025-01-13T17:26:22","modified_gmt":"2025-01-13T09:26:22","slug":"python%e5%a6%82%e4%bd%95%e7%94%a8%e9%80%bb%e8%be%91%e5%9b%9e%e5%bd%92","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1152501.html","title":{"rendered":"Python\u5982\u4f55\u7528\u903b\u8f91\u56de\u5f52"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25182459\/2750b30a-715c-48bb-803b-a31aa9a1865f.webp\" alt=\"Python\u5982\u4f55\u7528\u903b\u8f91\u56de\u5f52\" \/><\/p>\n<p><p> <strong>Python\u4e2d\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528scikit-learn\u5e93\u6765\u5b9e\u73b0\u903b\u8f91\u56de\u5f52\u3001\u903b\u8f91\u56de\u5f52\u662f\u4e00\u79cd\u7528\u4e8e\u5206\u7c7b\u95ee\u9898\u7684\u7edf\u8ba1\u65b9\u6cd5\u3001\u5b83\u901a\u8fc7\u4f30\u8ba1\u4e8b\u4ef6\u53d1\u751f\u7684\u6982\u7387\u6765\u8fdb\u884c\u5206\u7c7b\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u903b\u8f91\u56de\u5f52\u9002\u7528\u4e8e\u4e8c\u5206\u7c7b\u95ee\u9898\uff0c\u5373\u76ee\u6807\u53d8\u91cf\u53ea\u6709\u4e24\u4e2a\u53ef\u80fd\u7684\u53d6\u503c\uff0c\u4f8b\u5982\u662f\u5426\u60a3\u75c5\u3001\u662f\u5426\u8d2d\u4e70\u7b49\u3002\u5b83\u901a\u8fc7\u5b66\u4e60\u6570\u636e\u7684\u7279\u5f81\u548c\u76ee\u6807\u53d8\u91cf\u4e4b\u95f4\u7684\u5173\u7cfb\uff0c\u5efa\u7acb\u4e00\u4e2a\u56de\u5f52\u6a21\u578b\uff0c\u5e76\u4f7f\u7528\u8be5\u6a21\u578b\u5bf9\u65b0\u7684\u6570\u636e\u8fdb\u884c\u9884\u6d4b\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u63cf\u8ff0\u5982\u4f55\u5728Python\u4e2d\u4f7f\u7528\u903b\u8f91\u56de\u5f52\u8fdb\u884c\u5206\u7c7b\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5bfc\u5165\u5fc5\u8981\u7684\u5e93<\/h3>\n<\/p>\n<p><p>\u5728\u4f7f\u7528\u903b\u8f91\u56de\u5f52\u4e4b\u524d\uff0c\u9700\u8981\u5bfc\u5165\u4e00\u4e9b\u5fc5\u8981\u7684\u5e93\u3002\u8fd9\u4e9b\u5e93\u5305\u62ecNumPy\uff08\u7528\u4e8e\u6570\u503c\u8ba1\u7b97\uff09\u3001Pandas\uff08\u7528\u4e8e\u6570\u636e\u5904\u7406\uff09\u3001Matplotlib\uff08\u7528\u4e8e\u6570\u636e\u53ef\u89c6\u5316\uff09\u548cscikit-learn\uff08\u7528\u4e8e\u6784\u5efa\u548c\u8bc4\u4f30<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u6a21\u578b\uff09\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>import pandas as pd<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\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>from sklearn.linear_model import LogisticRegression<\/p>\n<p>from sklearn.metrics import accuracy_score, confusion_matrix, classification_report<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e8c\u3001\u52a0\u8f7d\u548c\u51c6\u5907\u6570\u636e<\/h3>\n<\/p>\n<p><p>\u5728\u8fdb\u884c\u903b\u8f91\u56de\u5f52\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u52a0\u8f7d\u548c\u51c6\u5907\u6570\u636e\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u4f1a\u5c06\u6570\u636e\u5206\u4e3a\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6\uff0c\u4ee5\u4fbf\u8bc4\u4f30\u6a21\u578b\u7684\u6027\u80fd\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u793a\u4f8b\u6570\u636e\u96c6<\/p>\n<p>data = pd.read_csv(&#39;data.csv&#39;)<\/p>\n<h2><strong>\u67e5\u770b\u6570\u636e\u96c6\u57fa\u672c\u4fe1\u606f<\/strong><\/h2>\n<p>print(data.head())<\/p>\n<p>print(data.info())<\/p>\n<p>print(data.describe())<\/p>\n<h2><strong>\u5206\u79bb\u7279\u5f81\u53d8\u91cf\u548c\u76ee\u6807\u53d8\u91cf<\/strong><\/h2>\n<p>X = data.drop(&#39;target&#39;, axis=1)<\/p>\n<p>y = data[&#39;target&#39;]<\/p>\n<h2><strong>\u5206\u5272\u6570\u636e\u96c6\u4e3a\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6<\/strong><\/h2>\n<p>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u6784\u5efa\u548c\u8bad\u7ec3\u903b\u8f91\u56de\u5f52\u6a21\u578b<\/h3>\n<\/p>\n<p><p>\u5728\u51c6\u5907\u597d\u6570\u636e\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528scikit-learn\u4e2d\u7684LogisticRegression\u7c7b\u6765\u6784\u5efa\u548c\u8bad\u7ec3\u903b\u8f91\u56de\u5f52\u6a21\u578b\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u521b\u5efa\u903b\u8f91\u56de\u5f52\u6a21\u578b<\/p>\n<p>model = LogisticRegression()<\/p>\n<h2><strong>\u8bad\u7ec3\u6a21\u578b<\/strong><\/h2>\n<p>model.fit(X_train, y_train)<\/p>\n<h2><strong>\u9884\u6d4b\u6d4b\u8bd5\u96c6<\/strong><\/h2>\n<p>y_pred = model.predict(X_test)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u56db\u3001\u8bc4\u4f30\u6a21\u578b\u6027\u80fd<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u8bc4\u4f30\u6a21\u578b\u7684\u6027\u80fd\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u5e38\u89c1\u7684\u8bc4\u4f30\u6307\u6807\uff0c\u4f8b\u5982\u51c6\u786e\u7387\u3001\u6df7\u6dc6\u77e9\u9635\u548c\u5206\u7c7b\u62a5\u544a\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8ba1\u7b97\u51c6\u786e\u7387<\/p>\n<p>accuracy = accuracy_score(y_test, y_pred)<\/p>\n<p>print(f&#39;Accuracy: {accuracy:.2f}&#39;)<\/p>\n<h2><strong>\u6df7\u6dc6\u77e9\u9635<\/strong><\/h2>\n<p>conf_matrix = confusion_matrix(y_test, y_pred)<\/p>\n<p>print(&#39;Confusion Matrix:&#39;)<\/p>\n<p>print(conf_matrix)<\/p>\n<h2><strong>\u5206\u7c7b\u62a5\u544a<\/strong><\/h2>\n<p>class_report = classification_report(y_test, y_pred)<\/p>\n<p>print(&#39;Classification Report:&#39;)<\/p>\n<p>print(class_report)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u53ef\u89c6\u5316\u7ed3\u679c<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u66f4\u597d\u5730\u7406\u89e3\u6a21\u578b\u7684\u6027\u80fd\uff0c\u6211\u4eec\u53ef\u4ee5\u53ef\u89c6\u5316\u4e00\u4e9b\u7ed3\u679c\uff0c\u4f8b\u5982\u6df7\u6dc6\u77e9\u9635\u548cROC\u66f2\u7ebf\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import seaborn as sns<\/p>\n<p>from sklearn.metrics import roc_curve, roc_auc_score<\/p>\n<h2><strong>\u53ef\u89c6\u5316\u6df7\u6dc6\u77e9\u9635<\/strong><\/h2>\n<p>sns.heatmap(conf_matrix, annot=True, fmt=&#39;d&#39;, cmap=&#39;Blues&#39;)<\/p>\n<p>plt.title(&#39;Confusion Matrix&#39;)<\/p>\n<p>plt.xlabel(&#39;Predicted&#39;)<\/p>\n<p>plt.ylabel(&#39;Actual&#39;)<\/p>\n<p>plt.show()<\/p>\n<h2><strong>\u8ba1\u7b97ROC\u66f2\u7ebf\u548cAUC\u503c<\/strong><\/h2>\n<p>fpr, tpr, thresholds = roc_curve(y_test, model.predict_proba(X_test)[:,1])<\/p>\n<p>roc_auc = roc_auc_score(y_test, y_pred)<\/p>\n<h2><strong>\u53ef\u89c6\u5316ROC\u66f2\u7ebf<\/strong><\/h2>\n<p>plt.plot(fpr, tpr, label=f&#39;ROC curve (area = {roc_auc:.2f})&#39;)<\/p>\n<p>plt.plot([0, 1], [0, 1], &#39;k--&#39;)<\/p>\n<p>plt.xlabel(&#39;False Positive Rate&#39;)<\/p>\n<p>plt.ylabel(&#39;True Positive Rate&#39;)<\/p>\n<p>plt.title(&#39;Receiver Operating Characteristic (ROC) Curve&#39;)<\/p>\n<p>plt.legend(loc=&#39;lower right&#39;)<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u5904\u7406\u4e0d\u5e73\u8861\u6570\u636e<\/h3>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u76ee\u6807\u53d8\u91cf\u7684\u4e0d\u5e73\u8861\u6570\u636e\u96c6\u53ef\u80fd\u4f1a\u5f71\u54cd\u6a21\u578b\u7684\u6027\u80fd\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\u6765\u5904\u7406\u4e0d\u5e73\u8861\u6570\u636e\uff1a<\/p>\n<\/p>\n<ol>\n<li><strong>\u8c03\u6574\u7c7b\u6743\u91cd<\/strong>\uff1a\u5728\u903b\u8f91\u56de\u5f52\u6a21\u578b\u4e2d\u53ef\u4ee5\u8c03\u6574\u7c7b\u7684\u6743\u91cd\uff0c\u4f7f\u5f97\u6a21\u578b\u66f4\u52a0\u5173\u6ce8\u5c11\u6570\u7c7b\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">model = LogisticRegression(class_weight=&#39;balanced&#39;)<\/p>\n<p>model.fit(X_train, y_train)<\/p>\n<p>y_pred = model.predict(X_test)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u8fc7\u91c7\u6837\u548c\u6b20\u91c7\u6837<\/strong>\uff1a\u4f7f\u7528\u8fc7\u91c7\u6837\u6280\u672f\u589e\u52a0\u5c11\u6570\u7c7b\u6837\u672c\uff0c\u6216\u8005\u4f7f\u7528\u6b20\u91c7\u6837\u6280\u672f\u51cf\u5c11\u591a\u6570\u7c7b\u6837\u672c\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">from imblearn.over_sampling import SMOTE<\/p>\n<p>from imblearn.under_sampling import RandomUnderSampler<\/p>\n<h2><strong>\u8fc7\u91c7\u6837<\/strong><\/h2>\n<p>smote = SMOTE()<\/p>\n<p>X_train_res, y_train_res = smote.fit_resample(X_train, y_train)<\/p>\n<h2><strong>\u6b20\u91c7\u6837<\/strong><\/h2>\n<p>undersample = RandomUnderSampler()<\/p>\n<p>X_train_res, y_train_res = undersample.fit_resample(X_train, y_train)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e03\u3001\u6a21\u578b\u8c03\u53c2<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u8fdb\u4e00\u6b65\u63d0\u9ad8\u6a21\u578b\u7684\u6027\u80fd\uff0c\u6211\u4eec\u53ef\u4ee5\u5bf9\u903b\u8f91\u56de\u5f52\u6a21\u578b\u8fdb\u884c\u8c03\u53c2\u3002\u5e38\u89c1\u7684\u8c03\u53c2\u65b9\u6cd5\u5305\u62ec\u7f51\u683c\u641c\u7d22\u548c\u968f\u673a\u641c\u7d22\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u7f51\u683c\u641c\u7d22<\/strong>\uff1a\u901a\u8fc7\u7a77\u4e3e\u6cd5\u641c\u7d22\u6700\u4f18\u53c2\u6570\u7ec4\u5408\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">from sklearn.model_selection import GridSearchCV<\/p>\n<h2><strong>\u5b9a\u4e49\u53c2\u6570\u7f51\u683c<\/strong><\/h2>\n<p>param_grid = {&#39;C&#39;: [0.1, 1, 10, 100], &#39;solver&#39;: [&#39;liblinear&#39;, &#39;saga&#39;]}<\/p>\n<h2><strong>\u521b\u5efa\u7f51\u683c\u641c\u7d22\u5bf9\u8c61<\/strong><\/h2>\n<p>grid_search = GridSearchCV(LogisticRegression(), param_grid, cv=5, scoring=&#39;accuracy&#39;)<\/p>\n<h2><strong>\u8bad\u7ec3\u6a21\u578b<\/strong><\/h2>\n<p>grid_search.fit(X_train, y_train)<\/p>\n<h2><strong>\u8f93\u51fa\u6700\u4f18\u53c2\u6570<\/strong><\/h2>\n<p>print(&#39;Best Parameters:&#39;, grid_search.best_params_)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u968f\u673a\u641c\u7d22<\/strong>\uff1a\u901a\u8fc7\u968f\u673a\u62bd\u6837\u641c\u7d22\u6700\u4f18\u53c2\u6570\u7ec4\u5408\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">from sklearn.model_selection import RandomizedSearchCV<\/p>\n<h2><strong>\u5b9a\u4e49\u53c2\u6570\u5206\u5e03<\/strong><\/h2>\n<p>param_dist = {&#39;C&#39;: [0.1, 1, 10, 100], &#39;solver&#39;: [&#39;liblinear&#39;, &#39;saga&#39;]}<\/p>\n<h2><strong>\u521b\u5efa\u968f\u673a\u641c\u7d22\u5bf9\u8c61<\/strong><\/h2>\n<p>random_search = RandomizedSearchCV(LogisticRegression(), param_dist, cv=5, scoring=&#39;accuracy&#39;, n_iter=10, random_state=42)<\/p>\n<h2><strong>\u8bad\u7ec3\u6a21\u578b<\/strong><\/h2>\n<p>random_search.fit(X_train, y_train)<\/p>\n<h2><strong>\u8f93\u51fa\u6700\u4f18\u53c2\u6570<\/strong><\/h2>\n<p>print(&#39;Best Parameters:&#39;, random_search.best_params_)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516b\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u6211\u4eec\u8be6\u7ec6\u63cf\u8ff0\u4e86\u5982\u4f55\u5728Python\u4e2d\u4f7f\u7528\u903b\u8f91\u56de\u5f52\u8fdb\u884c\u5206\u7c7b\uff0c\u5305\u62ec\u5bfc\u5165\u5fc5\u8981\u7684\u5e93\u3001\u52a0\u8f7d\u548c\u51c6\u5907\u6570\u636e\u3001\u6784\u5efa\u548c\u8bad\u7ec3\u6a21\u578b\u3001\u8bc4\u4f30\u6a21\u578b\u6027\u80fd\u3001\u53ef\u89c6\u5316\u7ed3\u679c\u3001\u5904\u7406\u4e0d\u5e73\u8861\u6570\u636e\u548c\u6a21\u578b\u8c03\u53c2\u3002\u903b\u8f91\u56de\u5f52\u662f\u4e00\u79cd\u7b80\u5355\u800c\u6709\u6548\u7684\u5206\u7c7b\u65b9\u6cd5\uff0c\u9002\u7528\u4e8e\u5404\u79cd\u4e8c\u5206\u7c7b\u95ee\u9898\u3002\u901a\u8fc7\u5408\u7406\u7684\u6570\u636e\u51c6\u5907\u548c\u6a21\u578b\u8c03\u53c2\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u63d0\u9ad8\u6a21\u578b\u7684\u6027\u80fd\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u903b\u8f91\u56de\u5f52\u53ef\u4ee5\u7ed3\u5408\u5176\u4ed6\u673a\u5668\u5b66\u4e60\u65b9\u6cd5\uff0c\u5982\u51b3\u7b56\u6811\u3001\u652f\u6301\u5411\u91cf\u673a\u548c\u795e\u7ecf\u7f51\u7edc\uff0c\u6784\u5efa\u66f4\u4e3a\u590d\u6742\u548c\u51c6\u786e\u7684\u5206\u7c7b\u6a21\u578b\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5b9e\u73b0\u903b\u8f91\u56de\u5f52\u6a21\u578b\uff1f<\/strong><br \/>\u8981\u5728Python\u4e2d\u5b9e\u73b0\u903b\u8f91\u56de\u5f52\u6a21\u578b\uff0c\u901a\u5e38\u4f7f\u7528<code>scikit-learn<\/code>\u5e93\u3002\u9996\u5148\uff0c\u786e\u4fdd\u5b89\u88c5\u4e86\u8be5\u5e93\u3002\u7136\u540e\uff0c\u5bfc\u5165\u6240\u9700\u7684\u6a21\u5757\uff0c\u52a0\u8f7d\u6570\u636e\u96c6\uff0c\u8fdb\u884c\u6570\u636e\u9884\u5904\u7406\uff08\u5982\u6807\u51c6\u5316\u3001\u7f3a\u5931\u503c\u5904\u7406\u7b49\uff09\uff0c\u63a5\u7740\u4f7f\u7528<code>LogisticRegression<\/code>\u7c7b\u521b\u5efa\u6a21\u578b\uff0c\u5e76\u8c03\u7528<code>fit<\/code>\u65b9\u6cd5\u8fdb\u884c\u8bad\u7ec3\u3002\u6700\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528<code>predict<\/code>\u65b9\u6cd5\u8fdb\u884c\u9884\u6d4b\uff0c\u5e76\u901a\u8fc7\u4e00\u4e9b\u8bc4\u4f30\u6307\u6807\u5982\u51c6\u786e\u7387\u3001\u6df7\u6dc6\u77e9\u9635\u7b49\u6765\u68c0\u9a8c\u6a21\u578b\u6548\u679c\u3002<\/p>\n<p><strong>\u903b\u8f91\u56de\u5f52\u9002\u5408\u5904\u7406\u54ea\u4e9b\u7c7b\u578b\u7684\u6570\u636e\uff1f<\/strong><br \/>\u903b\u8f91\u56de\u5f52\u4e3b\u8981\u7528\u4e8e\u4e8c\u5206\u7c7b\u95ee\u9898\uff0c\u5982\u5224\u65ad\u67d0\u4e2a\u7528\u6237\u662f\u5426\u4f1a\u8d2d\u4e70\u4ea7\u54c1\u3001\u67d0\u90ae\u4ef6\u662f\u5426\u4e3a\u5783\u573e\u90ae\u4ef6\u7b49\u3002\u867d\u7136\u903b\u8f91\u56de\u5f52\u6700\u521d\u662f\u4e3a\u4e8c\u5206\u7c7b\u95ee\u9898\u8bbe\u8ba1\u7684\uff0c\u4f46\u901a\u8fc7\u4e00\u4e9b\u6280\u5de7\uff08\u5982\u4f7f\u7528\u4e00\u5bf9\u591a\u7b56\u7565\uff09\uff0c\u4e5f\u53ef\u4ee5\u6269\u5c55\u5230\u591a\u5206\u7c7b\u95ee\u9898\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8f93\u5165\u7279\u5f81\u5e94\u5f53\u662f\u6570\u503c\u578b\uff0c\u82e5\u662f\u7c7b\u522b\u578b\u7279\u5f81\uff0c\u9700\u8981\u8fdb\u884c\u7f16\u7801\u5904\u7406\u3002<\/p>\n<p><strong>\u5982\u4f55\u8bc4\u4f30\u903b\u8f91\u56de\u5f52\u6a21\u578b\u7684\u6027\u80fd\uff1f<\/strong><br \/>\u8bc4\u4f30\u903b\u8f91\u56de\u5f52\u6a21\u578b\u7684\u6027\u80fd\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u6307\u6807\u3002\u5e38\u89c1\u7684\u5305\u62ec\u51c6\u786e\u7387\u3001\u7cbe\u786e\u7387\u3001\u53ec\u56de\u7387\u548cF1-score\u7b49\u3002\u6b64\u5916\uff0c\u7ed8\u5236ROC\u66f2\u7ebf\u548c\u8ba1\u7b97AUC\u503c\u4e5f\u662f\u975e\u5e38\u6709\u6548\u7684\u65b9\u6cd5\uff0c\u80fd\u591f\u5e2e\u52a9\u5224\u65ad\u6a21\u578b\u5728\u4e0d\u540c\u9608\u503c\u4e0b\u7684\u8868\u73b0\u3002\u4f7f\u7528<code>scikit-learn<\/code>\u4e2d\u7684<code>classification_report<\/code>\u548c<code>confusion_matrix<\/code>\u529f\u80fd\uff0c\u53ef\u4ee5\u66f4\u76f4\u89c2\u5730\u5206\u6790\u6a21\u578b\u7684\u9884\u6d4b\u6548\u679c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u4e2d\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528scikit-learn\u5e93\u6765\u5b9e\u73b0\u903b\u8f91\u56de\u5f52\u3001\u903b\u8f91\u56de\u5f52\u662f\u4e00\u79cd\u7528\u4e8e\u5206\u7c7b\u95ee\u9898\u7684\u7edf\u8ba1\u65b9\u6cd5\u3001\u5b83\u901a [&hellip;]","protected":false},"author":3,"featured_media":1152508,"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\/1152501"}],"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=1152501"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1152501\/revisions"}],"predecessor-version":[{"id":1152511,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1152501\/revisions\/1152511"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1152508"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1152501"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1152501"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1152501"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}