{"id":55529,"date":"2025-08-14T00:14:39","date_gmt":"2025-08-13T16:14:39","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/55529.html"},"modified":"2025-08-14T00:14:39","modified_gmt":"2025-08-13T16:14:39","slug":"kaggle%e6%96%b0%e6%89%8b%e5%85%a5%e9%97%a8%e6%88%bf%e4%bb%b7%e9%a2%84%e6%b5%8b%ef%bc%9apytorch%e4%bb%a3%e7%a0%81-%e8%b6%85%e8%af%a6%e7%bb%86%e5%9f%ba%e7%a1%80%e8%ae%b2%e8%a7%a3%ef%bc%8c%e4%bf%9d","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/55529.html","title":{"rendered":"kaggle\u65b0\u624b\u5165\u95e8\u623f\u4ef7\u9884\u6d4b\uff1aPytorch\u4ee3\u7801-\u8d85\u8be6\u7ec6\u57fa\u7840\u8bb2\u89e3\uff0c\u4fdd\u8bc1\u4f60\u770b\u5b8c\u4e5f\u4f1a\uff01\uff08\u6570\u636e\u5904\u7406\u4e0e\u7279\u5f81\u5de5\u7a0b\u7bc7\uff09"},"content":{"rendered":"<p>\u8fd9\u4e2a\u7ade\u8d5b\u5206\u4e24\u4e2a\u90e8\u5206\u8bb2\u89e3&#xff1a;\u4e00\u662f\u6570\u636e\u5904\u7406\u4e0e\u7279\u5f81\u5de5\u7a0b&#xff0c;\u4e8c\u662f\u7f51\u7edc\u642d\u5efa\u4e0e\u8bad\u7ec3<\/p>\n<p>\u8bb2\u89e3\u4ee3\u7801\u5206\u4e3a3\u4e2a\u6b65\u9aa4&#xff1a;\u6709\u4ec0\u4e48\u7528&#xff0c;\u4e3a\u4ec0\u4e48\u9700\u8981\u4ed6&#xff0c;\u5982\u4f55\u4f7f\u7528<\/p>\n<p>\u4fdd\u8bc1\u5927\u5bb6\u8010\u5fc3\u770b\u5b8c\u4e00\u5b9a\u5927\u6709\u88e8\u76ca&#xff01;\u5982\u679c\u6709\u61c2\u7684\u53ef\u4ee5\u8df3\u8fc7\u3002<\/p>\n<p>\u73b0\u5728\u5f00\u59cb\u5427&#xff01;<\/p>\n<p>\u9879\u76ee\u76ee\u6807<\/p>\n<p>\u6211\u4eec\u7684\u76ee\u6807\u662f\u6839\u636e\u623f\u5b50\u7684\u4fe1\u606f&#xff08;\u5982\u5730\u6bb5\u3001\u9762\u79ef\u7b49&#xff09;&#xff0c;\u9884\u6d4b\u623f\u5b50\u7684\u4ef7\u683c\u3002\u8fd9\u662f\u4e00\u4e2a\u5178\u578b\u7684\u4e8c\u5143\u5206\u7c7b\u95ee\u9898\u3002\u73b0\u5728\u6211\u4eec\u5f00\u59cb\u5427&#xff0c;\u8fd9\u662f\u539f\u7248\u6d4b\u8bd5\u96c6\u548c\u8bad\u7ec3\u96c6\u7684\u4e0b\u8f7d\u5730\u5740&#xff1a;<\/p>\n<p>\u901a\u8fc7\u7f51\u76d8\u5206\u4eab\u7684\u6587\u4ef6&#xff1a;home-data-for-ml-course \u94fe\u63a5: https:\/\/pan.baidu.com\/s\/16UWI_WIFMYIEjUquLQJllg?pwd&#061;6688 \u63d0\u53d6\u7801: 6688\u00a0<\/p>\n<h4>\u7b2c\u4e00\u6b65&#xff1a;\u5148\u5bfc\u5165\u4e00\u4e9b\u5fc5\u8981\u7684\u5e93<\/h4>\n<p>\u8fd9\u4e00\u6bb5\u5927\u5bb6\u5e94\u8be5\u90fd\u77e5\u9053&#xff0c;\u5c31\u662f\u4e3a\u4e86\u4f7f\u7528\u5e93\u91cc\u9762\u7684\u6a21\u5757\u3002<\/p>\n<p># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n# 1. \u5bfc\u5165\u6240\u6709\u9700\u8981\u7684\u5e93<br \/>\n# &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\nimport pandas as pd<br \/>\nimport numpy as np<br \/>\nimport torch<br \/>\nimport torch.nn as nn<br \/>\nimport torch.nn.functional as F<br \/>\nfrom torch.utils.data import TensorDataset, DataLoader, Subset<br \/>\nfrom sklearn.preprocessing import StandardScaler<br \/>\nfrom sklearn.model_selection import KFold<br \/>\nimport warnings<br \/>\nimport os<\/p>\n<p># \u5ffd\u7565\u4e00\u4e9b\u672a\u6765\u7248\u672c\u7684\u8b66\u544a&#xff0c;\u8ba9\u8f93\u51fa\u66f4\u5e72\u51c0<br \/>\nwarnings.filterwarnings(&#039;ignore&#039;, category&#061;FutureWarning)<\/p>\n<p># &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; <\/p>\n<p><span style=\"background-color:#d7d8d9\">warnings<\/span>&#xff1a;\u7528\u4e8e\u63a7\u5236\u7a0b\u5e8f\u5982\u4f55\u5904\u7406\u8b66\u544a\u4fe1\u606f\u3002\u4ee3\u7801\u4e2d\u7684 <span style=\"background-color:#d7d8d9\">warnings.filterwarnings(&#039;ignore&#039;, category&#061;FutureWarning)<\/span><span style=\"background-color:#d7d8d9\"> <\/span>\u610f\u601d\u662f\u201c\u8bf7\u5ffd\u7565\u6389\u90a3\u4e9b\u5173\u4e8e\u672a\u6765\u7248\u672c\u7279\u6027\u53d8\u66f4\u7684\u8b66\u544a\u201d&#xff0c;\u76ee\u7684\u662f\u8ba9\u7a0b\u5e8f\u8f93\u51fa\u66f4\u5e72\u51c0&#xff0c;\u4e0d\u53d7\u5e72\u6270\u3002<\/p>\n<h4>\u7b2c\u4e8c\u6b65&#xff0c;\u6570\u636e\u52a0\u8f7d\u4e0e\u9884\u5904\u7406<\/h4>\n<p># 2. \u6570\u636e\u52a0\u8f7d\u4e0e\u9884\u5904\u7406<br \/>\n# &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\nprint(&#034;&#8212; 1. Loading and Preprocessing Data &#8212;&#034;)<\/p>\n<p># \u52a0\u8f7d\u6570\u636e<br \/>\ntry:<br \/>\n    train_df &#061; pd.read_csv(&#039;train.csv&#039;)<br \/>\n    test_df &#061; pd.read_csv(&#039;test.csv&#039;)<br \/>\nexcept FileNotFoundError:<br \/>\n    print(&#034;\u9519\u8bef&#xff1a;\u8bf7\u786e\u4fdd train.csv \u548c test.csv \u6587\u4ef6\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u3002&#034;)<br \/>\n    exit() <\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u6709\u4ec0\u4e48\u7528&#xff1f;<\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u7684\u6838\u5fc3\u4f5c\u7528\u662f\u52a0\u8f7d\u6570\u636e\u6587\u4ef6\u3002<\/p>\n<p>\u5177\u4f53\u6765\u8bf4&#xff0c;\u5b83\u505a\u4e86\u4e24\u4ef6\u4e8b&#xff1a;<\/p>\n<p>\u8bfb\u53d6\u6570\u636e&#xff1a;\u5b83\u5c1d\u8bd5\u4ece\u4f60\u7684\u7535\u8111\u786c\u76d8\u4e2d\u8bfb\u53d6\u540d\u4e3a<span style=\"background-color:#d7d8d9\"> <\/span><span style=\"background-color:#d7d8d9\">train.csv<\/span><span style=\"background-color:#d7d8d9\"> <\/span>\u548c <span style=\"background-color:#d7d8d9\">test.csv<\/span> \u7684\u4e24\u4e2a\u6587\u4ef6\u3002<\/p>\n<p>\u5b58\u5165\u5185\u5b58&#xff1a;\u5c06\u8fd9\u4e24\u4e2a\u6587\u4ef6\u4e2d\u7684\u8868\u683c\u6570\u636e&#xff0c;\u52a0\u8f7d\u5230\u7a0b\u5e8f\u5185\u5b58\u91cc&#xff0c;\u5e76\u5206\u522b\u5b58\u50a8\u5728 <span style=\"background-color:#d7d8d9\">train_df<\/span> \u548c <span style=\"background-color:#d7d8d9\">test_df<\/span> \u8fd9\u4e24\u4e2a\u53d8\u91cf\u4e2d&#xff0c;\u4ee5\u4fbf\u540e\u7eed\u8fdb\u884c\u5206\u6790\u548c\u5904\u7406\u3002<\/p>\n<p>\u4f60\u53ef\u4ee5\u628a <span style=\"background-color:#d7d8d9\">train.csv<\/span> \u60f3\u8c61\u6210\u662f\u7ed9\u6a21\u578b\u7684\u6559\u79d1\u4e66\u548c\u7ec3\u4e60\u518c&#xff08;\u5e26\u6709\u95ee\u9898\u548c\u7b54\u6848&#xff09;&#xff0c;<span style=\"background-color:#d7d8d9\">test.csv<\/span><span style=\"background-color:#d7d8d9\"> <\/span>\u5219\u662f\u6700\u7ec8\u8003\u8bd5\u7684\u8bd5\u5377&#xff08;\u53ea\u6709\u95ee\u9898&#xff0c;\u6ca1\u6709\u7b54\u6848&#xff09;\u3002\u8fd9\u6bb5\u4ee3\u7801\u5c31\u662f\u628a\u6559\u79d1\u4e66\u548c\u8003\u5377\u53d1\u5230\u6a21\u578b\u624b\u4e0a\u3002<\/p>\n<p>\u6b64\u5916&#xff0c;\u5b83\u8fd8\u5305\u542b\u4e86\u4e00\u4e2a\u5b89\u5168\u68c0\u67e5\u673a\u5236&#xff1a;\u5982\u679c\u627e\u4e0d\u5230\u8fd9\u4e24\u4e2a\u6587\u4ef6&#xff0c;\u7a0b\u5e8f\u4e0d\u4f1a\u5d29\u6e83\u62a5\u9519&#xff0c;\u800c\u662f\u4f1a\u63d0\u793a\u4f60\u9700\u8981\u505a\u4ec0\u4e48&#xff0c;\u7136\u540e\u6b63\u5e38\u9000\u51fa\u3002<\/p>\n<\/p>\n<p>\u4e3a\u4ec0\u4e48\u7528\u5b83&#xff1f;<\/p>\n<p>\u4e00\u5207\u5206\u6790\u59cb\u4e8e\u6570\u636e&#xff1a;\u4efb\u4f55\u6570\u636e\u5206\u6790\u6216\u673a\u5668\u5b66\u4e60\u9879\u76ee\u7684\u7b2c\u4e00\u6b65&#xff0c;\u90fd\u662f\u83b7\u53d6\u6570\u636e\u3002\u6ca1\u6709\u6570\u636e&#xff0c;\u6a21\u578b\u5c31\u662f\u65e0\u6e90\u4e4b\u6c34\u3002\u6240\u4ee5&#xff0c;\u52a0\u8f7d\u6570\u636e\u662f\u5fc5\u987b\u7684\u8d77\u59cb\u6b65\u9aa4\u3002<\/p>\n<p>\u4f7f\u7528Pandas\u662f\u6700\u4f18\u9009\u62e9&#xff1a;CSV (Comma-Separated Values, \u9017\u53f7\u5206\u9694\u503c) \u662f\u4e00\u79cd\u6781\u5176\u5e38\u89c1\u7684\u5b58\u50a8\u8868\u683c\u6570\u636e\u7684\u6587\u4ef6\u683c\u5f0f\u3002\u800c\u6211\u4eec\u4e4b\u524d\u5bfc\u5165\u7684<span style=\"background-color:#d7d8d9\"> <\/span><span style=\"background-color:#d7d8d9\">pandas<\/span><span style=\"background-color:#d7d8d9\"> <\/span>\u5e93&#xff0c;\u6b63\u662fPython\u751f\u6001\u4e2d\u5904\u7406\u8fd9\u7c7b\u8868\u683c\u6570\u636e\u7684\u6807\u51c6\u3002\u5b83\u7684 <span style=\"background-color:#d7d8d9\">read_csv<\/span> \u51fd\u6570\u529f\u80fd\u5f3a\u5927\u3001\u901f\u5ea6\u5feb&#xff0c;\u80fd\u8f7b\u677e\u5c06CSV\u6587\u4ef6\u8f6c\u6362\u6210\u5b83\u7279\u6709\u7684\u3001\u4fbf\u4e8e\u64cd\u4f5c\u7684 <span style=\"background-color:#d7d8d9\">DataFrame<\/span><span style=\"background-color:#d7d8d9\"> <\/span>\u683c\u5f0f\u3002<\/p>\n<p>\u4e3a\u4ec0\u4e48\u8981\u7528 <span style=\"background-color:#d7d8d9\">try&#8230;except<\/span> \u7ed3\u6784&#xff1f;<\/p>\n<p>\u907f\u514d\u7a0b\u5e8f\u5d29\u6e83&#xff1a;\u5982\u679c\u76f4\u63a5\u5199<span style=\"background-color:#d7d8d9\"> <\/span><span style=\"background-color:#d7d8d9\">train_df &#061; pd.read_csv(&#039;train.csv&#039;)<\/span> \u800c\u4e0d\u52a0<span style=\"background-color:#d7d8d9\"> <\/span><span style=\"background-color:#d7d8d9\">try&#8230;except<\/span>&#xff0c;\u4e00\u65e6 <span style=\"background-color:#d7d8d9\">train.csv<\/span><span style=\"background-color:#d7d8d9\"> <\/span>\u6587\u4ef6\u4e0d\u5b58\u5728\u6216\u653e\u9519\u4e86\u4f4d\u7f6e&#xff0c;\u6574\u4e2a\u7a0b\u5e8f\u5c31\u4f1a\u7acb\u5373\u629b\u51fa\u4e00\u4e2a<span style=\"background-color:#d7d8d9\"> <\/span><span style=\"background-color:#d7d8d9\">FileNotFoundError<\/span><span style=\"background-color:#d7d8d9\"> <\/span>\u5f02\u5e38\u5e76\u5d29\u6e83\u3002\u8fd9\u4f1a\u663e\u793a\u4e00\u5927\u5806\u7ea2\u8272\u7684\u9519\u8bef\u4fe1\u606f&#xff0c;\u5bf9\u7528\u6237\u4e0d\u53cb\u597d\u3002<\/p>\n<p>\u63d0\u4f9b\u6e05\u6670\u7684\u6307\u5f15&#xff1a;\u901a\u8fc7 <span style=\"background-color:#d7d8d9\">try&#8230;except<\/span> \u6355\u83b7\u8fd9\u4e2a\u7279\u5b9a\u7684\u9519\u8bef&#xff0c;\u6211\u4eec\u53ef\u4ee5\u7ed9\u7528\u6237\u4e00\u4e2a\u6e05\u6670\u3001\u4eba\u6027\u5316\u7684\u63d0\u793a&#xff08;\u201c\u9519\u8bef&#xff1a;\u8bf7\u786e\u4fdd train.csv \u548c test.csv \u6587\u4ef6\u5728\u5f53\u524d\u76ee\u5f55\u4e0b\u3002\u201d&#xff09;&#xff0c;\u7136\u540e\u4f7f\u7528 <span style=\"background-color:#d7d8d9\">exit()<\/span><span style=\"background-color:#d7d8d9\"> <\/span>\u51fd\u6570\u9000\u51fa\u7a0b\u5e8f\u3002\u8fd9\u8ba9\u811a\u672c\u53d8\u5f97\u66f4\u53ef\u9760\u3001\u66f4\u6613\u4e8e\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p>\u8bed\u6cd5\u5982\u4f55\u4f7f\u7528&#xff1f;<\/p>\n<p><span style=\"background-color:#d7d8d9\">1.try: &#8230; except FileNotFoundError: &#8230;<\/span><\/p>\n<p>\u8fd9\u662f\u4e00\u4e2a\u5f02\u5e38\u5904\u7406\u7ed3\u6784&#xff0c;\u662fPython\u4e2d\u975e\u5e38\u91cd\u8981\u7684\u4e00\u4e2a\u6982\u5ff5\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">try:<\/span>\u5173\u952e\u5b57&#xff0c;\u5b83\u540e\u9762\u7684\u4ee3\u7801\u5757&#xff08;\u8fd9\u91cc\u662f\u4e24\u884c<span style=\"background-color:#d7d8d9\">pd.read_csv<\/span>&#xff09;\u662f\u5c1d\u8bd5\u6267\u884c\u533a\u3002Python\u4f1a\u6b63\u5e38\u5c1d\u8bd5\u8fd0\u884c\u8fd9\u91cc\u7684\u4ee3\u7801\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">except FileNotFoundError:<\/span>&#xff1a;\u5173\u952e\u5b57&#xff0c;\u5b83\u540e\u9762\u8ddf\u7740\u4e00\u4e2a\u5177\u4f53\u7684\u9519\u8bef\u7c7b\u578b\u3002\u5982\u679c <span style=\"background-color:#d7d8d9\">try<\/span><span style=\"background-color:#d7d8d9\"> <\/span>\u4ee3\u7801\u5757\u5728\u6267\u884c\u65f6\u6070\u597d\u53d1\u751f\u4e86 <span style=\"background-color:#d7d8d9\">FileNotFoundError<\/span> (\u6587\u4ef6\u672a\u627e\u5230\u9519\u8bef)&#xff0c;\u90a3\u4e48Python\u4f1a\u7acb\u523b\u505c\u6b62\u6267\u884c <span style=\"background-color:#d7d8d9\">try<\/span> \u91cc\u7684\u4ee3\u7801&#xff0c;\u8f6c\u800c\u6267\u884c<span style=\"background-color:#d7d8d9\"> <\/span><span style=\"background-color:#d7d8d9\">except<\/span> \u540e\u9762\u7684\u4ee3\u7801\u5757\u3002\u5982\u679c <span style=\"background-color:#d7d8d9\">try<\/span> \u5757\u91cc\u53d1\u751f\u4e86\u5176\u4ed6\u7c7b\u578b\u7684\u9519\u8bef&#xff0c;\u8fd9\u4e2a<span style=\"background-color:#d7d8d9\"> <\/span><span style=\"background-color:#d7d8d9\">except<\/span> \u5757\u662f\u4e0d\u4f1a\u88ab\u89e6\u53d1\u7684\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">2.train_df &#061; pd.read_csv(&#039;train.csv&#039;)&#xff1a;<\/span><\/p>\n<p><span style=\"background-color:#d7d8d9\">train_df<\/span><span style=\"background-color:#d7d8d9\">&#xff1a;<\/span>\u6211\u4eec\u5b9a\u4e49\u7684\u4e00\u4e2a\u53d8\u91cf\u540d\u3002\u6309\u7167\u60ef\u4f8b&#xff0c;\u7528 _df \u4f5c\u4e3a\u7ed3\u5c3e&#xff0c;\u53ef\u4ee5\u6e05\u6670\u5730\u8868\u660e\u8fd9\u4e2a\u53d8\u91cf\u5b58\u50a8\u7684\u662f\u4e00\u4e2aPandas DataFrame\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">pd.read_csv(&#8230;)<\/span>&#xff1a;\u8c03\u7528\u6211\u4eec\u4e4b\u524d\u5bfc\u5165\u7684 <span style=\"background-color:#d7d8d9\">pandas<\/span> \u5e93&#xff08;\u522b\u540d\u4e3a<span style=\"background-color:#d7d8d9\"> <\/span><span style=\"background-color:#d7d8d9\">pd<\/span>&#xff09;\u4e2d\u7684 <span style=\"background-color:#d7d8d9\">read_csv<\/span> \u51fd\u6570\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">&#039;train.csv&#039;<\/span><span style=\"background-color:#d7d8d9\">&#xff1a;<\/span>\u4f20\u9012\u7ed9 <span style=\"background-color:#d7d8d9\">read_csv<\/span> \u51fd\u6570\u7684\u53c2\u6570&#xff0c;\u5b83\u662f\u4e00\u4e2a\u5b57\u7b26\u4e32&#xff0c;\u4ee3\u8868\u8981\u8bfb\u53d6\u7684\u6587\u4ef6\u540d\u3002\u56e0\u4e3a\u8fd9\u91cc\u53ea\u5199\u4e86\u6587\u4ef6\u540d\u800c\u6ca1\u6709\u5199\u5b8c\u6574\u7684\u8def\u5f84&#xff08;\u6bd4\u5982<span style=\"background-color:#d7d8d9\"> <\/span><span style=\"background-color:#d7d8d9\">C:\/Users\/YourName\/Documents\/train.csv<\/span>&#xff09;&#xff0c;Python\u4f1a\u5728\u5f53\u524d\u8fd0\u884c\u811a\u672c\u7684\u90a3\u4e2a\u76ee\u5f55\u4e0b\u5bfb\u627e\u8fd9\u4e2a\u6587\u4ef6\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">3.print(&#8230;)<\/span><span style=\"background-color:#d7d8d9\"> \u548c <\/span><span style=\"background-color:#d7d8d9\">exit()<\/span><\/p>\n<p><span style=\"background-color:#d7d8d9\">print(&#8230;)<\/span>&#xff1a;\u5728except\u5757\u4e2d&#xff0c;\u6211\u4eec\u7528\u5b83\u6765\u6253\u5370\u81ea\u5b9a\u4e49\u7684\u9519\u8bef\u63d0\u793a\u4fe1\u606f\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">exit()<\/span>&#xff1a;\u4e00\u4e2a\u5185\u7f6e\u51fd\u6570&#xff0c;\u8c03\u7528\u5b83\u4f1a\u7acb\u5373\u7ec8\u6b62\u6574\u4e2a\u7a0b\u5e8f\u7684\u8fd0\u884c\u3002<\/p>\n<p>\u73b0\u5728\u6211\u4eec\u67e5\u770b\u4e00\u4e0b\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"536\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813161438-689cb9ee1194d.png\" width=\"1151\" \/><\/p>\n<p>\u53ef\u4ee5\u53d1\u73b0\u8bad\u7ec3\u96c6\u6709\u5f88\u591a\u7f3a\u5931\u503c&#xff0c;\u63a5\u4e0b\u6765\u6211\u4eec\u5904\u7406\u4e00\u4e0b\u4ed6\u4eec\u00a0<\/p>\n<p>\u9996\u5148\u6211\u4eec\u5148\u628aID\u5217\u79fb\u9664\u5e76\u4e14\u4fdd\u6301\u8d77\u6765&#xff0c;\u56e0\u4e3aID\u5bf9\u4e8e\u8bad\u7ec3\u6765\u8bf4\u6beb\u65e0\u7528\u5904&#xff1a;<\/p>\n<p># \u4fdd\u5b58\u6d4b\u8bd5\u96c6\u7684ID\u7528\u4e8e\u540e\u7eed\u63d0\u4ea4<br \/>\ntest_ids &#061; test_df[&#039;Id&#039;]<\/p>\n<p># \u79fb\u9664\u8bad\u7ec3\u6570\u636e\u4e2d\u7684ID\u5217<br \/>\ntrain_df &#061; train_df.drop(&#039;Id&#039;, axis&#061;1)<br \/>\ntest_df &#061; test_df.drop(&#039;Id&#039;, axis&#061;1)<\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u6709\u4ec0\u4e48\u7528&#xff1f; \u8fd9\u6bb5\u4ee3\u7801\u7684\u6838\u5fc3\u4f5c\u7528\u662f\u5904\u7406ID\u5217\u2014\u2014\u8fd9\u662f\u4e00\u4e2a\u5728\u6570\u636e\u96c6\u4e2d\u6ca1\u6709\u9884\u6d4b\u4ef7\u503c&#xff0c;\u4f46\u5bf9\u4e8e\u63d0\u4ea4\u7ed3\u679c\u53c8\u5fc5\u4e0d\u53ef\u5c11\u7684\u5217\u3002<\/p>\n<p>\u5b83\u4e3b\u8981\u5b8c\u6210\u4e86\u4e24\u4ef6\u4e8b&#xff1a;<\/p>\n<p>\u5907\u4efd\u6d4b\u8bd5\u96c6ID&#xff1a;\u5c06\u6d4b\u8bd5\u6570\u636e\u96c6 <span style=\"background-color:#d7d8d9\">test_df <\/span>\u4e2d\u7684 Id \u5217\u5355\u72ec\u4fdd\u5b58\u5230 <span style=\"background-color:#d7d8d9\">test_ids <\/span>\u53d8\u91cf\u4e2d\u3002<\/p>\n<p>\u6e05\u7406\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6&#xff1a;\u4ece\u8bad\u7ec3\u96c6 <span style=\"background-color:#d7d8d9\">train_df <\/span>\u548c\u6d4b\u8bd5\u96c6 <span style=\"background-color:#d7d8d9\">test_df<\/span> \u4e2d&#xff0c;\u90fd\u5f7b\u5e95\u79fb\u9664 Id \u8fd9\u4e00\u5217\u3002<\/p>\n<p>\u7ecf\u8fc7\u8fd9\u756a\u64cd\u4f5c\u540e&#xff0c;<span style=\"background-color:#d7d8d9\">train_df<\/span> \u548c <span style=\"background-color:#d7d8d9\">test_df<\/span> \u90fd\u4e0d\u518d\u542b\u6709Id\u5217&#xff0c;\u53ea\u5269\u4e0b\u4e0e\u623f\u4ef7\u76f8\u5173\u7684\u7279\u5f81&#xff08;Features&#xff09;\u4ee5\u53ca&#xff08;\u5728\u8bad\u7ec3\u96c6\u4e2d\u8fd8\u5305\u542b\u7684&#xff09;\u623f\u4ef7\u6807\u7b7e&#xff08;Label&#xff09;\u3002\u800c <span style=\"background-color:#d7d8d9\">test_ids<\/span> \u5c31\u50cf\u4e00\u4e2a\u5b58\u6839&#xff0c;\u4ee5\u5907\u540e\u7528\u3002<\/p>\n<\/p>\n<p>\u4e3a\u4ec0\u4e48\u7528\u5b83&#xff1f; \u662f\u7279\u5f81\u5de5\u7a0b&#xff08;Feature Engineering&#xff09;\u4e2d\u7684\u4e00\u4e2a\u57fa\u672c\u539f\u5219&#xff1a;<\/p>\n<p>ID\u5217\u6ca1\u6709\u9884\u6d4b\u80fd\u529b&#xff1a;Id \u5217\u901a\u5e38\u53ea\u662f\u4e00\u4e2a\u4ece1\u5f00\u59cb\u7684\u987a\u5e8f\u7f16\u53f7&#xff08;1, 2, 3, &#8230;&#xff09;\u3002\u4e00\u680b\u623f\u5b50\u7684ID\u662f5\u8fd8\u662f500&#xff0c;\u4e0e\u5b83\u7684\u6700\u7ec8\u552e\u4ef7\u6ca1\u6709\u4efb\u4f55\u5173\u7cfb\u3002\u5b83\u4e0d\u50cf\u201c\u623f\u5c4b\u9762\u79ef\u201d\u6216\u201c\u5efa\u9020\u5e74\u4efd\u201d\u90a3\u6837&#xff0c;\u5305\u542b\u53ef\u4ee5\u5e2e\u52a9\u6a21\u578b\u5224\u65ad\u623f\u4ef7\u7684\u6709\u6548\u4fe1\u606f\u3002<\/p>\n<p>\u628a\u8fd9\u79cd\u65e0\u6548\u4fe1\u606f\u5582\u7ed9\u6a21\u578b&#xff0c;\u4e0d\u4ec5\u6ca1\u7528&#xff0c;\u6709\u65f6\u4f1a\u6210\u4e3a\u566a\u58f0&#xff0c;\u5e72\u6270\u6a21\u578b\u7684\u5b66\u4e60&#xff0c;\u53ef\u80fd\u5bfc\u81f4\u6a21\u578b\u6027\u80fd\u4e0b\u964d\u3002\u56e0\u6b64&#xff0c;\u5728\u8bad\u7ec3\u5f00\u59cb\u524d&#xff0c;\u5c06\u5b83\u5254\u9664\u3002<\/p>\n<p>Kaggle\u63d0\u4ea4\u9700\u8981ID&#xff1a;\u65e2\u7136ID\u6ca1\u7528&#xff0c;\u4e3a\u4ec0\u4e48\u4e0d\u76f4\u63a5\u6254\u6389&#xff0c;\u8fd8\u8981\u5907\u4efd test_ids \u5462&#xff1f;\u56e0\u4e3aKaggle\u7ade\u8d5b\u5e73\u53f0\u5728\u8bc4\u5224\u4f60\u7684\u7ed3\u679c\u65f6&#xff0c;\u9700\u8981\u77e5\u9053\u4f60\u9884\u6d4b\u7684\u6bcf\u4e00\u4e2a\u623f\u4ef7\u5206\u522b\u5bf9\u5e94\u7684\u662f\u54ea\u4e00\u680b\u623f\u5b50\u3002\u4f60\u6700\u7ec8\u63d0\u4ea4\u7684 <span style=\"background-color:#d7d8d9\">submission.csv <\/span>\u6587\u4ef6&#xff0c;\u901a\u5e38\u9700\u8981\u5305\u542b\u4e24\u5217&#xff1a;<span style=\"background-color:#d7d8d9\">Id \u548c SalePrice<\/span>&#xff08;\u4f60\u9884\u6d4b\u7684\u623f\u4ef7&#xff09;\u3002\u6240\u4ee5&#xff0c;\u6211\u4eec\u5fc5\u987b\u5148\u628a\u6d4b\u8bd5\u96c6\u7684ID\u4fdd\u5b58\u4e0b\u6765&#xff0c;\u7b49\u6a21\u578b\u9884\u6d4b\u51fa\u6240\u6709\u623f\u4ef7\u540e&#xff0c;\u518d\u628a <span style=\"background-color:#d7d8d9\">test_ids<\/span> \u548c\u9884\u6d4b\u7ed3\u679c\u62fc\u5728\u4e00\u8d77&#xff0c;\u751f\u6210\u6700\u7ec8\u7684\u63d0\u4ea4\u6587\u4ef6\u3002<\/p>\n<p><span style=\"background-color:null\">\u4fdd\u6301\u6570\u636e\u7ed3\u6784\u4e00\u81f4<\/span>&#xff1a;\u6a21\u578b\u8bad\u7ec3\u65f6\u7528\u5230\u7684\u6570\u636e&#xff08;<span style=\"background-color:#d7d8d9\">train_df&#xff09;<\/span>\u6709\u4ec0\u4e48\u6837\u7684\u5217&#xff0c;\u90a3\u4e48\u5728\u9884\u6d4b\u65f6\u5582\u7ed9\u5b83\u7684\u6570\u636e&#xff08;<span style=\"background-color:#d7d8d9\">test_df<\/span>&#xff09;\u4e5f\u5fc5\u987b\u6709\u5b8c\u5168\u76f8\u540c\u7684\u5217\u7ed3\u6784\u3002\u65e2\u7136\u6211\u4eec\u4ece\u8bad\u7ec3\u6570\u636e\u4e2d\u5220\u9664\u4e86Id&#xff0c;\u90a3\u4e48\u4e5f\u5fc5\u987b\u4ece\u6d4b\u8bd5\u6570\u636e\u4e2d\u5220\u9664Id&#xff0c;\u4ee5\u786e\u4fdd\u4e24\u8005\u7ed3\u6784\u7edf\u4e00\u3002<\/p>\n<\/p>\n<p>\u8bed\u6cd5\u5982\u4f55\u4f7f\u7528&#xff1f; \u6211\u4eec\u6765\u8be6\u7ec6\u770b\u4e00\u4e0b\u8fd9\u4e24\u884c\u4ee3\u7801\u7684\u8bed\u6cd5\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">1.test_ids &#061; test_df[&#039;Id&#039;]<\/span> \u8fd9\u4e2a\u8bed\u6cd5\u6211\u4eec\u5df2\u7ecf\u89c1\u8fc7&#xff0c;\u5b83\u662f\u4ece<span style=\"background-color:#d7d8d9\">test_df<\/span>\u8fd9\u4e2a<span style=\"background-color:#d7d8d9\">DataFrame<\/span>\u4e2d\u9009\u53d6\u540d\u4e3a&#039;Id&#039;\u7684\u5355\u5217\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">test_df[&#039;Id&#039;] <\/span>\u7684\u7ed3\u679c\u662f\u4e00\u4e2aPandas Series&#xff08;\u4e00\u7ef4\u6570\u636e\u7cfb\u5217&#xff09;&#xff0c;\u7136\u540e\u901a\u8fc7 &#061; \u8d4b\u503c\u7ed9\u4e86\u65b0\u53d8\u91cf <span style=\"background-color:#d7d8d9\">test_ids<\/span>\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">2.train_df &#061; train_df.drop(&#039;Id&#039;, axis&#061;1)<\/span><\/p>\n<p><span style=\"background-color:#d7d8d9\">train_df.drop(&#8230;)<\/span>&#xff1a;\u8c03\u7528<span style=\"background-color:#d7d8d9\">train_df<\/span>\u8fd9\u4e2aDataFrame\u7684<span style=\"background-color:#d7d8d9\"> <\/span><span style=\"background-color:#d7d8d9\">.drop()<\/span> \u65b9\u6cd5\u3002\u8fd9\u4e2a\u65b9\u6cd5\u7684\u4f5c\u7528\u5c31\u662f\u5220\u9664\u884c\u6216\u5217\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">&#039;Id&#039;<\/span>&#xff1a;\u8fd9\u662f\u4f20\u9012\u7ed9<span style=\"background-color:#d7d8d9\"> .drop(<\/span>) \u65b9\u6cd5\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570&#xff0c;\u8868\u793a\u6211\u4eec\u60f3\u8981\u5220\u9664\u7684\u6807\u7b7e\u540d&#xff08;label&#xff09;\u3002\u5728\u8fd9\u91cc&#xff0c;\u5c31\u662f\u5217\u540d&#039;Id&#039;\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">axis&#061;1&#xff1a;<\/span>\u8fd9\u662f .drop() \u65b9\u6cd5\u4e2d\u6781\u5176\u91cd\u8981\u7684\u53c2\u6570\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">axis&#061;0 <\/span>\u4ee3\u8868\u884c\u8f74&#xff08;\u4e0a\u4e0b\u65b9\u5411&#xff09;\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">axis&#061;1 <\/span>\u4ee3\u8868\u5217\u8f74&#xff08;\u5de6\u53f3\u65b9\u5411&#xff09;\u3002<\/p>\n<p>\u901a\u8fc7\u6307\u5b9a<span style=\"background-color:#d7d8d9\"> axis&#061;1<\/span>&#xff0c;\u6211\u4eec\u660e\u786e\u544a\u8bc9Pandas&#xff1a;\u201c\u6211\u7ed9\u4f60\u7684\u6807\u7b7e\u540d &#039;Id&#039; \u662f\u4e00\u4e2a\u5217\u7684\u540d\u79f0&#xff0c;\u8bf7\u4f60\u53bb\u5220\u9664\u8fd9\u4e00\u6574\u5217\u3002\u201d \u5982\u679c\u4e0d\u5199\u6216\u8005\u5199\u6210axis&#061;0&#xff0c;Pandas\u4f1a\u8bd5\u56fe\u53bb\u5bfb\u627e\u4e00\u4e2a\u7d22\u5f15\u540d\u53eb&#039;Id&#039;\u7684\u884c&#xff0c;\u90a3\u901a\u5e38\u4f1a\u62a5\u9519\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">train_df &#061; &#8230;&#xff1a;.drop() &#xff1a;<\/span><\/p>\n<p>\u65b9\u6cd5\u9ed8\u8ba4\u4f1a\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u3001\u5220\u9664\u4e86\u6307\u5b9a\u5217\u7684DataFrame&#xff0c;\u800c\u4e0d\u4f1a\u4fee\u6539\u539f\u59cb\u7684 <span style=\"background-color:#d7d8d9\">train_df<\/span>\u3002\u56e0\u6b64&#xff0c;\u6211\u4eec\u5fc5\u987b\u7528\u8d4b\u503c\u8bed\u53e5 <span style=\"background-color:#d7d8d9\">train_df <\/span>&#061; &#8230;&#xff0c;\u5c06\u8fd9\u4e2a\u5220\u9664\u4e86\u5217\u7684\u65b0DataFrame\u91cd\u65b0\u8d4b\u503c\u7ed9 <span style=\"background-color:#d7d8d9\">train_df <\/span>\u53d8\u91cf&#xff0c;\u4ece\u800c\u5b9e\u73b0\u201c\u66f4\u65b0\u201d <span style=\"background-color:#d7d8d9\">train_df <\/span>\u7684\u6548\u679c\u3002<span style=\"background-color:#d7d8d9\">test_df.drop(&#8230;)<\/span> \u90a3\u4e00\u884c\u540c\u7406\u3002<\/p>\n<\/p>\n<p>\u63a5\u4e0b\u6765\u7ee7\u7eed\u9884\u5904\u7406&#xff1a;<\/p>\n<p># \u5904\u7406\u5f02\u5e38\u503c<br \/>\ntrain_df &#061; train_df.drop(train_df[(train_df[&#039;GrLivArea&#039;]&gt;4000) &amp;<br \/>\n                                 (train_df[&#039;SalePrice&#039;]&lt;300000)].index)<\/p>\n<p># \u4ece\u8bad\u7ec3\u6570\u636e\u4e2d\u5206\u79bb\u76ee\u6807\u53d8\u91cf SalePrice<br \/>\ny &#061; np.log1p(train_df[&#039;SalePrice&#039;])<br \/>\ntrain_df &#061; train_df.drop(&#039;SalePrice&#039;, axis&#061;1)<\/p>\n<p># \u5408\u5e76\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6\u4ee5\u4fbf\u4e8e\u7edf\u4e00\u5904\u7406<br \/>\nall_data &#061; pd.concat([train_df, test_df], axis&#061;0).reset_index(drop&#061;True)<\/p>\n<p>1.\u5904\u7406\u5f02\u5e38\u503c<\/p>\n<p><span style=\"background-color:#d7d8d9\">train_df &#061; train_df.drop(train_df[(train_df[&#039;GrLivArea&#039;]&gt;4000) &amp; (train_df[&#039;SalePrice&#039;]&lt;300000)].index)<\/span><\/p>\n<\/p>\n<p><span style=\"background-color:null\">\u8fd9\u884c\u4ee3\u7801\u7684\u4f5c\u7528\u662f\u8bc6\u522b\u5e76\u5220\u9664\u8bad\u7ec3\u6570\u636e\u4e2d\u7684\u7279\u5b9a\u5f02\u5e38\u503c&#xff08;Outliers&#xff09;\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">\u5177\u4f53\u6765\u8bf4&#xff0c;\u5b83\u4f1a\u627e\u5230\u90a3\u4e9b\u540c\u65f6\u6ee1\u8db3\u4ee5\u4e0b\u4e24\u4e2a\u6761\u4ef6\u7684\u623f\u5b50&#xff08;\u884c&#xff09;&#xff0c;\u7136\u540e\u5c06\u5b83\u4eec\u4ece\u8bad\u7ec3\u96c6 train_df \u4e2d\u5220\u9664&#xff1a;<\/span><\/p>\n<p><span style=\"background-color:null\">\u5730\u9762\u4ee5\u4e0a\u5c45\u4f4f\u9762\u79ef (GrLivArea) \u5927\u4e8e 4000\u5e73\u65b9\u82f1\u5c3a\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">\u5e76\u4e14 (&amp;)&#xff0c;\u623f\u5c4b\u552e\u4ef7 (SalePrice) \u4f4e\u4e8e 300,000\u7f8e\u5143\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">\u8fd9\u5c31\u50cf\u662f\u5728\u8bf4&#xff1a;\u201c\u627e\u51fa\u90a3\u4e9b\u623f\u5b50\u5927\u5f97\u79bb\u8c31&#xff0c;\u4f46\u4ef7\u683c\u5374\u4fbf\u5b9c\u5f97\u4e0d\u6b63\u5e38\u7684\u6837\u672c&#xff0c;\u7136\u540e\u628a\u5b83\u4eec\u6254\u6389\u3002\u201d<\/span><\/p>\n<p>\u4e3b\u8981\u662f\u8fd9\u79cd\u8fc7\u4e8e\u5938\u5f20\u7684\u6837\u672c\u4f1a\u4e25\u91cd\u5f71\u54cd\u5b66\u4e60\u6548\u679c<\/p>\n<\/p>\n<p>\u4e3a\u4ec0\u4e48\u7528\u5b83&#xff1f; \u5f02\u5e38\u503c\u4f1a\u4e25\u91cd\u626d\u66f2\u6a21\u578b\u7684\u5b66\u4e60\u3002<\/p>\n<p>\u4e3a\u4ec0\u4e48\u8fd9\u4e9b\u662f\u5f02\u5e38\u503c&#xff1f; \u5728\u827e\u59c6\u65af\u623f\u4ef7\u8fd9\u4e2a\u6570\u636e\u96c6\u4e2d&#xff0c;\u901a\u5e38\u623f\u5c4b\u9762\u79ef\u8d8a\u5927&#xff0c;\u4ef7\u683c\u8d8a\u9ad8\u3002\u901a\u8fc7\u6570\u636e\u53ef\u89c6\u5316&#xff08;\u6bd4\u5982\u753b\u6563\u70b9\u56fe&#xff09;&#xff0c;\u6570\u636e\u79d1\u5b66\u5bb6\u53d1\u73b0\u6709\u51e0\u4e2a\u6570\u636e\u70b9\u4e25\u91cd\u504f\u79bb\u4e86\u8fd9\u4e2a\u8d8b\u52bf\u2014\u2014\u5b83\u4eec\u7684\u9762\u79ef\u975e\u5e38\u5927&#xff0c;\u4f46\u4ef7\u683c\u5374\u5f02\u5e38\u4f4e\u3002\u8fd9\u53ef\u80fd\u662f\u6570\u636e\u5f55\u5165\u9519\u8bef&#xff0c;\u6216\u8005\u662f\u4e00\u4e9b\u975e\u5e38\u7279\u6b8a\u7684\u60c5\u51b5&#xff08;\u6bd4\u5982\u623f\u5b50\u72b6\u51b5\u6781\u5dee&#xff09;\u3002<\/p>\n<p>\u6709\u4ec0\u4e48\u5371\u5bb3&#xff1f; \u6a21\u578b&#xff08;\u5c24\u5176\u662f\u7ebf\u6027\u6a21\u578b&#xff09;\u5728\u5b66\u4e60\u65f6&#xff0c;\u4f1a\u5c3d\u529b\u53bb\u62df\u5408\u6240\u6709\u7684\u6570\u636e\u70b9&#xff0c;\u5305\u62ec\u8fd9\u4e9b\u5f02\u5e38\u70b9\u3002\u4e3a\u4e86\u7167\u987e\u8fd9\u4e9b\u201c\u4e0d\u5408\u7fa4\u201d\u7684\u70b9&#xff0c;\u6a21\u578b\u53ef\u80fd\u4f1a\u88ab\u201c\u5e26\u504f\u201d&#xff0c;\u5bfc\u81f4\u5b83\u5bf9\u6b63\u5e38\u6570\u636e\u7684\u9884\u6d4b\u80fd\u529b\u4e0b\u964d\u3002\u60f3\u8c61\u4e00\u4e0b&#xff0c;\u4e3a\u4e86\u8ba9\u4e00\u6761\u76f4\u7ebf\u540c\u65f6\u7a7f\u8fc7\u4e00\u7247\u5bc6\u96c6\u7684\u70b9\u4e91\u548c\u8fdc\u5904\u4e00\u4e2a\u5b64\u7acb\u7684\u70b9&#xff0c;\u8fd9\u6761\u76f4\u7ebf\u52bf\u5fc5\u4f1a\u53d1\u751f\u503e\u659c&#xff0c;\u4ece\u800c\u65e0\u6cd5\u5f88\u597d\u5730\u4ee3\u8868\u90a3\u7247\u5bc6\u96c6\u7684\u70b9\u4e91\u3002<\/p>\n<p>\u4e3a\u4ec0\u4e48\u8981\u5220\u9664&#xff1f; \u5220\u9664\u8fd9\u4e9b\u88ab\u786e\u8ba4\u662f\u5f02\u5e38\u6216\u9519\u8bef\u7684\u6570\u636e\u70b9&#xff0c;\u53ef\u4ee5\u8ba9\u6a21\u578b\u4e13\u6ce8\u4e8e\u5b66\u4e60\u6570\u636e\u4e2d\u666e\u904d\u5b58\u5728\u7684\u3001\u66f4\u5177\u4ee3\u8868\u6027\u7684\u89c4\u5f8b&#xff0c;\u4ece\u800c\u63d0\u9ad8\u6a21\u578b\u7684\u6cdb\u5316\u80fd\u529b&#xff08;\u5bf9\u65b0\u6570\u636e\u7684\u9884\u6d4b\u80fd\u529b&#xff09;\u3002<\/p>\n<\/p>\n<p>\u8bed\u6cd5\u5982\u4f55\u4f7f\u7528&#xff1f; \u8fd9\u4e00\u884c\u4ee3\u7801\u5d4c\u5957\u6bd4\u8f83\u591a&#xff0c;\u6211\u4eec\u4ece\u91cc\u5230\u5916\u62c6\u89e3&#xff1a;<\/p>\n<p><span style=\"background-color:#d7d8d9\">train_df[&#039;GrLivArea&#039;] &gt; 4000:<\/span> \u8fd9\u4f1a\u4ea7\u751f\u4e00\u4e2a\u5e03\u5c14\u503c&#xff0c;\u5bf9\u4e8eGrLivArea\u5927\u4e8e4000\u7684\u884c&#xff0c;\u503c\u4e3aTrue&#xff0c;\u5426\u5219\u4e3aFalse\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">train_df[&#039;SalePrice&#039;] &lt; 300000<\/span>: \u540c\u7406&#xff0c;\u8fd9\u4f1a\u4ea7\u751f\u53e6\u4e00\u4e2a\u5e03\u5c14\u503c\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">(&#8230;) &amp; (&#8230;)<\/span>: &amp; \u7b26\u53f7\u662fPandas\u4e2d\u7528\u4e8e\u5bf9\u4e24\u4e2a\u5e03\u5c14\u8fdb\u884c\u4e0e\u64cd\u4f5c\u7684\u3002\u53ea\u6709\u5f53\u4e24\u4e2a\u6761\u4ef6\u5728\u540c\u4e00\u884c\u90fd\u4e3aTrue\u65f6&#xff0c;\u7ed3\u679c\u884c\u624d\u4e3aTrue\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">train_df[&#8230;]<\/span>: \u5c06\u4e0a\u9762\u5f97\u5230\u7684\u6700\u7ec8\u5e03\u5c14Series\u653e\u56detrain_df[&#8230;]\u4e2d&#xff0c;\u8fd9\u662f\u4e00\u79cd\u5e03\u5c14\u7d22\u5f15\u7684\u65b9\u6cd5\u3002\u5b83\u4f1a\u7b5b\u9009\u51fa\u6240\u6709\u5bf9\u5e94\u503c\u4e3aTrue\u7684\u884c\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">.index<\/span>: \u5728\u7b5b\u9009\u51fa\u7684\u8fd9\u4e9b\u5f02\u5e38\u884c\u4e0a\u8c03\u7528.index&#xff0c;\u83b7\u53d6\u5b83\u4eec\u7684\u7d22\u5f15\u6807\u7b7e&#xff08;\u6bd4\u5982\u884c\u53f7&#xff09;\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">train_df.drop(&#8230;)<\/span>: \u6700\u540e&#xff0c;\u8c03\u7528\u6211\u4eec\u719f\u6089\u7684<span style=\"background-color:#d7d8d9\">.drop()<\/span>\u65b9\u6cd5&#xff0c;\u628a\u8fd9\u4e9b\u7d22\u5f15\u5bf9\u5e94\u7684\u884c\u4ece<span style=\"background-color:#d7d8d9\">train_df<\/span>\u4e2d\u5220\u9664\u3002\u8fd9\u91cc\u9ed8\u8ba4\u5c31\u662f\u6309\u884c\u5220\u9664<span style=\"background-color:#d7d8d9\">&#xff08;axis&#061;0&#xff09;<\/span>&#xff0c;\u6240\u4ee5\u53ef\u4ee5\u7701\u7565\u3002<\/p>\n<\/p>\n<p>2. \u76ee\u6807\u53d8\u91cf\u8f6c\u6362\u4e0e\u5206\u79bb <span style=\"background-color:#d7d8d9\">y &#061; np.log1p(train_df[&#039;SalePrice&#039;])<\/span> <span style=\"background-color:#d7d8d9\">train_df &#061; train_df.drop(&#039;SalePrice&#039;, axis&#061;1)<\/span><\/p>\n<\/p>\n<p><span style=\"background-color:null\">\u8fd9\u6bb5\u4ee3\u7801\u6709\u4ec0\u4e48\u7528&#xff1f;<\/span><\/p>\n<p> <span style=\"background-color:null\">\u8fd9\u4e24\u884c\u4ee3\u7801\u5b8c\u6210\u4e86\u4e24\u9879\u4efb\u52a1&#xff1a;<\/span><\/p>\n<p><span style=\"background-color:null\">\u5bf9\u6570\u8f6c\u6362&#xff1a;\u5b83\u6ca1\u6709\u76f4\u63a5\u4f7f\u7528\u539f\u59cb\u7684SalePrice\u4f5c\u4e3a\u76ee\u6807&#xff0c;\u800c\u662f\u5bf9\u5b83\u8fdb\u884c\u4e86<\/span><span style=\"background-color:#d7d8d9\">log1p<\/span><span style=\"background-color:null\">\u8f6c\u6362&#xff0c;\u5e76\u5c06\u7ed3\u679c\u5b58\u50a8\u5728\u53d8\u91cf y \u4e2d\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">\u5206\u79bb\u6807\u7b7e&#xff1a;\u4ece<\/span><span style=\"background-color:#d7d8d9\">train_df<\/span><span style=\"background-color:null\">\u4e2d\u79fb\u9664\u4e86\u539f\u59cb\u7684SalePrice\u5217&#xff0c;\u786e\u4fdd\u8bad\u7ec3\u6570\u636e\u4e2d\u53ea\u5269\u4e0b\u7279\u5f81\u3002<\/span><\/p>\n<\/p>\n<p><span style=\"background-color:null\">\u4e3a\u4ec0\u4e48\u7528\u5b83&#xff1f; \u4e3a\u4ec0\u4e48\u8981\u8fdb\u884c\u5bf9\u6570\u8f6c\u6362 (log1p)&#xff1f;<\/span><\/p>\n<p><span style=\"background-color:null\">\u7f13\u89e3\u6570\u636e\u504f\u6001&#xff08;Skewness&#xff09;&#xff1a;\u623f\u4ef7\u8fd9\u7c7b\u6570\u636e\u901a\u5e38\u662f\u53f3\u504f\u5206\u5e03\u7684&#xff0c;\u610f\u5473\u7740\u5927\u591a\u6570\u623f\u5b50\u4ef7\u683c\u96c6\u4e2d\u5728\u8f83\u4f4e\u7684\u8303\u56f4&#xff0c;\u800c\u6709\u5c11\u6570\u8c6a\u5b85\u4ef7\u683c\u6781\u9ad8&#xff0c;\u62d6\u51fa\u4e00\u6761\u957f\u957f\u7684\u201c\u53f3\u5c3e\u5df4\u201d\u3002\u8fd9\u79cd\u504f\u6001\u5206\u5e03\u5bf9\u5f88\u591a\u6a21\u578b\u7684\u6027\u80fd\u4e0d\u5229\u3002\u53d6\u5bf9\u6570\u53ef\u4ee5\u6709\u6548\u5730\u201c\u538b\u7f29\u201d\u6570\u636e\u5c3a\u5ea6&#xff0c;\u7279\u522b\u662f\u538b\u7f29\u9ad8\u7aef\u503c&#xff0c;\u4f7f\u5f97\u8f6c\u6362\u540e\u7684\u6570\u636e\u5206\u5e03\u66f4\u63a5\u8fd1\u6b63\u6001\u5206\u5e03&#xff08;\u949f\u5f62\u66f2\u7ebf&#xff09;\u3002\u8bb8\u591a\u6a21\u578b&#xff08;\u5982\u7ebf\u6027\u56de\u5f52&#xff09;\u5728\u76ee\u6807\u53d8\u91cf\u670d\u4ece\u6b63\u6001\u5206\u5e03\u65f6\u8868\u73b0\u5f97\u66f4\u597d\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">\u7a33\u5b9a\u65b9\u5dee&#xff1a;\u5bf9\u6570\u8f6c\u6362\u8fd8\u6709\u52a9\u4e8e\u4f7f\u6570\u636e\u7684\u65b9\u5dee\u66f4\u52a0\u7a33\u5b9a&#xff0c;\u4e0d\u53d7\u6570\u503c\u5927\u5c0f\u7684\u5f71\u54cd\u3002<\/span><\/p>\n<p><span style=\"background-color:#d7d8d9\">log1p vs log<\/span><span style=\"background-color:null\">&#xff1a;log1p \u8ba1\u7b97\u7684\u662f log(1 &#043; x)\u3002\u4f7f\u7528\u5b83\u800c\u4e0d\u662f\u76f4\u63a5\u7528np.log(x)\u662f\u4e3a\u4e86\u6570\u503c\u7a33\u5b9a\u6027\u3002\u5982\u679c\u67d0\u4e2ax\u503c\u975e\u5e38\u5c0f\u6216\u8005\u4e3a0&#xff0c;log(x)\u4f1a\u5f97\u5230\u8d1f\u65e0\u7a77\u5927\u6216\u9519\u8bef&#xff0c;\u800clog(1 &#043; x)\u5219\u53ef\u4ee5\u5f88\u597d\u5730\u5904\u7406\u8fd9\u79cd\u60c5\u51b5\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">\u4e3a\u4ec0\u4e48\u8981\u5206\u79bb\u6807\u7b7e&#xff1f;<\/span><\/p>\n<p><span style=\"background-color:null\">\u8fd9\u4e2a\u7406\u7531\u548c\u6211\u4eec\u4e4b\u524d\u8ba8\u8bba\u8fc7\u7684\u4e00\u6837&#xff1a;SalePrice\u662f\u6211\u4eec\u8981\u9884\u6d4b\u7684\u7ed3\u679c&#xff0c;\u4e0d\u662f\u7279\u5f81\u3002\u5fc5\u987b\u5c06\u5176\u4ece\u7279\u5f81\u6570\u636e<\/span><span style=\"background-color:#d7d8d9\">train_df<\/span><span style=\"background-color:null\">\u4e2d\u5206\u79bb\u51fa\u6765&#xff0c;\u907f\u514d\u6570\u636e\u6cc4\u9732\u3002<\/span><\/p>\n<\/p>\n<p><span style=\"background-color:null\">\u8bed\u6cd5\u5982\u4f55\u4f7f\u7528&#xff1f;<\/span> <span style=\"background-color:#d7d8d9\">np.log1p(&#8230;)<\/span><span style=\"background-color:null\">: \u8c03\u7528Numpy\u5e93&#xff08;\u522b\u540d\u4e3anp&#xff09;\u7684 log1p \u51fd\u6570&#xff0c;\u5bf9\u4f20\u5165\u7684Pandas Series&#xff08;<\/span><span style=\"background-color:#d7d8d9\">train_df[&#039;SalePrice&#039;]<\/span><span style=\"background-color:null\">&#xff09;\u4e2d\u7684\u6bcf\u4e00\u4e2a\u5143\u7d20\u6267\u884c log(1&#043;x) \u8ba1\u7b97\u3002<\/span><\/p>\n<p><span style=\"background-color:#d7d8d9\">train_df.drop(&#039;SalePrice&#039;, axis&#061;1)<\/span><span style=\"background-color:null\">: \u6211\u4eec\u5df2\u7ecf\u5f88\u719f\u6089\u4e86&#xff0c;\u4ecetrain_df\u4e2d\u5220\u9664\u540d\u4e3a&#039;SalePrice&#039;\u7684\u5217 (axis&#061;1)\u3002<\/span><\/p>\n<p>3. \u6570\u636e\u96c6\u5408\u5e76<\/p>\n<p><span style=\"background-color:#d7d8d9\">all_data &#061; pd.concat([train_df, test_df], axis&#061;0).reset_index(drop&#061;True)<\/span><\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u6709\u4ec0\u4e48\u7528&#xff1f; \u8fd9\u4e00\u884c\u5c06\u5904\u7406\u8fc7\u7684\u8bad\u7ec3\u96c6&#xff08;\u5df2\u79fb\u9664\u5f02\u5e38\u503c\u548cSalePrice\u5217&#xff09;\u548c\u6d4b\u8bd5\u96c6&#xff08;\u5df2\u79fb\u9664Id\u5217&#xff09;\u5782\u76f4\u62fc\u63a5\u6210\u4e00\u4e2a\u5927\u7684\u6570\u636e\u96c6all_data\u3002\u5e76\u4e14&#xff0c;\u5b83\u8fd8\u91cd\u7f6e\u4e86\u8fd9\u4e2a\u65b0\u6570\u636e\u96c6\u7684\u7d22\u5f15\u3002<\/p>\n<p>\u4e3a\u4ec0\u4e48\u7528\u5b83&#xff1f;<\/p>\n<p>\u7edf\u4e00\u5904\u7406&#xff1a;\u76ee\u7684\u548c\u4e4b\u524d\u4e00\u6837&#xff0c;\u5c06\u8bad\u7ec3\u96c6\u548c\u6d4b\u8bd5\u96c6\u7684\u7279\u5f81\u653e\u5728\u4e00\u8d77&#xff0c;\u662f\u4e3a\u4e86\u80fd\u5bf9\u5b83\u4eec\u8fdb\u884c\u5b8c\u5168\u4e00\u81f4\u7684\u540e\u7eed\u5904\u7406&#xff08;\u5982\u586b\u5145\u7f3a\u5931\u503c\u3001\u7279\u5f81\u7f16\u7801\u3001\u7279\u5f81\u7f29\u653e\u7b49&#xff09;\u3002<\/p>\n<p>\u4e3a\u4ec0\u4e48\u8981<span style=\"background-color:#d7d8d9\">.reset_index(drop&#061;True)<\/span>&#xff1f;<\/p>\n<p><span style=\"background-color:#d7d8d9\">pd.concat <\/span>\u5728\u62fc\u63a5\u65f6&#xff0c;\u4f1a\u4fdd\u7559\u539f\u59cb\u7684\u7d22\u5f15\u3002\u6bd4\u5982&#xff0c;\u5982\u679c\u8bad\u7ec3\u96c6\u67091460\u884c&#xff08;\u7d22\u5f150-1459&#xff09;&#xff0c;\u6d4b\u8bd5\u96c6\u67091459\u884c&#xff08;\u7d22\u5f150-1458&#xff09;&#xff0c;\u62fc\u63a5\u540e&#xff0c;all_data\u7684\u7d22\u5f15\u5c31\u4f1a\u662f [0, 1, &#8230;, 1459, 0, 1, &#8230;, 1458]\u3002\u4f60\u4f1a\u53d1\u73b0\u7d22\u5f15\u6709\u5927\u91cf\u91cd\u590d\u3002<\/p>\n<p>\u8fd9\u79cd\u91cd\u590d\u7684\u7d22\u5f15\u5728\u540e\u7eed\u64cd\u4f5c\u4e2d\u53ef\u80fd\u4f1a\u5bfc\u81f4\u610f\u60f3\u4e0d\u5230\u7684\u95ee\u9898\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">.reset_index()<\/span> \u4f1a\u751f\u6210\u4e00\u5957\u65b0\u7684\u3001\u4ece0\u5f00\u59cb\u8fde\u7eed\u9012\u589e\u7684\u7d22\u5f15&#xff08;0, 1, 2, &#8230;, 2917&#xff09;\u3002<\/p>\n<p>\u53c2\u6570 drop&#061;True \u7684\u4f5c\u7528\u662f\u4e22\u5f03\u65e7\u7684\u3001\u6df7\u4e71\u7684\u7d22\u5f15&#xff0c;\u800c\u4e0d\u662f\u628a\u5b83\u5f53\u6210\u4e00\u4e2a\u65b0\u5217\u4fdd\u7559\u4e0b\u6765\u3002\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u5e72\u51c0\u5229\u843d\u7684\u64cd\u4f5c\u3002<\/p>\n<p>\u8bed\u6cd5\u5982\u4f55\u4f7f\u7528&#xff1f; <span style=\"background-color:#d7d8d9\">pd.concat([train_df, test_df], axis&#061;0):<\/span> \u6211\u4eec\u5df2\u7ecf\u719f\u6089&#xff0c;\u6309\u884c (axis&#061;0) \u62fc\u63a5\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">.reset_index(drop&#061;True)<\/span>: \u8fd9\u662f\u4e00\u4e2a\u94fe\u5f0f\u8c03\u7528\u3002pd.concat\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684DataFrame&#xff0c;\u6211\u4eec\u7d27\u63a5\u7740\u5728\u8fd9\u4e2a\u8fd4\u56de\u7684DataFrame\u4e0a\u8c03\u7528.reset_index()\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<h4>\u7b2c\u4e09\u6b65&#xff0c;\u7279\u5f81\u5de5\u7a0b<\/h4>\n<p>\u6211\u4eec\u73b0\u5728\u8fdb\u5165\u4e86\u6574\u4e2a\u9879\u76ee\u4e2d\u6280\u672f\u542b\u91cf\u6700\u9ad8\u3001\u6700\u80fd\u4f53\u73b0\u7ecf\u9a8c\u7684\u90e8\u5206\u2014\u2014\u7279\u5f81\u5de5\u7a0b&#xff08;Feature Engineering&#xff09;\u3002\u8fd9\u6bb5\u4ee3\u7801\u4e13\u6ce8\u4e8e\u5904\u7406\u673a\u5668\u5b66\u4e60\u4e2d\u6700\u5e38\u89c1\u4e5f\u6700\u68d8\u624b\u7684\u95ee\u9898\u4e4b\u4e00&#xff1a;\u7f3a\u5931\u503c&#xff08;Missing Values&#xff09;\u3002<\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u7684\u6574\u4f53\u76ee\u6807\u662f&#xff1a;\u7528\u5408\u7406\u7684\u65b9\u5f0f&#xff0c;\u6709\u7b56\u7565\u5730\u586b\u8865\u6570\u636e\u4e2d\u7684\u7a7a\u767d\u683c&#xff0c;\u8ba9\u6570\u636e\u53d8\u5f97\u5b8c\u6574\u3001\u5e72\u51c0\u3002<\/p>\n<p># 3. \u7279\u5f81\u5de5\u7a0b<br \/>\n# &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p># \u5904\u7406\u7f3a\u5931\u503c<br \/>\nfor col in (&#039;PoolQC&#039;, &#039;MiscFeature&#039;, &#039;Alley&#039;, &#039;Fence&#039;, &#039;FireplaceQu&#039;, &#039;GarageType&#039;,<br \/>\n            &#039;GarageFinish&#039;, &#039;GarageQual&#039;, &#039;GarageCond&#039;, &#039;BsmtQual&#039;, &#039;BsmtCond&#039;,<br \/>\n            &#039;BsmtExposure&#039;, &#039;BsmtFinType1&#039;, &#039;BsmtFinType2&#039;, &#039;MasVnrType&#039;):<br \/>\n    all_data[col] &#061; all_data[col].fillna(&#039;None&#039;)<\/p>\n<p>for col in (&#039;GarageYrBlt&#039;, &#039;GarageArea&#039;, &#039;GarageCars&#039;, &#039;BsmtFinSF1&#039;, &#039;BsmtFinSF2&#039;,<br \/>\n            &#039;BsmtUnfSF&#039;,&#039;TotalBsmtSF&#039;, &#039;BsmtFullBath&#039;, &#039;BsmtHalfBath&#039;, &#039;MasVnrArea&#039;):<br \/>\n    all_data[col] &#061; all_data[col].fillna(0)<\/p>\n<p>all_data[&#039;LotFrontage&#039;] &#061; all_data.groupby(&#039;Neighborhood&#039;)[&#039;LotFrontage&#039;].transform(<br \/>\n    lambda x: x.fillna(x.median()))<\/p>\n<p>for col in (&#039;MSZoning&#039;, &#039;Electrical&#039;, &#039;KitchenQual&#039;, &#039;Exterior1st&#039;, &#039;Exterior2nd&#039;, &#039;SaleType&#039;, &#039;Functional&#039;):<br \/>\n    all_data[col] &#061; all_data[col].fillna(all_data[col].mode()[0])<\/p>\n<p># \u5220\u9664\u9ad8\u7f3a\u5931\u7387\u7684\u5217<br \/>\nall_data &#061; all_data.drop([&#039;Utilities&#039;], axis&#061;1) <\/p>\n<p>\u7b56\u7565\u4e00&#xff1a;\u7528&#034;None&#034;\u586b\u5145\u8868\u793a\u201c\u6ca1\u6709\u201d\u7684\u7c7b\u522b<\/p>\n<p><span style=\"background-color:#d7d8d9\">for col in (&#039;PoolQC&#039;, &#039;MiscFeature&#039;, &#039;Alley&#039;, &#039;Fence&#039;, &#039;FireplaceQu&#039;, &#039;GarageType&#039;, &#039;GarageFinish&#039;, &#039;GarageQual&#039;, &#039;GarageCond&#039;, &#039;BsmtQual&#039;, &#039;BsmtCond&#039;, &#039;BsmtExposure&#039;, &#039;BsmtFinType1&#039;, &#039;BsmtFinType2&#039;, &#039;MasVnrType&#039;): <\/span><\/p>\n<p><span style=\"background-color:#d7d8d9\">all_data[col] &#061; all_data[col].fillna(&#039;None&#039;)<\/span><\/p>\n<p><span style=\"background-color:null\">\u5b83\u5728\u505a\u4ec0\u4e48&#xff1f;<\/span> <span style=\"background-color:null\">\u8fd9\u6bb5\u4ee3\u7801\u904d\u5386\u4e00\u4e2a\u5305\u542b\u591a\u4e2a\u7c7b\u522b\u578b\u7279\u5f81\u540d\u79f0\u7684\u5217\u8868\u3002\u5bf9\u4e8e\u5217\u8868\u4e2d\u7684\u6bcf\u4e00\u5217&#xff0c;\u5b83\u90fd\u4f7f\u7528\u5b57\u7b26\u4e32&#039;None&#039;\u6765\u586b\u5145\u8be5\u5217\u4e2d\u6240\u6709\u7684\u7f3a\u5931\u503c&#xff08;\u5728Pandas\u4e2d\u901a\u5e38\u662fNaN&#xff09;\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">\u4e3a\u4ec0\u4e48\u8981\u8fd9\u4e48\u505a&#xff1f; \u8fd9\u91cc\u7684\u6838\u5fc3\u601d\u60f3\u662f&#xff1a;\u7f3a\u5931\u672c\u8eab\u5c31\u662f\u4e00\u79cd\u4fe1\u606f\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">\u5728\u8fd9\u4e9b\u7279\u5b9a\u7684\u5217\u4e2d&#xff0c;\u4e00\u4e2a\u7f3a\u5931\u503c(NaN)\u7684\u542b\u4e49\u5e76\u4e0d\u662f\u201c\u6570\u636e\u672a\u77e5\u201d\u6216\u201c\u5fd8\u4e86\u586b\u201d&#xff0c;\u800c\u662f\u4ee3\u8868\u201c\u8fd9\u680b\u623f\u5b50\u6ca1\u6709\u8fd9\u4e2a\u8bbe\u65bd\u201d\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">PoolQC&#xff08;\u6e38\u6cf3\u6c60\u8d28\u91cf&#xff09;\u7f3a\u5931&#xff0c;\u610f\u5473\u7740\u6ca1\u6709\u6e38\u6cf3\u6c60\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">GarageType&#xff08;\u8f66\u5e93\u7c7b\u578b&#xff09;\u7f3a\u5931&#xff0c;\u610f\u5473\u7740\u6ca1\u6709\u8f66\u5e93\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">Alley&#xff08;\u5c0f\u5df7\u901a\u9053&#xff09;\u7f3a\u5931&#xff0c;\u610f\u5473\u7740\u6ca1\u6709\u5c0f\u5df7\u901a\u9053\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">\u56e0\u6b64&#xff0c;\u7528&#039;None&#039;\u8fd9\u4e2a\u65b0\u7684\u7c7b\u522b\u6765\u586b\u5145&#xff0c;\u662f\u5b8c\u5168\u7b26\u5408\u903b\u8f91\u7684\u3002\u6211\u4eec\u4e0d\u4ec5\u586b\u8865\u4e86\u7a7a\u767d&#xff0c;\u8fd8\u521b\u9020\u4e86\u4e00\u4e2a\u6709\u5b9e\u9645\u610f\u4e49\u7684\u65b0\u7c7b\u522b&#xff0c;\u6a21\u578b\u53ef\u4ee5\u4ece\u4e2d\u5b66\u4e60\u5230\u201c\u6ca1\u6709\u67d0\u9879\u8bbe\u65bd\u201d\u5bf9\u623f\u4ef7\u7684\u5f71\u54cd\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">\u8bed\u6cd5\u8bb2\u89e3<\/span> <span style=\"background-color:#d7d8d9\">for col in (&#8230;):<\/span><span style=\"background-color:null\"> \u4e00\u4e2a\u6807\u51c6\u7684for\u5faa\u73af&#xff0c;col\u53d8\u91cf\u5728\u6bcf\u6b21\u5faa\u73af\u4e2d\u4f1a\u4f9d\u6b21\u6210\u4e3a\u5143\u7ec4(&#8230;)\u4e2d\u7684\u4e00\u4e2a\u5217\u540d\u5b57\u7b26\u4e32\u3002<\/span><\/p>\n<p><span style=\"background-color:#d7d8d9\">all_data[col]<\/span><span style=\"background-color:null\">: \u9009\u53d6all_data\u8fd9\u4e2aDataFrame\u4e2d\u540d\u4e3acol\u7684\u6574\u5217\u3002&#xff08;<\/span><span style=\"background-color:#d7d8d9\">all_data<\/span><span style=\"background-color:null\">\u662f\u4e4b\u524d\u6211\u4eec\u5408\u5e76\u7684\u8bad\u7ec3\u96c6\u4e0e\u6d4b\u8bd5\u96c6&#xff09;<\/span><\/p>\n<p><span style=\"background-color:#d7d8d9\">.fillna(&#039;None&#039;)<\/span><span style=\"background-color:null\">: \u8fd9\u662fPandas Series&#xff08;\u5217&#xff09;\u7684\u4e00\u4e2a\u65b9\u6cd5&#xff0c;\u5b83\u4f1a\u627e\u5230\u6240\u6709NaN\u503c&#xff0c;\u5e76\u7528\u62ec\u53f7\u91cc\u63d0\u4f9b\u7684\u503c&#xff08;\u8fd9\u91cc\u662f\u5b57\u7b26\u4e32&#039;None&#039;&#xff09;\u6765\u586b\u5145\u5b83\u4eec\u3002<\/span><\/p>\n<p>\u7b56\u7565\u4e8c&#xff1a;\u7528 0 \u586b\u5145\u8868\u793a\u201c\u6ca1\u6709\u201d\u7684\u6570\u503c<\/p>\n<p><span style=\"background-color:#d7d8d9\">for col in (&#039;GarageYrBlt&#039;, &#039;GarageArea&#039;, &#039;GarageCars&#039;, &#039;BsmtFinSF1&#039;, &#039;BsmtFinSF2&#039;,\u00a0<\/span> <span style=\"background-color:#d7d8d9\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 &#039;BsmtUnfSF&#039;,&#039;TotalBsmtSF&#039;, &#039;BsmtFullBath&#039;, &#039;BsmtHalfBath&#039;, &#039;MasVnrArea&#039;):<\/span> <span style=\"background-color:#d7d8d9\">\u00a0 \u00a0 all_data[col] &#061; all_data[col].fillna(0)<\/span><\/p>\n<p><span style=\"background-color:null\">\u5b83\u5728\u505a\u4ec0\u4e48&#xff1f;<\/span> <span style=\"background-color:null\">\u8fd9\u6bb5\u4ee3\u7801\u904d\u5386\u4e00\u4e2a\u6570\u503c\u578b\u7279\u5f81\u7684\u5217\u8868&#xff0c;\u5e76\u5c06\u8fd9\u4e9b\u5217\u4e2d\u7684\u6240\u6709\u7f3a\u5931\u503c\u586b\u5145\u4e3a0\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">\u4e3a\u4ec0\u4e48\u8981\u8fd9\u4e48\u505a&#xff1f;<\/span> <span style=\"background-color:null\">\u8fd9\u4e2a\u7b56\u7565\u4e0e\u4e0a\u4e00\u4e2a\u7d27\u5bc6\u76f8\u8fde\u3002\u5982\u679c\u4e00\u680b\u623f\u5b50\u6ca1\u6709\u8f66\u5e93&#xff08;GarageType\u662f&#039;None&#039;&#xff09;&#xff0c;\u90a3\u4e48\u5b83\u7684\u8f66\u5e93\u9762\u79ef&#xff08;GarageArea&#xff09;\u3001\u8f66\u5e93\u5bb9\u91cf&#xff08;GarageCars&#xff09;\u548c\u8f66\u5e93\u5efa\u9020\u5e74\u4efd&#xff08;GarageYrBlt&#xff09;\u81ea\u7136\u5c31\u5e94\u8be5\u662f0\u3002\u540c\u7406&#xff0c;\u6ca1\u6709\u5730\u4e0b\u5ba4\u7684\u623f\u5b50&#xff0c;\u5176\u5730\u4e0b\u5ba4\u76f8\u5173\u7684\u9762\u79ef\u548c\u6d74\u5ba4\u6570\u91cf\u4e5f\u5e94\u8be5\u662f0\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">\u6240\u4ee5&#xff0c;\u8fd9\u91cc\u76840\u4e0d\u662f\u4e00\u4e2a\u968f\u610f\u7684\u586b\u5145\u503c&#xff0c;\u800c\u662f\u903b\u8f91\u63a8\u65ad\u51fa\u7684\u771f\u5b9e\u6570\u503c\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">\u7b56\u7565\u4e09&#xff1a;\u7528\u5206\u7ec4\u4e2d\u4f4d\u6570\u586b\u5145<\/span><\/p>\n<p><span style=\"background-color:#d7d8d9\">all_data[&#039;LotFrontage&#039;] &#061; all_data.groupby(&#039;Neighborhood&#039;)[&#039;LotFrontage&#039;].transform(<\/span> <span style=\"background-color:#d7d8d9\">\u00a0 \u00a0 lambda x: x.fillna(x.median()))<\/span><\/p>\n<p><span style=\"background-color:null\">\u5b83\u5728\u505a\u4ec0\u4e48&#xff1f;<\/span> <span style=\"background-color:null\">\u8fd9\u884c\u4ee3\u7801\u7528\u4e00\u79cd\u66f4\u667a\u80fd\u7684\u65b9\u5f0f\u586b\u5145LotFrontage&#xff08;\u4e0e\u8857\u9053\u76f8\u8fde\u7684\u7ebf\u6027\u82f1\u5c3a\u6570&#xff09;\u7684\u7f3a\u5931\u503c\u3002\u5b83\u4e0d\u662f\u7528\u4e00\u4e2a\u5168\u5c40\u7684\u7edf\u4e00\u503c\u6765\u586b\u5145&#xff0c;\u800c\u662f\u6839\u636e\u6bcf\u680b\u623f\u5b50\u6240\u5728\u7684\u793e\u533a&#xff08;Neighborhood&#xff09;&#xff0c;\u7528\u8be5\u793e\u533a\u5185\u6240\u6709\u623f\u5b50\u7684LotFrontage\u7684\u4e2d\u4f4d\u6570\u6765\u586b\u5145\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">\u4e3a\u4ec0\u4e48\u8981\u8fd9\u4e48\u505a&#xff1f;<\/span> <span style=\"background-color:null\">\u8fd9\u4f53\u73b0\u4e86\u201c\u5177\u4f53\u95ee\u9898\u5177\u4f53\u5206\u6790\u201d\u7684\u601d\u60f3\u3002\u623f\u5b50\u7684\u4e34\u8857\u5bbd\u5ea6\u5f88\u53ef\u80fd\u4e0e\u5b83\u6240\u5728\u7684\u793e\u533a\u89c4\u5212\u6709\u5173\u3002\u540c\u4e00\u4e2a\u793e\u533a\u7684\u623f\u5b50&#xff0c;\u5176\u4e34\u8857\u5bbd\u5ea6\u5f80\u5f80\u6bd4\u8f83\u76f8\u4f3c\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">\u7b80\u5355\u65b9\u6cd5&#xff1a;\u7528\u6240\u6709\u623f\u5b50\u7684LotFrontage\u7684\u5e73\u5747\u503c\u6216\u4e2d\u4f4d\u6570\u6765\u586b\u5145\u3002\u8fd9\u79cd\u65b9\u6cd5\u592a\u7c97\u7cd9&#xff0c;\u53ef\u80fd\u4f1a\u7ed9\u4e00\u4e2a\u9ad8\u6863\u793e\u533a\u7684\u623f\u5b50\u5206\u914d\u4e00\u4e2a\u6765\u81ea\u8d2b\u6c11\u533a\u7684\u4e2d\u4f4d\u6570&#xff0c;\u4e0d\u5408\u7406\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">\u806a\u660e\u65b9\u6cd5&#xff1a;\u6211\u4eec\u5047\u8bbe&#xff0c;\u4e00\u680b\u623f\u5b50\u7f3a\u5931\u7684\u4e34\u8857\u5bbd\u5ea6&#xff0c;\u6700\u53ef\u80fd\u63a5\u8fd1\u5b83\u90bb\u5c45\u4eec\u7684\u666e\u904d\u6c34\u5e73\u3002\u8fd9\u79cd\u57fa\u4e8e\u5206\u7ec4\u7684\u586b\u5145\u65b9\u5f0f&#xff0c;\u4f7f\u5f97\u586b\u5145\u503c\u66f4\u5177\u4e0a\u4e0b\u6587\u76f8\u5173\u6027&#xff0c;\u4e5f\u66f4\u7cbe\u786e\u3002<\/span><\/p>\n<p>\u8bed\u6cd5\u8bb2\u89e3<\/p>\n<p>\u8fd9\u884c\u94fe\u5f0f\u8c03\u7528\u662fPandas\u9ad8\u7ea7\u7528\u6cd5&#xff0c;\u6211\u4eec\u628a\u5b83\u62c6\u5f00\u770b&#xff1a;<\/p>\n<p><span style=\"background-color:#d7d8d9\">all_data.groupby(&#039;Neighborhood&#039;)<\/span>: \u5c06\u6574\u4e2a\u6570\u636e\u96c6\u6309\u7167&#039;Neighborhood&#039;\u5217\u7684\u503c\u8fdb\u884c\u5206\u7ec4\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">[&#039;LotFrontage&#039;]:<\/span> \u5728\u6bcf\u4e2a\u5206\u7ec4\u5185\u90e8&#xff0c;\u9009\u53d6&#039;LotFrontage&#039;\u8fd9\u4e00\u5217\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">.transform(&#8230;):<\/span>\u00a0\u5b83\u4f1a\u5bf9\u6bcf\u4e2a\u5206\u7ec4\u6267\u884c\u62ec\u53f7\u91cc\u7684\u51fd\u6570&#xff0c;\u7136\u540e\u8fd4\u56de\u4e00\u4e2a\u548c\u539f\u59cball_data\u4e00\u6837\u957f\u3001\u7d22\u5f15\u4e5f\u5b8c\u5168\u5bf9\u9f50\u7684Series&#xff0c;\u53ef\u4ee5\u76f4\u63a5\u8d4b\u503c\u56de\u53bb\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">lambda x: x.fillna(x.median())<\/span>: \u8fd9\u662f\u4e00\u4e2a\u533f\u540d\u51fd\u6570\u3002<\/p>\n<p>x\u5728\u6bcf\u6b21\u8c03\u7528\u65f6&#xff0c;\u4ee3\u8868\u4e00\u4e2a\u5206\u7ec4&#xff08;\u5373\u67d0\u4e2a\u793e\u533a\u6240\u6709\u623f\u5b50\u7684LotFrontage\u503c&#xff09;\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">x.median()<\/span>: \u8ba1\u7b97\u8fd9\u4e2a\u5206\u7ec4&#xff08;x&#xff09;\u7684\u4e2d\u4f4d\u6570\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">x.fillna(&#8230;)<\/span>: \u7528\u521a\u7b97\u51fa\u7684\u8fd9\u4e2a\u4e2d\u4f4d\u6570&#xff0c;\u6765\u586b\u5145\u8fd9\u4e2a\u5206\u7ec4&#xff08;x&#xff09;\u5185\u90e8\u7684\u7f3a\u5931\u503c\u3002<\/p>\n<p>\u7b56\u7565\u56db&#xff1a;\u7528\u4f17\u6570\u586b\u5145\u5e38\u89c4\u7c7b\u522b<\/p>\n<p><span style=\"background-color:#d7d8d9\">for col in (&#039;MSZoning&#039;, &#039;Electrical&#039;, &#039;KitchenQual&#039;, &#039;Exterior1st&#039;, &#039;Exterior2nd&#039;, &#039;SaleType&#039;, &#039;Functional&#039;):<\/span> <span style=\"background-color:#d7d8d9\">\u00a0 \u00a0 all_data[col] &#061; all_data[col].fillna(all_data[col].mode()[0])<\/span><\/p>\n<p><span style=\"background-color:null\">\u5b83\u5728\u505a\u4ec0\u4e48&#xff1f;<\/span> <span style=\"background-color:null\">\u8fd9\u6bb5\u4ee3\u7801\u5bf9\u53e6\u4e00\u4e9b\u7c7b\u522b\u578b\u7279\u5f81\u7684\u7f3a\u5931\u503c&#xff0c;\u4f7f\u7528\u8be5\u5217\u7684\u4f17\u6570&#xff08;mode&#xff0c;\u5373\u51fa\u73b0\u6b21\u6570\u6700\u591a\u7684\u503c&#xff09;\u6765\u8fdb\u884c\u586b\u5145\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">\u4e3a\u4ec0\u4e48\u8981\u8fd9\u4e48\u505a&#xff1f;<\/span> <span style=\"background-color:null\">\u5bf9\u4e8e\u8fd9\u4e9b\u5217&#xff0c;\u7f3a\u5931\u503c\u66f4\u53ef\u80fd\u662f\u968f\u673a\u7684\u6570\u636e\u5f55\u5165\u9057\u6f0f\u3002\u6700\u4fdd\u9669\u3001\u6700\u5408\u7406\u7684\u731c\u6d4b\u662f&#xff0c;\u8fd9\u4e2a\u7f3a\u5931\u7684\u503c\u5c31\u662f\u8be5\u5217\u6700\u5e38\u89c1\u7684\u90a3\u4e2a\u503c\u3002\u4f8b\u5982&#xff0c;\u5982\u679cMSZoning&#xff08;\u533a\u57df\u5206\u7c7b&#xff09;\u7f3a\u5931\u4e86&#xff0c;\u800c\u6570\u636e\u96c6\u4e2d90%\u7684\u623f\u5b50\u90fd\u662f&#039;RL&#039;&#xff08;\u4f4f\u5b85\u4f4e\u5bc6\u5ea6\u533a&#xff09;&#xff0c;\u90a3\u4e48\u6211\u4eec\u5c31\u6709\u7406\u7531\u76f8\u4fe1\u8fd9\u4e2a\u7f3a\u5931\u503c\u4e5f\u5e94\u8be5\u662f&#039;RL&#039;\u3002<\/span><\/p>\n<p><span style=\"background-color:null\">\u8bed\u6cd5\u8bb2\u89e3<\/span> <span style=\"background-color:#d7d8d9\">all_data[col].mode():<\/span><span style=\"background-color:null\"> \u8ba1\u7b97col\u8fd9\u4e00\u5217\u7684\u4f17\u6570\u3002\u6ce8\u610f&#xff0c;\u5b83\u8fd4\u56de\u7684\u662f\u4e00\u4e2aPandas Series&#xff0c;\u56e0\u4e3a\u4e00\u5217\u4e2d\u53ef\u80fd\u5b58\u5728\u591a\u4e2a\u4f17\u6570&#xff08;\u51fa\u73b0\u6b21\u6570\u76f8\u540c&#xff09;\u3002<\/span><\/p>\n<p><span style=\"background-color:#d7d8d9\">[0]<\/span><span style=\"background-color:null\">: \u6211\u4eec\u901a\u8fc7\u7d22\u5f15[0]\u6765\u53d6\u7b2c\u4e00\u4e2a\u4f17\u6570\u3002\u5373\u4f7f\u53ea\u6709\u4e00\u4e2a\u4f17\u6570&#xff0c;\u8fd9\u4e2a\u64cd\u4f5c\u4e5f\u80fd\u786e\u4fdd\u6211\u4eec\u5f97\u5230\u7684\u662f\u4e00\u4e2a\u5355\u4e00\u7684\u503c\u800c\u4e0d\u662f\u4e00\u4e2aSeries&#xff0c;\u4ece\u800c\u53ef\u4ee5\u7528\u6765\u586b\u5145\u3002<\/span><\/p>\n<p>\u7b56\u7565\u4e94&#xff1a;\u5220\u9664\u65e0\u7528\u5217<\/p>\n<p><span style=\"background-color:#d7d8d9\"># \u5220\u9664\u9ad8\u7f3a\u5931\u7387\u7684\u5217<\/span> <span style=\"background-color:#d7d8d9\">all_data &#061; all_data.drop([&#039;Utilities&#039;], axis&#061;1)<\/span><\/p>\n<p>\u8fd9\u884c\u4ee3\u7801\u76f4\u63a5\u5220\u9664\u4e86&#039;Utilities&#039;&#xff08;\u516c\u5171\u8bbe\u65bd&#xff09;\u8fd9\u4e00\u6574\u5217\u3002<\/p>\n<\/p>\n<p>\u00a0\u4e3a\u4ec0\u4e48\u8981\u8fd9\u4e48\u505a&#xff1f;<\/p>\n<p>\u901a\u8fc7\u6570\u636e\u63a2\u7d22\u53ef\u4ee5\u53d1\u73b0&#xff0c;&#039;Utilities&#039;\u8fd9\u4e00\u5217\u51e0\u4e4e\u6240\u6709\u884c\u7684\u503c\u90fd\u662f\u4e00\u6837\u7684&#xff08;\u6bd4\u5982\u90fd\u662f&#039;AllPub&#039;&#xff09;&#xff0c;\u53ea\u6709\u6781\u5c11\u6570\u51e0\u4e2a\u4f8b\u5916\u3002\u4e00\u4e2a\u51e0\u4e4e\u6ca1\u6709\u53d8\u5316\u7684\u7279\u5f81&#xff0c;\u5bf9\u4e8e\u6a21\u578b\u533a\u5206\u4e0d\u540c\u623f\u4ef7\u6765\u8bf4&#xff0c;\u51e0\u4e4e\u63d0\u4f9b\u4e0d\u4e86\u4efb\u4f55\u6709\u7528\u7684\u4fe1\u606f\u3002\u7559\u7740\u5b83\u53cd\u800c\u4f1a\u589e\u52a0\u8ba1\u7b97\u7684\u590d\u6742\u6027&#xff0c;\u6240\u4ee5\u76f4\u63a5\u5220\u9664\u662f\u6700\u597d\u7684\u9009\u62e9\u3002<\/p>\n<\/p>\n<p>\u65b0\u7279\u5f81&#xff0c;\u4e3a\u4e86\u66f4\u597d\u7684\u7ed3\u679c<\/p>\n<p>\u8fd9\u90e8\u5206\u662f\u7279\u5f81\u5de5\u7a0b\u7684\u521b\u65b0&#xff0c;\u5b83\u4e0d\u518d\u662f\u4fee\u8865\u6570\u636e&#xff08;\u5904\u7406\u7f3a\u5931\u503c&#xff09;&#xff0c;\u800c\u662f\u521b\u9020\u5168\u65b0\u7684\u7279\u5f81\u3002<\/p>\n<p>\u8fd9\u6574\u6bb5\u4ee3\u7801\u7684\u76ee\u6807\u662f&#xff1a;\u901a\u8fc7\u7ec4\u5408\u6216\u53d8\u6362\u73b0\u6709\u7684\u5217&#xff0c;\u751f\u6210\u4e00\u4e9b\u65b0\u7684\u3001\u5bf9\u623f\u4ef7\u9884\u6d4b\u66f4\u6709\u5e2e\u52a9\u7684\u7279\u5f81\u3002<\/p>\n<\/p>\n<p># \u521b\u65b0\u7279\u5f81<br \/>\nall_data[&#039;TotalSF&#039;] &#061; all_data[&#039;TotalBsmtSF&#039;] &#043; all_data[&#039;1stFlrSF&#039;] &#043; all_data[&#039;2ndFlrSF&#039;]<br \/>\nall_data[&#039;TotalBath&#039;] &#061; (all_data[&#039;FullBath&#039;] &#043;<br \/>\n                        0.5 * all_data[&#039;HalfBath&#039;] &#043;<br \/>\n                        all_data[&#039;BsmtFullBath&#039;] &#043;<br \/>\n                        0.5 * all_data[&#039;BsmtHalfBath&#039;])<br \/>\nall_data[&#039;Age&#039;] &#061; all_data[&#039;YrSold&#039;] &#8211; all_data[&#039;YearBuilt&#039;]<br \/>\nall_data[&#039;RemodelAge&#039;] &#061; all_data[&#039;YrSold&#039;] &#8211; all_data[&#039;YearRemodAdd&#039;]<br \/>\nall_data[&#039;HasPool&#039;] &#061; all_data[&#039;PoolArea&#039;].apply(lambda x: 1 if x &gt; 0 else 0)<br \/>\nall_data[&#039;TotalPorchSF&#039;] &#061; (all_data[&#039;OpenPorchSF&#039;] &#043;<br \/>\n                            all_data[&#039;EnclosedPorch&#039;] &#043;<br \/>\n                            all_data[&#039;3SsnPorch&#039;] &#043;<br \/>\n                            all_data[&#039;ScreenPorch&#039;]) <\/p>\n<p><span style=\"background-color:#d7d8d9\">\u200b\u200b\u200b\u200b\u200b\u200b<\/span><span style=\"background-color:#d7d8d9\">TotalSF<\/span>&#xff1a;\u5c06\u5730\u4e0b\u5ba4\u3001\u4e00\u697c\u548c\u4e8c\u697c\u7684\u9762\u79ef\u76f8\u52a0&#xff0c;\u5f97\u5230\u623f\u5c4b\u7684\u603b\u5c45\u4f4f\u9762\u79ef\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">TotalBath<\/span>&#xff1a;\u5c06\u6240\u6709\u6d74\u5ba4&#xff08;\u5730\u4e0a\u7684\u3001\u5730\u4e0b\u5ba4\u7684\u3001\u5168\u536b\u3001\u534a\u536b&#xff09;\u7684\u6570\u91cf\u76f8\u52a0&#xff0c;\u5f97\u5230\u4e00\u4e2a\u52a0\u6743\u7684\u603b\u6d74\u5ba4\u6570\u3002\u5176\u4e2d&#xff0c;\u534a\u536b&#xff08;HalfBath&#xff0c;\u901a\u5e38\u6307\u6ca1\u6709\u6dcb\u6d74\u6216\u6d74\u7f38\u7684\u536b\u751f\u95f4&#xff09;\u63090.5\u4e2a\u8ba1\u7b97\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">Age<\/span>&#xff1a;\u7528\u51fa\u552e\u5e74\u4efd\u51cf\u53bb\u5efa\u9020\u5e74\u4efd&#xff0c;\u5f97\u5230\u623f\u5b50\u5728\u552e\u51fa\u65f6\u7684\u5b9e\u9645\u5e74\u9f84\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">RemodelAge<\/span>&#xff1a;\u7528\u51fa\u552e\u5e74\u4efd\u51cf\u53bb\u6700\u8fd1\u4e00\u6b21\u7ffb\u65b0\u5e74\u4efd&#xff0c;\u5f97\u5230\u8ddd\u79bb\u4e0a\u6b21\u7ffb\u65b0\u8fc7\u4e86\u591a\u5c11\u5e74\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">HasPool<\/span>&#xff1a;\u8fd9\u662f\u4e00\u4e2a\u4e8c\u5143\u7279\u5f81&#xff08;Binary Feature&#xff09;\u3002\u5b83\u68c0\u67e5 <span style=\"background-color:#d7d8d9\">PoolArea<\/span>&#xff08;\u6cf3\u6c60\u9762\u79ef&#xff09;\u5217&#xff0c;\u5982\u679c\u9762\u79ef\u5927\u4e8e0&#xff0c;\u5c31\u8d4b\u503c\u4e3a1&#xff08;\u4ee3\u8868\u201c\u6709\u201d&#xff09;&#xff1b;\u5982\u679c\u9762\u79ef\u7b49\u4e8e0&#xff0c;\u5c31\u8d4b\u503c\u4e3a0&#xff08;\u4ee3\u8868\u201c\u65e0\u201d&#xff09;\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">TotalPorchSF<\/span>&#xff1a;\u5c06\u56db\u79cd\u4e0d\u540c\u7c7b\u578b\u7684\u95e8\u5eca\/\u9633\u53f0\u9762\u79ef\u5168\u90e8\u76f8\u52a0&#xff0c;\u5f97\u5230\u4e00\u4e2a\u603b\u7684\u95e8\u5eca\u9762\u79ef\u3002<\/p>\n<p> \u8bed\u6cd5\u8bb2\u89e3<\/p>\n<p><span style=\"background-color:#d7d8d9\">all_data[&#039;PoolArea&#039;].apply(lambda x: 1 if x &gt; 0 else 0)<\/span><\/p>\n<p><span style=\"background-color:#d7d8d9\">.apply()<\/span><span style=\"background-color:null\"> \u662fPandas\u7684\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684\u65b9\u6cd5&#xff0c;\u5b83\u53ef\u4ee5\u5c06\u4e00\u4e2a\u51fd\u6570\u5e94\u7528\u5230\u5217\u4e2d\u7684\u6bcf\u4e00\u4e2a\u5143\u7d20\u4e0a\u3002<\/span><\/p>\n<p><span style=\"background-color:#d7d8d9\">lambda x<\/span><span style=\"background-color:null\">: &#8230; \u662f\u4e00\u4e2a\u533f\u540d\u51fd\u6570\u3002\u8fd9\u91cc\u7684 x \u4f9d\u6b21\u4ee3\u8868 PoolArea \u5217\u4e2d\u7684\u6bcf\u4e00\u4e2a\u503c\u3002<\/span><\/p>\n<p><span style=\"background-color:#d7d8d9\">1 if x &gt; 0 else 0<\/span><span style=\"background-color:null\">&#xff1a;\u8fd9\u662f\u4e00\u4e2a\u4e09\u5143\u8868\u8fbe\u5f0f\u3002\u5982\u679c x &gt; 0 \u8fd9\u4e2a\u6761\u4ef6\u6210\u7acb&#xff0c;\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\u5c31\u662f1&#xff1b;\u5426\u5219&#xff0c;\u7ed3\u679c\u5c31\u662f0\u3002<\/span><\/p>\n<p>\u5408\u8d77\u6765&#xff0c;\u8fd9\u884c\u4ee3\u7801\u7684\u610f\u601d\u5c31\u662f&#xff1a;\u201c\u904d\u5386<span style=\"background-color:#d7d8d9\">PoolArea<\/span>\u5217\u7684\u6bcf\u4e00\u4e2a\u503c&#xff0c;\u5982\u679c\u503c\u5927\u4e8e0&#xff0c;\u5c31\u8fd4\u56de1&#xff0c;\u5426\u5219\u8fd4\u56de0\u201d&#xff0c;\u4ece\u800c\u751f\u6210\u4e86\u4e00\u4e2a\u53ea\u5305\u542b0\u548c1\u7684\u65b0\u5217\u3002<\/p>\n<\/p>\n<h4>\u7b2c\u56db\u6b65&#xff0c;\u504f\u6001\u5904\u7406\u4e0e\u72ec\u70ed\u7f16\u7801<\/h4>\n<\/p>\n<p># \u5904\u7406\u504f\u6001\u6570\u503c\u7279\u5f81<br \/>\nnumeric_feats &#061; all_data.dtypes[all_data.dtypes !&#061; &#034;object&#034;].index<br \/>\nskewed_feats &#061; all_data[numeric_feats].apply(lambda x: x.skew()).sort_values(ascending&#061;False)<br \/>\nskewness &#061; skewed_feats[abs(skewed_feats) &gt; 0.75]<br \/>\nprint(f&#034;\\\\nFound {len(skewness)} skewed numerical features for log transformation.&#034;)<\/p>\n<p>for feat in skewness.index:<br \/>\n    if all_data[feat].min() &gt; 0:<br \/>\n        all_data[feat] &#061; np.log1p(all_data[feat])<br \/>\n    else:<br \/>\n        all_data[feat] &#061; np.sign(all_data[feat]) * np.log1p(np.abs(all_data[feat]) &#043; 1)<\/p>\n<p># One-Hot Encoding<br \/>\nall_data &#061; pd.get_dummies(all_data, drop_first&#061;True)<br \/>\nprint(f&#034;Feature engineering complete. Total features: {all_data.shape[1]}&#034;) <\/p>\n<p>1.\u5904\u7406\u6570\u503c\u7279\u5f81\u7684\u504f\u6001 (Handling Skew in Numerical Features)<\/p>\n<p># \u5904\u7406\u504f\u6001\u6570\u503c\u7279\u5f81<br \/>\nnumeric_feats &#061; all_data.dtypes[all_data.dtypes !&#061; &#034;object&#034;].index<br \/>\nskewed_feats &#061; all_data[numeric_feats].apply(lambda x: x.skew()).sort_values(ascending&#061;False)<br \/>\nskewness &#061; skewed_feats[abs(skewed_feats) &gt; 0.75]<br \/>\nprint(f&#034;\\\\nFound {len(skewness)} skewed numerical features for log transformation.&#034;)<\/p>\n<p>for feat in skewness.index:<br \/>\n    if all_data[feat].min() &gt;&#061; 0: # Note: I adjusted this to &gt;&#061; 0 for robustness<br \/>\n        all_data[feat] &#061; np.log1p(all_data[feat])<br \/>\n    # The &#039;else&#039; part in your original code is less common; log1p on positive data is the main takeaway. <\/p>\n<p>\u5b83\u5728\u505a\u4ec0\u4e48&#xff1f;<\/p>\n<\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u5206\u4e3a\u4e24\u6b65&#xff1a;<\/p>\n<p>\u8bca\u65ad&#xff1a;\u627e\u51fa\u6240\u6709\u6570\u503c\u578b\u7684\u7279\u5f81&#xff0c;\u8ba1\u7b97\u5b83\u4eec\u7684\u504f\u6001\u7cfb\u6570&#xff08;skewness&#xff09;&#xff0c;\u7136\u540e\u7b5b\u9009\u51fa\u90a3\u4e9b\u504f\u6001\u7a0b\u5ea6\u8fc7\u9ad8&#xff08;\u7edd\u5bf9\u503c\u5927\u4e8e0.75&#xff09;\u7684\u7279\u5f81\u3002<\/p>\n<p>\u6539\u53d8&#xff1a;\u5bf9\u8fd9\u4e9b\u7b5b\u9009\u51fa\u6765\u7684\u201c\u6b6a\u201d\u7279\u5f81&#xff0c;\u5e94\u7528\u5bf9\u6570\u8f6c\u6362&#xff08;log transformation&#xff09;&#xff0c;\u6765\u6539\u53d8\u5b83\u4eec&#xff0c;\u4f7f\u5176\u5206\u5e03\u66f4\u63a5\u8fd1\u5bf9\u79f0\u7684\u6b63\u6001\u5206\u5e03&#xff08;\u949f\u5f62\u66f2\u7ebf&#xff09;\u3002<\/p>\n<p>\u4e3a\u4ec0\u4e48\u8981\u8fd9\u4e48\u505a&#xff1f; \u8bb8\u591a\u673a\u5668\u5b66\u4e60\u6a21\u578b\u5728\u6570\u636e\u5206\u5e03\u66f4\u201c\u4e56\u201d&#xff08;\u5373\u63a5\u8fd1\u6b63\u6001\u5206\u5e03&#xff09;\u65f6&#xff0c;\u8868\u73b0\u4f1a\u66f4\u597d\u3001\u66f4\u7a33\u5b9a\u3002<\/p>\n<p>\u504f\u6001&#xff08;Skewness&#xff09; \u662f\u8861\u91cf\u6570\u636e\u5206\u5e03\u4e0d\u5bf9\u79f0\u6027\u7684\u6307\u6807\u3002\u4e00\u4e2a\u4e25\u91cd\u53f3\u504f&#xff08;\u6709\u4e00\u4e2a\u957f\u957f\u7684\u53f3\u5c3e\u5df4&#xff09;\u7684\u7279\u5f81&#xff0c;\u610f\u5473\u7740\u5927\u90e8\u5206\u6570\u636e\u70b9\u90fd\u6324\u5728\u4f4e\u6570\u503c\u533a&#xff0c;\u800c\u5c11\u6570\u6781\u9ad8\u7684\u503c\u4f1a\u4e0d\u6210\u6bd4\u4f8b\u5730\u5f71\u54cd\u6a21\u578b&#xff0c;\u50cf\u4e00\u4e2a\u201c\u574f\u5b66\u751f\u201d\u4e00\u6837\u628a\u6574\u4e2a\u6a21\u578b\u7684\u201c\u6ce8\u610f\u529b\u201d\u90fd\u62c9\u8fc7\u53bb\u3002<\/p>\n<p>\u901a\u8fc7log\u8f6c\u6362&#xff0c;\u6211\u4eec\u53ef\u4ee5\u6709\u6548\u5730\u201c\u538b\u7f29\u201d\u9ad8\u7aef\u6570\u503c&#xff0c;\u628a\u957f\u957f\u7684\u5c3e\u5df4\u7f29\u77ed&#xff0c;\u8ba9\u6574\u4e2a\u6570\u636e\u5206\u5e03\u770b\u8d77\u6765\u66f4\u50cf\u4e00\u4e2a\u5bf9\u79f0\u7684\u949f\u5f62\u3002\u8fd9\u6709\u52a9\u4e8e\u6a21\u578b\u66f4\u597d\u5730\u5b66\u4e60\u5230\u6570\u636e\u4e2d\u7684\u666e\u904d\u89c4\u5f8b&#xff0c;\u800c\u4e0d\u662f\u88ab\u5c11\u6570\u6781\u7aef\u503c\u5e26\u504f\u3002\u6211\u4eec\u4e4b\u524d\u5bf9SalePrice\u505a\u8fd9\u4e2a\u64cd\u4f5c\u4e5f\u662f\u51fa\u4e8e\u540c\u6837\u7684\u539f\u56e0\u3002<\/p>\n<p>\u8bed\u6cd5\u8bb2\u89e3 <span style=\"background-color:#d7d8d9\">numeric_feats &#061; all_data.dtypes[all_data.dtypes !&#061; &#034;object&#034;].index<\/span><\/p>\n<p><span style=\"background-color:#d7d8d9\">all_data.dtypes<\/span>&#xff1a;\u83b7\u53d6\u6bcf\u5217\u7684\u6570\u636e\u7c7b\u578b\u3002<\/p>\n<p>[<span style=\"background-color:#d7d8d9\">all_data.dtypes !&#061; &#034;object&#034;<\/span>]&#xff1a;\u4e00\u4e2a\u5e03\u5c14\u8fc7\u6ee4\u5668&#xff0c;\u53ea\u4fdd\u7559\u6570\u636e\u7c7b\u578b\u4e0d\u7b49\u4e8e&#034;object&#034;&#xff08;\u5373\u6587\u672c\u7c7b\u578b&#xff09;\u7684\u5217\u3002<\/p>\n<p>.index&#xff1a;\u83b7\u53d6\u8fd9\u4e9b\u88ab\u9009\u4e2d\u7684\u6570\u503c\u578b\u5217\u7684\u5217\u540d\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">skewed_feats &#061; all_data[numeric_feats].apply<\/span><\/p>\n<p><span style=\"background-color:#d7d8d9\">(lambda x: x.skew()).sort_values(ascending&#061;False)<\/span><\/p>\n<p><span style=\"background-color:#d7d8d9\">1.all_data[numeric_feats]: <\/span><span style=\"background-color:null\">\u4ec5\u9009\u62e9\u6240\u6709\u6570\u503c\u5217\u6784\u6210\u4e00\u4e2a\u65b0\u7684DataFrame\u3002<\/span><\/p>\n<p><span style=\"background-color:#d7d8d9\">2.apply(lambda x: x.skew()):<\/span> \u5bf9\u6bcf\u4e00\u5217(x)\u5e94\u7528.skew()\u51fd\u6570\u6765\u8ba1\u7b97\u5176\u504f\u6001\u7cfb\u6570\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">3.sort_values(ascending&#061;False)<\/span>: \u5c06\u8ba1\u7b97\u51fa\u7684\u504f\u6001\u7cfb\u6570\u503c\u4ece\u9ad8\u5230\u4f4e\u6392\u5e8f\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">skewness &#061; skewed_feats[abs(skewed_feats) &gt; 0.75]<\/span><\/p>\n<p>abs(&#8230;): \u53d6\u504f\u6001\u7cfb\u6570\u7684\u7edd\u5bf9\u503c\u3002<\/p>\n<p>&gt; 0.75: \u7b5b\u9009\u51fa\u90a3\u4e9b\u504f\u6001\u7a0b\u5ea6\u5f88\u9ad8\u7684\u7279\u5f81&#xff08;\u901a\u5e380.5-1\u4e4b\u95f4\u7b97\u4e2d\u5ea6\u504f\u6001&#xff0c;\u5927\u4e8e1\u7b97\u9ad8\u5ea6\u504f\u6001&#xff0c;0.75\u662f\u4e00\u4e2a\u5e38\u7528\u7684\u9608\u503c&#xff09;\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">for feat in skewness.index: &#8230;<\/span><\/p>\n<p><span style=\"background-color:null\">\u904d\u5386\u6bcf\u4e00\u4e2a\u88ab\u9274\u5b9a\u4e3a\u201c\u9ad8\u5ea6\u504f\u6001\u201d\u7684\u7279\u5f81\u540d\u3002<\/span><\/p>\n<p><span style=\"background-color:#d7d8d9\">all_data[feat] &#061; np.log1p(all_data[feat]):<\/span><span style=\"background-color:null\"> <\/span><\/p>\n<p><span style=\"background-color:null\">\u7528\u6211\u4eec\u719f\u6089\u7684log(1&#043;x)\u51fd\u6570\u6765\u66ff\u6362\u539f\u59cb\u7684\u5217\u6570\u636e&#xff0c;\u5b8c\u6210\u201c\u77eb\u6b63\u201d\u3002<\/span><\/p>\n<p>\u5c06\u7c7b\u522b\u7279\u5f81\u8f6c\u6362\u4e3a\u6570\u503c (One-Hot Encoding)<\/p>\n<p># One-Hot Encoding<br \/>\nall_data &#061; pd.get_dummies(all_data, drop_first&#061;True)<br \/>\nprint(f&#034;Feature engineering complete. Total features: {all_data.shape[1]}&#034;) <\/p>\n<p>:<\/p>\n<p>\u5b83\u5728\u505a\u4ec0\u4e48&#xff1f;<\/p>\n<p>\u8fd9\u884c\u4ee3\u7801\u662f\u9884\u5904\u7406\u7684\u4e34\u95e8\u4e00\u811a\u3002\u5b83\u4f7f\u7528\u4e00\u79cd\u540d\u4e3a\u72ec\u70ed\u7f16\u7801&#xff08;One-Hot Encoding\u7684\u6280\u672f&#xff0c;\u5c06\u6570\u636e\u96c6\u4e2d\u6240\u6709\u5269\u4f59\u7684\u6587\u672c\u7c7b\u522b\u7279\u5f81&#xff08;\u6bd4\u5982<span style=\"background-color:#d7d8d9\">Neighborhood<\/span>&#xff09;\u8f6c\u6362\u6210\u6a21\u578b\u53ef\u4ee5\u7406\u89e3\u76840\u548c1\u3002<\/p>\n<\/p>\n<p>\u4e3a\u4ec0\u4e48\u8981\u8fd9\u4e48\u505a&#xff1f; \u6838\u5fc3\u601d\u60f3&#xff1a;\u8ba1\u7b97\u673a\u6a21\u578b\u53ea\u61c2\u6570\u5b57&#xff0c;\u4e0d\u61c2\u6587\u5b57\u3002<\/p>\n<p>\u6211\u4eec\u4e0d\u80fd\u76f4\u63a5\u628a\u201cA\u533a\u201d\u3001\u201cB\u533a\u201d\u8fd9\u6837\u7684\u6587\u672c\u5582\u7ed9\u6a21\u578b\u3002\u4e00\u79cd\u7b80\u5355\u7684\u60f3\u6cd5\u662f\u628a\u5b83\u4eec\u6620\u5c04\u6210A\u533a-&gt;1, B\u533a-&gt;2\u3002\u4f46\u8fd9\u6837\u505a\u4f1a\u5f15\u5165\u4e00\u4e2a\u4e25\u91cd\u7684\u95ee\u9898&#xff1a;\u6a21\u578b\u4f1a\u8bef\u4ee5\u4e3a\u201cB\u533a &gt; A\u533a\u201d&#xff0c;\u5373\u5b83\u4eec\u4e4b\u95f4\u5b58\u5728\u4e00\u79cd\u4e0d\u5b58\u5728\u7684\u987a\u5e8f\u548c\u5927\u5c0f\u5173\u7cfb\u3002<\/p>\n<p>One-Hot\u7f16\u7801\u89e3\u51b3\u4e86\u8fd9\u4e2a\u95ee\u9898\u3002\u5047\u8bbe\u4e00\u4e2aColor\u5217\u6709\u4e09\u4e2a\u7c7b\u522b[&#039;Red&#039;, &#039;Green&#039;, &#039;Blue&#039;]&#xff0c;\u5b83\u4f1a\u8fd9\u6837\u505a&#xff1a;<\/p>\n<p>\u5220\u9664\u539f\u59cb\u7684Color\u5217\u3002<\/p>\n<p>\u521b\u5efa\u4e09\u4e2a\u65b0\u7684\u5217&#xff1a;Color_Red, Color_Green, Color_Blue\u3002<\/p>\n<p>\u5bf9\u4e8e\u539f\u6765\u662fRed\u7684\u884c&#xff0c;\u5728\u65b0\u5217Color_Red\u4e2d\u8bb0\u4e3a1&#xff0c;\u5176\u4ed6\u4e24\u4e2a\u8bb0\u4e3a0\u3002<\/p>\n<p>\u5bf9\u4e8e\u539f\u6765\u662fGreen\u7684\u884c&#xff0c;\u5728\u65b0\u5217Color_Green\u4e2d\u8bb0\u4e3a1&#xff0c;\u5176\u4ed6\u4e24\u4e2a\u8bb0\u4e3a0\u3002<\/p>\n<p>\u8fd9\u6837&#xff0c;\u6bcf\u4e2a\u7c7b\u522b\u90fd\u53d8\u6210\u4e86\u4e00\u4e2a\u72ec\u7acb\u76840\/1\u7279\u5f81&#xff0c;\u5b83\u4eec\u4e4b\u95f4\u662f\u5e73\u7b49\u7684&#xff0c;\u6ca1\u6709\u5927\u5c0f\u4e4b\u5206\u3002<\/p>\n<\/p>\n<p>\u8bed\u6cd5\u8bb2\u89e3 <span style=\"background-color:#d7d8d9\">pd.get_dummies(all_data, &#8230;)<\/span>: \u8fd9\u662fPandas\u4e2d\u6267\u884cOne-Hot\u7f16\u7801\u7684\u4e13\u7528\u51fd\u6570\u3002\u5b83\u4f1a\u81ea\u52a8\u627e\u5230DataFrame\u4e2d\u6240\u6709object\u7c7b\u578b\u6216\u5176\u4ed6\u7c7b\u522b\u578b\u6570\u636e&#xff0c;\u5e76\u5bf9\u5b83\u4eec\u8fdb\u884c\u8f6c\u6362\u3002<\/p>\n<p><span style=\"background-color:#d7d8d9\">drop_first&#061;True:<\/span> \u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u53c2\u6570\u3002\u4ee5\u4e0a\u9762\u7684Color\u4f8b\u5b50\u6765\u8bf4&#xff0c;\u5982\u679c\u6211\u4eec\u77e5\u9053\u4e86Color_Red\u662f0&#xff0c;Color_Green\u4e5f\u662f0&#xff0c;\u90a3\u6211\u4eec\u5c31\u80fd100%\u63a8\u65ad\u51faColor_Blue\u5fc5\u7136\u662f1\u3002\u8fd9\u610f\u5473\u7740\u5176\u4e2d\u4e00\u5217\u662f\u5197\u4f59\u7684\u3002drop_first&#061;True\u4f1a\u81ea\u52a8\u4e22\u5f03\u6bcf\u4e2a\u7279\u5f81\u7684\u7b2c\u4e00\u4e2a\u7c7b\u522b\u6240\u5bf9\u5e94\u7684\u5217&#xff0c;\u4ece\u800c\u907f\u514d\u591a\u91cd\u5171\u7ebf\u6027&#xff08;multicollinearity&#xff09;&#xff0c;\u8fd9\u4f1a\u8ba9\u4e00\u4e9b\u6a21\u578b&#xff08;\u7279\u522b\u662f\u7ebf\u6027\u6a21\u578b&#xff09;\u8fd0\u884c\u5f97\u66f4\u7a33\u5b9a\u3002<\/p>\n<p>\u81f3\u6b64&#xff0c;\u6574\u4e2a<span style=\"background-color:#d7d8d9\">all_data<\/span> DataFrame\u5df2\u7ecf\u88ab\u5f7b\u5e95\u201c\u51c0\u5316\u201d\u548c\u201c\u6539\u9020\u201d\u5b8c\u6bd5\u3002\u6240\u6709\u7684\u7279\u5f81\u90fd\u53d8\u6210\u4e86\u7eaf\u6570\u503c\u7c7b\u578b&#xff0c;\u504f\u6001\u7279\u5f81\u5f97\u5230\u4e86\u77eb\u6b63&#xff0c;\u7c7b\u522b\u7279\u5f81\u4e5f\u901a\u8fc7One-Hot\u7f16\u7801\u5b9e\u73b0\u4e86\u6570\u503c\u5316\u3002<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb591\u6b21\uff0c\u70b9\u8d5e19\u6b21\uff0c\u6536\u85cf10\u6b21\u3002\u6211\u4eec\u7684\u76ee\u6807\u662f\u6839\u636e\u623f\u5b50\u7684\u4fe1\u606f\uff08\u5982\u5730\u6bb5\u3001\u9762\u79ef\u7b49\uff09\uff0c\u9884\u6d4b\u623f\u5b50\u7684\u4ef7\u683c\u3002\u8fd9\u662f\u4e00\u4e2a\u5178\u578b\u7684\u4e8c\u5143\u5206\u7c7b\u95ee\u9898\u3002\u8fd9\u4e2a\u7ade\u8d5b\u5206\u4e24\u4e2a\u90e8\u5206\u8bb2\u89e3\uff1a\u4e00\u662f\u6570\u636e\u5904\u7406\u4e0e\u7279\u5f81\u5de5\u7a0b\uff0c\u4e8c\u662f\u7f51\u7edc\u642d\u5efa\u4e0e\u8bad\u7ec3\u8bb2\u89e3\u4ee3\u7801\u5206\u4e3a3\u4e2a\u6b65\u9aa4\uff1a\u6709\u4ec0\u4e48\u7528\uff0c\u4e3a\u4ec0\u4e48\u9700\u8981\u4ed6\uff0c\u5982\u4f55\u4f7f\u7528\u3002\u4fdd\u8bc1\u5927\u5bb6\u8010\u5fc3\u770b\u5b8c\u4e00\u5b9a\u5927\u6709\u88e8\u76ca\uff01\u5982\u679c\u6709\u61c2\u7684\u53ef\u4ee5\u8df3\u8fc7\u3002\u73b0\u5728\u5f00\u59cb\u5427\uff01<\/p>\n","protected":false},"author":2,"featured_media":55528,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[587,5723,152,50,62,207,86],"topic":[],"class_list":["post-55529","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-587","tag-kaggle","tag-pytorch","tag-50","tag-62","tag-207","tag-86"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>kaggle\u65b0\u624b\u5165\u95e8\u623f\u4ef7\u9884\u6d4b\uff1aPytorch\u4ee3\u7801-\u8d85\u8be6\u7ec6\u57fa\u7840\u8bb2\u89e3\uff0c\u4fdd\u8bc1\u4f60\u770b\u5b8c\u4e5f\u4f1a\uff01\uff08\u6570\u636e\u5904\u7406\u4e0e\u7279\u5f81\u5de5\u7a0b\u7bc7\uff09 - \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\/55529.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"kaggle\u65b0\u624b\u5165\u95e8\u623f\u4ef7\u9884\u6d4b\uff1aPytorch\u4ee3\u7801-\u8d85\u8be6\u7ec6\u57fa\u7840\u8bb2\u89e3\uff0c\u4fdd\u8bc1\u4f60\u770b\u5b8c\u4e5f\u4f1a\uff01\uff08\u6570\u636e\u5904\u7406\u4e0e\u7279\u5f81\u5de5\u7a0b\u7bc7\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb591\u6b21\uff0c\u70b9\u8d5e19\u6b21\uff0c\u6536\u85cf10\u6b21\u3002\u6211\u4eec\u7684\u76ee\u6807\u662f\u6839\u636e\u623f\u5b50\u7684\u4fe1\u606f\uff08\u5982\u5730\u6bb5\u3001\u9762\u79ef\u7b49\uff09\uff0c\u9884\u6d4b\u623f\u5b50\u7684\u4ef7\u683c\u3002\u8fd9\u662f\u4e00\u4e2a\u5178\u578b\u7684\u4e8c\u5143\u5206\u7c7b\u95ee\u9898\u3002\u8fd9\u4e2a\u7ade\u8d5b\u5206\u4e24\u4e2a\u90e8\u5206\u8bb2\u89e3\uff1a\u4e00\u662f\u6570\u636e\u5904\u7406\u4e0e\u7279\u5f81\u5de5\u7a0b\uff0c\u4e8c\u662f\u7f51\u7edc\u642d\u5efa\u4e0e\u8bad\u7ec3\u8bb2\u89e3\u4ee3\u7801\u5206\u4e3a3\u4e2a\u6b65\u9aa4\uff1a\u6709\u4ec0\u4e48\u7528\uff0c\u4e3a\u4ec0\u4e48\u9700\u8981\u4ed6\uff0c\u5982\u4f55\u4f7f\u7528\u3002\u4fdd\u8bc1\u5927\u5bb6\u8010\u5fc3\u770b\u5b8c\u4e00\u5b9a\u5927\u6709\u88e8\u76ca\uff01\u5982\u679c\u6709\u61c2\u7684\u53ef\u4ee5\u8df3\u8fc7\u3002\u73b0\u5728\u5f00\u59cb\u5427\uff01\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/55529.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-13T16:14:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813161438-689cb9ee1194d.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=\"11 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/55529.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/55529.html\",\"name\":\"kaggle\u65b0\u624b\u5165\u95e8\u623f\u4ef7\u9884\u6d4b\uff1aPytorch\u4ee3\u7801-\u8d85\u8be6\u7ec6\u57fa\u7840\u8bb2\u89e3\uff0c\u4fdd\u8bc1\u4f60\u770b\u5b8c\u4e5f\u4f1a\uff01\uff08\u6570\u636e\u5904\u7406\u4e0e\u7279\u5f81\u5de5\u7a0b\u7bc7\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-13T16:14:39+00:00\",\"dateModified\":\"2025-08-13T16:14:39+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/55529.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/55529.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/55529.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"kaggle\u65b0\u624b\u5165\u95e8\u623f\u4ef7\u9884\u6d4b\uff1aPytorch\u4ee3\u7801-\u8d85\u8be6\u7ec6\u57fa\u7840\u8bb2\u89e3\uff0c\u4fdd\u8bc1\u4f60\u770b\u5b8c\u4e5f\u4f1a\uff01\uff08\u6570\u636e\u5904\u7406\u4e0e\u7279\u5f81\u5de5\u7a0b\u7bc7\uff09\"}]},{\"@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":"kaggle\u65b0\u624b\u5165\u95e8\u623f\u4ef7\u9884\u6d4b\uff1aPytorch\u4ee3\u7801-\u8d85\u8be6\u7ec6\u57fa\u7840\u8bb2\u89e3\uff0c\u4fdd\u8bc1\u4f60\u770b\u5b8c\u4e5f\u4f1a\uff01\uff08\u6570\u636e\u5904\u7406\u4e0e\u7279\u5f81\u5de5\u7a0b\u7bc7\uff09 - \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\/55529.html","og_locale":"zh_CN","og_type":"article","og_title":"kaggle\u65b0\u624b\u5165\u95e8\u623f\u4ef7\u9884\u6d4b\uff1aPytorch\u4ee3\u7801-\u8d85\u8be6\u7ec6\u57fa\u7840\u8bb2\u89e3\uff0c\u4fdd\u8bc1\u4f60\u770b\u5b8c\u4e5f\u4f1a\uff01\uff08\u6570\u636e\u5904\u7406\u4e0e\u7279\u5f81\u5de5\u7a0b\u7bc7\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb591\u6b21\uff0c\u70b9\u8d5e19\u6b21\uff0c\u6536\u85cf10\u6b21\u3002\u6211\u4eec\u7684\u76ee\u6807\u662f\u6839\u636e\u623f\u5b50\u7684\u4fe1\u606f\uff08\u5982\u5730\u6bb5\u3001\u9762\u79ef\u7b49\uff09\uff0c\u9884\u6d4b\u623f\u5b50\u7684\u4ef7\u683c\u3002\u8fd9\u662f\u4e00\u4e2a\u5178\u578b\u7684\u4e8c\u5143\u5206\u7c7b\u95ee\u9898\u3002\u8fd9\u4e2a\u7ade\u8d5b\u5206\u4e24\u4e2a\u90e8\u5206\u8bb2\u89e3\uff1a\u4e00\u662f\u6570\u636e\u5904\u7406\u4e0e\u7279\u5f81\u5de5\u7a0b\uff0c\u4e8c\u662f\u7f51\u7edc\u642d\u5efa\u4e0e\u8bad\u7ec3\u8bb2\u89e3\u4ee3\u7801\u5206\u4e3a3\u4e2a\u6b65\u9aa4\uff1a\u6709\u4ec0\u4e48\u7528\uff0c\u4e3a\u4ec0\u4e48\u9700\u8981\u4ed6\uff0c\u5982\u4f55\u4f7f\u7528\u3002\u4fdd\u8bc1\u5927\u5bb6\u8010\u5fc3\u770b\u5b8c\u4e00\u5b9a\u5927\u6709\u88e8\u76ca\uff01\u5982\u679c\u6709\u61c2\u7684\u53ef\u4ee5\u8df3\u8fc7\u3002\u73b0\u5728\u5f00\u59cb\u5427\uff01","og_url":"https:\/\/www.wsisp.com\/helps\/55529.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-13T16:14:39+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250813161438-689cb9ee1194d.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"11 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/55529.html","url":"https:\/\/www.wsisp.com\/helps\/55529.html","name":"kaggle\u65b0\u624b\u5165\u95e8\u623f\u4ef7\u9884\u6d4b\uff1aPytorch\u4ee3\u7801-\u8d85\u8be6\u7ec6\u57fa\u7840\u8bb2\u89e3\uff0c\u4fdd\u8bc1\u4f60\u770b\u5b8c\u4e5f\u4f1a\uff01\uff08\u6570\u636e\u5904\u7406\u4e0e\u7279\u5f81\u5de5\u7a0b\u7bc7\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-13T16:14:39+00:00","dateModified":"2025-08-13T16:14:39+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/55529.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/55529.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/55529.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"kaggle\u65b0\u624b\u5165\u95e8\u623f\u4ef7\u9884\u6d4b\uff1aPytorch\u4ee3\u7801-\u8d85\u8be6\u7ec6\u57fa\u7840\u8bb2\u89e3\uff0c\u4fdd\u8bc1\u4f60\u770b\u5b8c\u4e5f\u4f1a\uff01\uff08\u6570\u636e\u5904\u7406\u4e0e\u7279\u5f81\u5de5\u7a0b\u7bc7\uff09"}]},{"@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\/55529","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=55529"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/55529\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/55528"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=55529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=55529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=55529"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=55529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}