{"id":1009340,"date":"2024-12-27T11:10:55","date_gmt":"2024-12-27T03:10:55","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1009340.html"},"modified":"2024-12-27T11:10:58","modified_gmt":"2024-12-27T03:10:58","slug":"python%e4%b8%ad%e5%a6%82%e4%bd%95%e5%ae%89%e8%a3%85sklearn","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1009340.html","title":{"rendered":"python\u4e2d\u5982\u4f55\u5b89\u88c5sklearn"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25084315\/2e2cf66e-09bf-44f7-8a9b-c3ac3db258e4.webp\" alt=\"python\u4e2d\u5982\u4f55\u5b89\u88c5sklearn\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u5b89\u88c5sklearn\u975e\u5e38\u7b80\u5355\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u3001conda\u547d\u4ee4\u3001\u786e\u4fddPython\u73af\u5883\u5df2\u5b89\u88c5\u3001\u786e\u4fddpip\u6216conda\u7248\u672c\u6700\u65b0\u3002<\/strong> \u9996\u5148\uff0c\u4f7f\u7528pip\u547d\u4ee4\u662f\u6700\u5e38\u89c1\u7684\u65b9\u5f0f\uff0c\u53ea\u9700\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>pip install scikit-learn<\/code>\u5373\u53ef\u3002\u5bf9\u4e8e\u4f7f\u7528Anaconda\u7684\u7528\u6237\uff0c\u53ef\u4ee5\u901a\u8fc7<code>conda install scikit-learn<\/code>\u6765\u5b8c\u6210\u5b89\u88c5\u3002\u6b64\u5916\uff0c\u786e\u4fdd\u4f60\u7684Python\u73af\u5883\u5df2\u7ecf\u6b63\u786e\u5b89\u88c5\u5e76\u914d\u7f6e\uff0c\u56e0\u4e3asklearn\u662f\u4e00\u4e2a\u4f9d\u8d56\u4e8ePython\u7684\u5e93\u3002\u6700\u540e\uff0c\u5b9a\u671f\u66f4\u65b0\u4f60\u7684pip\u6216conda\u7248\u672c\uff0c\u4ee5\u907f\u514d\u56e0\u7248\u672c\u8fc7\u65e7\u5bfc\u81f4\u7684\u5b89\u88c5\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><p><strong>\u4f7f\u7528pip\u547d\u4ee4\u5b89\u88c5<\/strong><\/p>\n<\/p>\n<p><p>Pip\u662fPython\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u4f7f\u7528\u5b83\u6765\u5b89\u88c5scikit-learn\u975e\u5e38\u7b80\u5355\u3002\u9996\u5148\uff0c\u6253\u5f00\u4f60\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff08Windows\u7528\u6237\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u63d0\u793a\u7b26\u6216PowerShell\uff0cmacOS\u548cLinux\u7528\u6237\u53ef\u4ee5\u4f7f\u7528\u7ec8\u7aef\uff09\u3002\u786e\u4fdd\u4f60\u7684Python\u73af\u5883\u5df2\u88ab\u6b63\u786e\u914d\u7f6e\uff0c\u5e76\u4e14pip\u5df2\u7ecf\u5b89\u88c5\u548c\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002<\/p>\n<\/p>\n<p><p>\u5728\u547d\u4ee4\u884c\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install scikit-learn<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8be5\u547d\u4ee4\u4f1a\u81ea\u52a8\u4ecePython Package Index\uff08PyPI\uff09\u4e0b\u8f7d\u5e76\u5b89\u88c5scikit-learn\u4ee5\u53ca\u5176\u6240\u9700\u7684\u4f9d\u8d56\u5305\u3002<\/p>\n<\/p>\n<p><p><strong>\u4f7f\u7528Conda\u547d\u4ee4\u5b89\u88c5<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662fAnaconda\u5206\u53d1\u7248\u7684Python\uff0c\u90a3\u4e48\u4f7f\u7528conda\u6765\u7ba1\u7406\u548c\u5b89\u88c5\u5305\u53ef\u80fd\u66f4\u4e3a\u65b9\u4fbf\u3002Conda\u662fAnaconda\u73af\u5883\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u81ea\u52a8\u5904\u7406\u5305\u7684\u4f9d\u8d56\u5173\u7cfb\u5e76\u9002\u7528\u4e8e\u66f4\u590d\u6742\u7684\u73af\u5883\u914d\u7f6e\u3002<\/p>\n<\/p>\n<p><p>\u6253\u5f00Anaconda Prompt\uff08\u6216\u4f60\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff09\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda install scikit-learn<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>Conda\u4f1a\u81ea\u52a8\u68c0\u6d4b\u5e76\u5b89\u88c5scikit-learn\u53ca\u5176\u6240\u6709\u4f9d\u8d56\u9879\u3002<\/p>\n<\/p>\n<p><p><strong>\u786e\u4fddPython\u73af\u5883\u5df2\u5b89\u88c5<\/strong><\/p>\n<\/p>\n<p><p>\u5b89\u88c5sklearn\u4e4b\u524d\uff0c\u786e\u4fdd\u4f60\u7684\u8ba1\u7b97\u673a\u4e0a\u5df2\u6b63\u786e\u5b89\u88c5Python\u73af\u5883\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u68c0\u67e5Python\u662f\u5426\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u4f60\u7684\u7cfb\u7edf\u8fd4\u56dePython\u7684\u7248\u672c\u53f7\uff0c\u8bf4\u660ePython\u5df2\u7ecf\u5b89\u88c5\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5\uff0c\u8bf7\u4ecePython\u5b98\u7f51\u4e0b\u8f7d\u5b89\u88c5\u5305\u5e76\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><p><strong>\u786e\u4fddpip\u6216conda\u7248\u672c\u6700\u65b0<\/strong><\/p>\n<\/p>\n<p><p>\u5305\u7ba1\u7406\u5de5\u5177\u7684\u7248\u672c\u8fc7\u65e7\u53ef\u80fd\u5bfc\u81f4\u5b89\u88c5\u95ee\u9898\u3002\u5728\u5b89\u88c5sklearn\u4e4b\u524d\uff0c\u5efa\u8bae\u5c06pip\u6216conda\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002<\/p>\n<\/p>\n<p><p>\u5bf9\u4e8epip\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u66f4\u65b0\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m pip install --upgrade pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5bf9\u4e8econda\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u66f4\u65b0\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda update conda<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>\u5b89\u88c5\u540e\u7684\u9a8c\u8bc1<\/strong><\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u5efa\u8bae\u9a8c\u8bc1sklearn\u662f\u5426\u6b63\u786e\u5b89\u88c5\u3002\u53ef\u4ee5\u901a\u8fc7Python\u89e3\u91ca\u5668\u6267\u884c\u4ee5\u4e0b\u4ee3\u7801\u6765\u6d4b\u8bd5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sklearn<\/p>\n<p>print(sklearn.__version__)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u6ca1\u6709\u9519\u8bef\u4fe1\u606f\u5e76\u8f93\u51fa\u7248\u672c\u53f7\uff0c\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<p><p><strong>\u89e3\u51b3\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u7684\u5e38\u89c1\u95ee\u9898<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u4f60\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u95ee\u9898\u3002\u5e38\u89c1\u95ee\u9898\u5305\u62ec\u7f51\u7edc\u8fde\u63a5\u95ee\u9898\u3001\u6743\u9650\u4e0d\u8db3\u3001\u4f9d\u8d56\u5173\u7cfb\u51b2\u7a81\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u7f51\u7edc\u8fde\u63a5\u95ee\u9898<\/strong>\uff1a\u786e\u4fdd\u4f60\u7684\u8ba1\u7b97\u673a\u53ef\u4ee5\u8bbf\u95ee\u5916\u7f51\u3002\u5982\u679c\u516c\u53f8\u6216\u5b66\u6821\u7f51\u7edc\u9650\u5236\u4e86\u5916\u7f51\u8bbf\u95ee\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528VPN\u6216\u8054\u7cfb\u7f51\u7edc\u7ba1\u7406\u5458\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6743\u9650\u4e0d\u8db3<\/strong>\uff1a\u5728Windows\u4e2d\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\u547d\u4ee4\u63d0\u793a\u7b26\uff1b\u5728macOS\u6216Linux\u4e2d\uff0c\u4f7f\u7528<code>sudo<\/code>\u547d\u4ee4\u6765\u63d0\u5347\u6743\u9650\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f9d\u8d56\u5173\u7cfb\u51b2\u7a81<\/strong>\uff1a\u5982\u679c\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u4f9d\u8d56\u5173\u7cfb\u51b2\u7a81\uff0c\u53ef\u80fd\u9700\u8981\u624b\u52a8\u5b89\u88c5\u6216\u66f4\u65b0\u51b2\u7a81\u7684\u5305\u3002\u4f7f\u7528<code>pip list<\/code>\u6216<code>conda list<\/code>\u67e5\u770b\u5df2\u5b89\u88c5\u5305\uff0c\u5e76\u4f7f\u7528<code>pip install --upgrade package_name<\/code>\u6216<code>conda update package_name<\/code>\u66f4\u65b0\u76f8\u5173\u5305\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5e94\u8be5\u80fd\u591f\u987a\u5229\u5b89\u88c5\u5e76\u914d\u7f6esklearn\u5e93\uff0c\u5f00\u59cb\u4f60\u7684<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u9879\u76ee\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5b89\u88c5sklearn\uff1f<\/strong><br \/>\u8981\u5728Python\u4e2d\u5b89\u88c5sklearn\uff08\u5373scikit-learn\uff09\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528Python\u7684\u5305\u7ba1\u7406\u5de5\u5177pip\u3002\u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<code>pip install scikit-learn<\/code>\u3002\u786e\u4fdd\u60a8\u5df2\u7ecf\u5b89\u88c5\u4e86pip\uff0c\u5e76\u4e14\u60a8\u7684Python\u73af\u5883\u5df2\u914d\u7f6e\u6b63\u786e\u3002\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0cpip\u4f1a\u81ea\u52a8\u5904\u7406\u4f9d\u8d56\u5173\u7cfb\u3002<\/p>\n<p><strong>\u5728\u5b89\u88c5sklearn\u4e4b\u524d\uff0c\u9700\u8981\u51c6\u5907\u4ec0\u4e48\uff1f<\/strong><br \/>\u5728\u5b89\u88c5sklearn\u4e4b\u524d\uff0c\u5efa\u8bae\u60a8\u786e\u4fdd\u7cfb\u7edf\u4e2d\u5df2\u5b89\u88c5Python\u53ca\u5176\u5305\u7ba1\u7406\u5de5\u5177pip\u3002\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c<code>python --version<\/code>\u548c<code>pip --version<\/code>\u6765\u68c0\u67e5\u5176\u662f\u5426\u5df2\u6b63\u786e\u5b89\u88c5\u3002\u6b64\u5916\uff0c\u4f7f\u7528\u865a\u62df\u73af\u5883\uff08\u5982venv\u6216conda\uff09\u53ef\u4ee5\u5e2e\u52a9\u60a8\u7ba1\u7406\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u907f\u514d\u4e0e\u5176\u4ed6\u9879\u76ee\u51b2\u7a81\u3002<\/p>\n<p><strong>\u5982\u679c\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9047\u5230\u9519\u8bef\uff0c\u8be5\u5982\u4f55\u89e3\u51b3\uff1f<\/strong><br \/>\u5982\u679c\u5728\u5b89\u88c5sklearn\u65f6\u9047\u5230\u9519\u8bef\uff0c\u5efa\u8bae\u9996\u5148\u68c0\u67e5Python\u548cpip\u7684\u7248\u672c\u662f\u5426\u652f\u6301\u5f53\u524d\u7684scikit-learn\u7248\u672c\u3002\u67d0\u4e9b\u4f9d\u8d56\u5e93\u53ef\u80fd\u4e5f\u9700\u8981\u66f4\u65b0\u3002\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\u547d\u4ee4<code>pip install --upgrade pip<\/code>\u6765\u5347\u7ea7pip\u3002\u5982\u679c\u95ee\u9898\u4ecd\u7136\u5b58\u5728\uff0c\u67e5\u770b\u9519\u8bef\u4fe1\u606f\u4e2d\u7684\u63d0\u793a\uff0c\u6216\u8bbf\u95eescikit-learn\u7684\u5b98\u65b9\u6587\u6863\u548cGitHub\u9875\u9762\u4ee5\u5bfb\u6c42\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u5b89\u88c5sklearn\u975e\u5e38\u7b80\u5355\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528pip\u547d\u4ee4\u3001conda\u547d\u4ee4\u3001\u786e\u4fddPython\u73af\u5883\u5df2\u5b89\u88c5\u3001 [&hellip;]","protected":false},"author":3,"featured_media":1009349,"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\/1009340"}],"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=1009340"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1009340\/revisions"}],"predecessor-version":[{"id":1009352,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1009340\/revisions\/1009352"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1009349"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1009340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1009340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1009340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}